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

import com.YuyeTech.TPlat.common.pojo.Result;
import com.YuyeTech.TPlat.common.service.*;
import com.YuyeTech.TPlat.sys.syssettinglimit.pojo.SysSettingLimit;
import com.YuyeTech.TPlat.sys.syssettinglimit.repository.SysSettingLimitRepository;
import com.YuyeTech.TPlat.sys.syssettinglimit.vo.SysSettingLimitVo;
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 SysSettingLimitServiceImpl extends CommonServiceImpl<SysSettingLimitVo, SysSettingLimit, String> implements SysSettingLimitService{

    @PersistenceContext
    private EntityManager em;
    @Autowired
    private SysSettingLimitRepository sysSettingLimitRepository;

    @Autowired
    private RedisSettingMap redisSettingMap;
    @Override
    public Result<SysSettingLimitVo> save(SysSettingLimitVo entityVo) {
        //调用父类
        Result<SysSettingLimitVo> result = super.save(entityVo);

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