package com.YuyeTech.TPlat.sys.syssetting.service;

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