[测评系统]--测评系统核心代码库
linzhijie
2021-08-16 7c6ff5de779476a50c26182d9c5075cf7b3a2394
src/main/java/com/ots/project/system/user/service/UserServiceImpl.java
@@ -1,4 +1,5 @@
package com.ots.project.system.user.service;
import com.ots.common.constant.UserConstants;
import com.ots.common.exception.BusinessException;
import com.ots.common.utils.StringUtils;
@@ -22,6 +23,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
@@ -49,6 +51,7 @@
        
        return userMapper.selectUserList(user);
    }
    public List<User> selectUserList2(User user) {
        
        return userMapper.selectUserList(user);
@@ -289,4 +292,37 @@
        }
        return userMapper.updateUser(user);
    }
    @Override
    public int changeHintStatus(String userId, Integer type) {
        // type 0取消授权 1授权
        if(type == 0){
            //查询事中提示语管理员
            Role role = roleMapper.selectByRoleKey("hint_common");
            if(role != null && StringUtils.isNotEmpty(userId)){
                //更新事中提示语状态
                userMapper.updateHintState(userId,type);
                UserRole userRole = new UserRole();
                userRole.setRoleId(role.getRoleId());
                userRole.setUserId(Long.valueOf(userId));
                return userRoleMapper.deleteUserRoleInfo(userRole);
            }
        }else if(type == 1){
            //查询事中提示语管理员
            Role role = roleMapper.selectByRoleKey("hint_common");
            List<UserRole> list = new ArrayList<UserRole>();
            if(role != null && StringUtils.isNotEmpty(userId)){
                //更新事中提示语状态
                userMapper.updateHintState(userId,type);
                UserRole ur = new UserRole();
                ur.setUserId(Long.valueOf(userId));
                ur.setRoleId(role.getRoleId());
                list.add(ur);
                return userRoleMapper.batchUserRole(list);
            }
        }
        return 0;
    }
}