package com.td.Dawa.sys.syssetting.service;

import com.td.Dawa.common.pojo.Result;
import com.td.Dawa.common.service.CommonServiceImpl;
import com.td.Dawa.sys.syssetting.pojo.SysSetting;
import com.td.Dawa.sys.syssetting.repository.SysSettingRepository;
import com.td.Dawa.sys.syssetting.vo.SysSettingVo;
import com.td.Dawa.util.RedisSettingMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Service
@Transactional
public class SysSettingServiceImpl extends CommonServiceImpl<SysSettingVo, SysSetting, String> implements SysSettingService{

    @PersistenceContext
    private EntityManager em;
    @Autowired
    private SysSettingRepository sysSettingRepository;
    @Autowired
    private RedisSettingMap redisSettingMap;
    @Override
    public Result<SysSettingVo> save(SysSettingVo entityVo) {
        //调用父类
        Result<SysSettingVo> result = super.save(entityVo);

        //更新系统设置时同步更新公用静态集合sysSettingMap
        //SysSettingUtil.setSysSettingMap(result.getData());
        redisSettingMap.setSysSettingMap(result.getData());
        return result;
    }
}
