package com.qmth.teachcloud.common.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qmth.teachcloud.common.bean.auth.AuthBean;
import com.qmth.teachcloud.common.bean.result.MenuResult;
import com.qmth.teachcloud.common.contant.SystemConstant;
import com.qmth.teachcloud.common.entity.*;
import com.qmth.teachcloud.common.enums.PrivilegePropertyEnum;
import com.qmth.teachcloud.common.service.*;
import io.swagger.models.auth.In;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import java.util.Set;

/**
 * @Description: 缓存操作serviceImpl 实现类
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2021/3/25
 */
@Service
public class CommonCacheServiceImpl implements CommonCacheService {
    private final static Logger log = LoggerFactory.getLogger(CommonCacheServiceImpl.class);

    @Resource
    SysUserService sysUserService;

    @Resource
    BasicSchoolService basicSchoolService;

    @Resource
    TeachcloudCommonService commonService;

    @Resource
    SysOrgService sysOrgService;

    @Resource
    SysRoleService sysRoleService;

    @Resource
    SysConfigService sysConfigService;

    @Resource
    CacheManager cacheManager;

    @Resource
    TSchoolPrivilegeService tSchoolPrivilegeService;

    @Resource
    TSchoolRoleService tSchoolRoleService;

    /**
     * 添加角色缓存
     *
     * @param roleId
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.ROLE_CACHE, key = "#p0", unless = "#result == null")
    public SysRole roleCache(Long roleId) {
        return sysRoleService.getById(roleId);
    }

    /**
     * 修改角色缓存
     *
     * @param roleId
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.ROLE_CACHE, key = "#p0", condition = "#result != null")
    public SysRole updateRoleCache(Long roleId) {
        return sysRoleService.getById(roleId);
    }

    /**
     * 删除角色缓存
     *
     * @param roleId
     * @return
     */
    @Override
    @CacheEvict(value = SystemConstant.ROLE_CACHE, key = "#p0")
    public void removeRoleCache(Long roleId) {

    }

    /**
     * 添加用户菜单缓存
     *
     * @param userId
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.USER_MENU_CACHE, key = "#p0", unless = "#result == null")
    public MenuResult userMenuCache(Long userId) {
        return commonService.getUserMenu(userId);
    }

    /**
     * 修改用户菜单缓存
     *
     * @param userId
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.USER_MENU_CACHE, key = "#p0", condition = "#result != null")
    public MenuResult updateUserMenuCache(Long userId) {
        return commonService.getUserMenu(userId);
    }

    /**
     * 删除用户菜单缓存
     *
     * @param userId
     */
    @Override
    @CacheEvict(value = SystemConstant.USER_MENU_CACHE, key = "#p0")
    public void removeUserMenuCache(Long userId) {

    }

    /**
     * 添加用户缓存
     *
     * @param userId
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0", unless = "#result == null")
    public SysUser userCache(Long userId) {
        return sysUserService.getById(userId);
    }

    /**
     * 修改用户缓存
     *
     * @param userId
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0", condition = "#result != null")
    public SysUser updateUserCache(Long userId) {
        return sysUserService.getById(userId);
    }

    /**
     * 删除用户缓存
     *
     * @param userId
     */
    @Override
    @CacheEvict(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0")
    public void removeUserCache(Long userId) {

    }

    /**
     * 添加用户鉴权缓存
     *
     * @param userId
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.USER_OAUTH_CACHE, key = "#p0", unless = "#result == null")
    public AuthBean userAuthCache(Long userId) {
        return commonService.getUserAuth(userId);
    }

    /**
     * 修改用户鉴权缓存
     *
     * @param userId
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.USER_OAUTH_CACHE, key = "#p0", condition = "#result != null")
    public AuthBean updateUserAuthCache(Long userId) {
        return commonService.getUserAuth(userId);
    }

    /**
     * 删除用户鉴权缓存
     *
     * @param userId
     */
    @Override
    @CacheEvict(value = SystemConstant.USER_OAUTH_CACHE, key = "#p0")
    public void removeUserAuthCache(Long userId) {

    }

    /**
     * 添加学校缓存
     *
     * @param schoolId
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.SCHOOL_CACHE, key = "#p0", unless = "#result == null")
    public BasicSchool schoolCache(Long schoolId) {
        return basicSchoolService.getById(schoolId);
    }

    /**
     * 添加学校缓存
     *
     * @param code
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.SCHOOL_CODE_CACHE, key = "#p0", unless = "#result == null")
    public BasicSchool schoolCache(String code) {
        QueryWrapper<BasicSchool> basicSchoolQueryWrapper = new QueryWrapper<>();
        basicSchoolQueryWrapper.lambda().eq(BasicSchool::getCode, code);
        return basicSchoolService.getOne(basicSchoolQueryWrapper);
    }

    /**
     * 更新学校缓存
     *
     * @param schoolId
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.SCHOOL_CACHE, key = "#p0", condition = "#result != null")
    public BasicSchool updateSchoolCache(Long schoolId) {
        return basicSchoolService.getById(schoolId);
    }

    /**
     * 更新学校缓存
     *
     * @param code
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.SCHOOL_CODE_CACHE, key = "#p0", condition = "#result != null")
    public BasicSchool updateSchoolCache(String code) {
        QueryWrapper<BasicSchool> basicSchoolQueryWrapper = new QueryWrapper<>();
        basicSchoolQueryWrapper.lambda().eq(BasicSchool::getCode, code);
        return basicSchoolService.getOne(basicSchoolQueryWrapper);
    }

    /**
     * 删除学校缓存
     *
     * @param schoolId
     */
    @Override
    @CacheEvict(value = SystemConstant.SCHOOL_CACHE, key = "#p0")
    public void removeSchoolCache(Long schoolId) {

    }

    /**
     * 删除学校缓存
     */
    @Override
    @CacheEvict(value = SystemConstant.SCHOOL_CACHE, allEntries = true)
    public void removeSchoolIdCache() {

    }

    /**
     * 删除学校缓存
     *
     * @param code
     */
    @Override
    @CacheEvict(value = SystemConstant.SCHOOL_CODE_CACHE, key = "#p0")
    public void removeSchoolCache(String code) {

    }

    /**
     * 删除学校缓存
     */
    @Override
    @CacheEvict(value = SystemConstant.SCHOOL_CODE_CACHE, allEntries = true)
    public void removeSchoolCodeCache() {

    }

    /**
     * 添加机构缓存
     *
     * @param orgId
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.ORG_CACHE, key = "#p0", unless = "#result == null")
    public SysOrg orgCache(Long orgId) {
        return sysOrgService.getById(orgId);
    }

    /**
     * 更新机构缓存
     *
     * @param orgId
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.ORG_CACHE, key = "#p0", condition = "#result != null")
    public SysOrg updateOrgCache(Long orgId) {
        return sysOrgService.getById(orgId);
    }

    /**
     * 删除机构缓存
     *
     * @param orgId
     */
    @Override
    @CacheEvict(value = SystemConstant.ORG_CACHE, key = "#p0")
    public void removeOrgCache(Long orgId) {

    }

    /**
     * 删除机构缓存
     */
    @Override
    @CacheEvict(value = SystemConstant.ORG_CACHE, allEntries = true)
    public void removeOrgCache() {

    }

    /**
     * 获取鉴权url
     *
     * @param privilegePropertyEnum
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.PRIVILEGE_URL_CACHE, key = "#p0", unless = "#result == null")
    public Set<String> privilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum) {
        return commonService.getPrivilegeUrl(privilegePropertyEnum);
    }

    @Override
    @Cacheable(value = SystemConstant.PRIVILEGE_URL_CACHE, key = "#p0 + '-' + #p1", unless = "#result == null")
    public Set<String> privilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum, Long schoolId) {
        return commonService.getPrivilegeUrl(privilegePropertyEnum, schoolId);
    }

    /**
     * 修改鉴权url
     *
     * @param privilegePropertyEnum
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.PRIVILEGE_URL_CACHE, key = "#p0", condition = "#result != null")
    public Set<String> updatePrivilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum) {
        return commonService.getPrivilegeUrl(privilegePropertyEnum);
    }

    /**
     * 删除鉴权url
     *
     * @param privilegePropertyEnum
     */
    @Override
    @CacheEvict(value = SystemConstant.PRIVILEGE_URL_CACHE, key = "#p0")
    public void removePrivilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum) {

    }

    /**
     * 获取角色权限缓存
     *
     * @param roleId
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.ROLE_PRIVILEGE_CACHE, key = "#p0", unless = "#result == null")
    public List<SysRolePrivilege> rolePrivilegeCache(Long roleId) {
        return commonService.getRolePrivilege(roleId);
    }

    /**
     * 修改角色权限缓存
     *
     * @param roleId
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.ROLE_PRIVILEGE_CACHE, key = "#p0", condition = "#result != null")
    public List<SysRolePrivilege> updateRolePrivilegeCache(Long roleId) {
        return commonService.getRolePrivilege(roleId);
    }

    /**
     * 删除角色权限缓存
     *
     * @param roleId
     */
    @Override
    @CacheEvict(value = SystemConstant.ROLE_PRIVILEGE_CACHE, key = "#p0")
    public void removeRolePrivilegeCache(Long roleId) {

    }

    /**
     * 添加用户角色权限缓存
     *
     * @param userId
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.USER_ROLE_PRIVILEGE_CACHE, key = "#p0", unless = "#result == null")
    public List<SysUserRole> userRolePrivilegeCache(Long userId) {
        return commonService.getUserRolePrivilege(userId);
    }

    /**
     * 修改用户角色权限缓存
     *
     * @param userId
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.USER_ROLE_PRIVILEGE_CACHE, key = "#p0", condition = "#result != null")
    public List<SysUserRole> updateUserRolePrivilegeCache(Long userId) {
        return commonService.getUserRolePrivilege(userId);
    }

    /**
     * 删除用户角色权限缓存
     *
     * @param userId
     */
    @Override
    @CacheEvict(value = SystemConstant.USER_ROLE_PRIVILEGE_CACHE, key = "#p0")
    public void removeUserRolePrivilegeCache(Long userId) {

    }

    /**
     * 删除考生个人报告缓存
     */
    @Override
    @CacheEvict(value = SystemConstant.EXAM_STUDENT_REPORT, allEntries = true)
    public void removeExamStudentReportCache() {

    }

    /**
     * 删除院长缓存
     */
    @Override
    @CacheEvict(value = SystemConstant.COLLEGE_DEAN_REPORT, allEntries = true)
    public void removeCollegeDeanCache() {

    }

    /**
     * 删除学院学科缓存
     */
    @Override
    @CacheEvict(value = SystemConstant.COLLEGE_COURSE_REPORT, allEntries = true)
    public void removeCollegeCourseCache() {

    }

    /**
     * 删除开课课程考试总览图表缓存
     */
    @Override
    @CacheEvict(value = SystemConstant.SURVEY_TEACHER_VIEW_REPORT, allEntries = true)
    public void removeSurveyTeacherViewCache() {

    }

    /**
     * 删除考生个人报告缓存
     *
     * @param schoolId
     * @param studentCode
     * @param examId
     * @param courseCode
     */
    @Override
    @CacheEvict(value = SystemConstant.EXAM_STUDENT_REPORT, key = "#schoolId + '-' + #studentCode + '-' + #examId + '-' + #courseCode")
    public void removeExamStudentReportCache(Long schoolId, String studentCode, String examId, String courseCode) {

    }

    /**
     * 删除院长缓存
     *
     * @param schoolId
     * @param semesterId
     * @param examId
     * @param collegeId
     */
    @Override
    @CacheEvict(value = SystemConstant.COLLEGE_DEAN_REPORT, key = "#schoolId + '-' + #semesterId + '-' + #examId + '-' +#collegeId")
    public void removeCollegeDeanCache(Long schoolId, Long semesterId, Long examId, Long collegeId) {

    }

    /**
     * 删除学院学科缓存
     *
     * @param schoolId
     * @param semesterId
     * @param examId
     * @param courseCode
     * @param collegeId
     */
    @Override
    @CacheEvict(value = SystemConstant.COLLEGE_COURSE_REPORT, key = "#schoolId + '-' + #semesterId + '-' + #examId + '-' + #courseCode + '-' + #collegeId")
    public void removeCollegeCourseCache(Long schoolId, Long semesterId, Long examId, String courseCode, Long collegeId) {

    }

    /**
     * 删除开课课程考试分析图表缓存
     *
     * @param schoolId
     * @param semesterId
     * @param examId
     * @param courseCode
     * @param collegeId
     */
    @Override
    @CacheEvict(value = SystemConstant.SURVEY_TEACHER_VIEW_REPORT, key = "#schoolId + '-' + #semesterId + '-' + #examId + '-' + #courseCode + '-' + #collegeId")
    public void removeSurveyTeacherViewCache(Long schoolId, Long semesterId, Long examId, String courseCode, Long collegeId) {

    }

//    @Override
//    @Cacheable(value = SystemConstant.AUTH_INFO_CACHE, key = "#p0", unless = "#result == null")
//    public AuthOrgInfoDto authInfoCache(String code) {
//        AppInfo appInfo = solarService.getAppInfo();
//        AuthOrgInfoDto authOrgInfoDto = null;
//        if (Objects.nonNull(appInfo)) {
//            List<OrgInfo> orgInfoList = solarService.getOrgList().stream().filter(s -> Objects.equals(s.getCode(), code)).collect(Collectors.toList());
//            if (Objects.nonNull(orgInfoList) && orgInfoList.size() > 0) {
//                authOrgInfoDto = new AuthOrgInfoDto(orgInfoList.get(0), appInfo.getControl());
//            }
//        }
//        return authOrgInfoDto;
//    }
//f
//    @Override
//    @CachePut(value = SystemConstant.AUTH_INFO_CACHE, key = "#p0", condition = "#result != null")
//    public AuthOrgInfoDto updateAuthInfoCache(String code) {
//        AppInfo appInfo = solarService.getAppInfo();
//        AuthOrgInfoDto authOrgInfoDto = null;
//        if (Objects.nonNull(appInfo)) {
//            List<OrgInfo> orgInfoList = solarService.getOrgList().stream().filter(s -> Objects.equals(s.getCode(), code)).collect(Collectors.toList());
//            if (Objects.nonNull(orgInfoList) && orgInfoList.size() > 0) {
//                authOrgInfoDto = new AuthOrgInfoDto(orgInfoList.get(0), appInfo.getControl());
//            }
//        }
//        return authOrgInfoDto;
//    }
//
//    @Override
//    @CacheEvict(value = SystemConstant.AUTH_INFO_CACHE, key = "#p0")
//    public void removeAuthInfoCache(String code) {
//
//    }

    /**
     * 添加系统参数缓存
     *
     * @param key
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0", unless = "#result == null")
    public SysConfig addSysConfigCache(String key) {
        return sysConfigService.getOne(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getConfigKey, key));
    }

    /**
     * 更新系统参数缓存
     *
     * @param key
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0", condition = "#result != null")
    public SysConfig updateSysConfigCache(String key) {
        return sysConfigService.getOne(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getConfigKey, key));
    }

    /**
     * 删除系统参数缓存
     *
     * @param key
     */
    @Override
    @CacheEvict(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0")
    public void removeSysConfigCache(String key) {

    }

    /**
     * 更新系统参数缓存
     *
     * @param key
     * @return
     */
    @Override
    public void updateSysConfigCacheForDb(String key, SysConfig sysConfig) {
        cacheManager.getCache(SystemConstant.SYS_CONFIG_CACHE).put(key, sysConfig);
    }

    /**
     * 添加系统参数缓存
     *
     * @param schoolId
     * @param key
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0 + '-' + #p1", unless = "#result == null")
    public SysConfig addSysConfigCache(Long schoolId, String key) {
        return sysConfigService.getOne(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getSchoolId, schoolId).eq(SysConfig::getConfigKey, key));
    }

    /**
     * 更新系统参数缓存
     *
     * @param schoolId
     * @param key
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0 + '-' + #p1", condition = "#result != null")
    public SysConfig updateSysConfigCache(Long schoolId, String key) {
        return sysConfigService.getOne(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getSchoolId, schoolId).eq(SysConfig::getConfigKey, key));
    }

    /**
     * 删除系统参数缓存
     *
     * @param schoolId
     * @param key
     */
    @Override
    @CacheEvict(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0 + '-' + #p1")
    public void removeSysConfigCache(Long schoolId, String key) {

    }

    @Override
    @Cacheable(value = SystemConstant.ORG_COLLEGE_LEVEL_CACHE, key = "#p0", unless = "#result == null")
    public List<SysOrg> addOrgCollegeLevelCache(Long schoolId) {
        return sysOrgService.findCollegeLevelOrgList(schoolId);
    }

    @Override
    @CachePut(value = SystemConstant.ORG_COLLEGE_LEVEL_CACHE, key = "#p0", condition = "#result != null")
    public List<SysOrg> updateOrgCollegeLevelCache(Long schoolId) {
        return sysOrgService.findCollegeLevelOrgList(schoolId);
    }

    @Override
    @CacheEvict(value = SystemConstant.ORG_COLLEGE_LEVEL_CACHE, key = "#p0")
    public void removeOrgCollegeLevelCache(Long schoolId) {

    }

    /**
     * 根据学校id查找自定义菜单
     *
     * @param schoolId
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.SCHOOL_PRIVILEGE_CACHE, key = "#p0", unless = "#result == null")
    public List<TSchoolPrivilege> addSchoolPrivilegeCache(Long schoolId) {
        return tSchoolPrivilegeService.findBySchoolId(schoolId);
    }

    /**
     * 根据学校id修改自定义菜单
     *
     * @param schoolId
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.SCHOOL_PRIVILEGE_CACHE, key = "#p0", condition = "#result != null")
    public List<TSchoolPrivilege> updateSchoolPrivilegeCache(Long schoolId) {
        return tSchoolPrivilegeService.findBySchoolId(schoolId);
    }

    /**
     * 根据学校id删除自定义菜单
     *
     * @param schoolId
     */
    @Override
    @CacheEvict(value = SystemConstant.SCHOOL_PRIVILEGE_CACHE, key = "#p0")
    public void removeSchoolPrivilegeCache(Long schoolId) {

    }

    /**
     * 根据学校id查找自定义角色
     *
     * @param schoolId
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.SCHOOL_ROLE_CACHE, key = "#p0", unless = "#result == null")
    public List<TSchoolRole> addSchoolRoleCache(Long schoolId) {
        return tSchoolRoleService.findBySchoolId(schoolId);
    }

    /**
     * 根据学校id修改自定义角色
     *
     * @param schoolId
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.SCHOOL_ROLE_CACHE, key = "#p0", condition = "#result != null")
    public List<TSchoolRole> updateSchoolRoleCache(Long schoolId) {
        return tSchoolRoleService.findBySchoolId(schoolId);
    }

    /**
     * 根据学校id删除自定义角色
     *
     * @param schoolId
     */
    @Override
    @CacheEvict(value = SystemConstant.SCHOOL_ROLE_CACHE, key = "#p0")
    public void removeSchoolRoleCache(Long schoolId) {

    }

    @Override
    @Cacheable(value = SystemConstant.CUSTOM_ROLE_CACHE, unless = "#result == null")
    public List<SysRole> addCustomRoleCache() {
        return sysRoleService.findCustomRole();
    }

    @Override
    @CachePut(value = SystemConstant.CUSTOM_ROLE_CACHE, condition = "#result != null")
    public List<SysRole> updateCustomRoleCache() {
        return sysRoleService.findCustomRole();
    }

    @Override
    @CacheEvict(value = SystemConstant.CUSTOM_ROLE_CACHE)
    public void removeCustomRoleCache() {

    }

    /**
     * 命题任务序号查询
     *
     * @param schoolId   学校ID
     * @param courseCode 课程代码
     */
    @Override
    @Cacheable(value = SystemConstant.EXAM_TASK_SEQUENCE_CACHE, key = "#schoolId+'-'+#courseCode")
    public String addExamTaskSequence(Long schoolId, String courseCode) {
        return "0";
    }

    /**
     * 命题任务序号自增
     *
     * @param schoolId   学校ID
     * @param courseCode 课程代码
     * @return int
     */
    @Override
    @CachePut(value = SystemConstant.EXAM_TASK_SEQUENCE_CACHE, key = "#schoolId+'-'+#courseCode")
    public String updateExamTaskSequence(Long schoolId, String courseCode, String value) {
        return String.valueOf(Integer.valueOf(value) + 1);
    }

    /**
     * 添加机构code
     *
     * @param schoolId
     * @return
     */
    @Override
    @Cacheable(value = SystemConstant.ORG_CODE_CACHE, key = "#p0", unless = "#result == null")
    public Integer getMaxOrgCode(Long schoolId) {
        SysOrg rootOrg = sysOrgService.findRootOrg(schoolId);
        QueryWrapper<SysOrg> orgQueryWrapper = new QueryWrapper<>();
        orgQueryWrapper.lambda().eq(SysOrg::getSchoolId, schoolId)
                .eq(SysOrg::getParentId, rootOrg.getId())
                .like(SysOrg::getCode, SystemConstant.ORG_PREFIX);
        List<SysOrg> sysOrgList = sysOrgService.list(orgQueryWrapper);
        if (sysOrgList.isEmpty()) {
            return 0;
        }
        Integer maxCode = sysOrgList.stream().map(m -> Integer.parseInt(m.getCode().replace(SystemConstant.ORG_PREFIX, "").trim())).max(Comparator.comparingInt(x -> x)).get();
        return maxCode;
    }

    /**
     * 修改机构code
     *
     * @param schoolId
     * @return
     */
    @Override
    @CachePut(value = SystemConstant.ORG_CODE_CACHE, key = "#p0", condition = "#result != null")
    public Integer setMaxOrgCode(Long schoolId, Integer maxCode) {
        return maxCode;
    }

    @Override
    @CacheEvict(value = SystemConstant.ORG_CODE_CACHE, key = "#p0")
    public void removeMaxOrgCode(Long schoolId) {

    }

}
