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

import com.td.WaDa.common.pojo.Result;
import com.td.WaDa.common.service.CommonServiceImpl;
import com.td.WaDa.sys.syssetting.pojo.SysSetting;
import com.td.WaDa.sys.syssetting.repository.SysSettingRepository;
import com.td.WaDa.sys.syssetting.vo.SysSettingVo;
import com.td.WaDa.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;
    }
}
