package com.stylefeng.guns.modular.system.controller.system;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.baomidou.mybatisplus.plugins.Page;
|
import com.heredata.hos.model.bucket.Bucket;
|
import com.stylefeng.guns.config.properties.GunsProperties;
|
import com.stylefeng.guns.core.base.controller.BaseController;
|
import com.stylefeng.guns.core.base.tips.ErrorTip;
|
import com.stylefeng.guns.core.base.tips.Tip;
|
import com.stylefeng.guns.core.beetl.ShiroExtUtil;
|
import com.stylefeng.guns.core.common.annotion.BussinessLog;
|
import com.stylefeng.guns.core.common.annotion.Permission;
|
import com.stylefeng.guns.core.common.constant.Const;
|
import com.stylefeng.guns.core.common.constant.dictmap.UserDict;
|
import com.stylefeng.guns.core.common.constant.factory.ConstantFactory;
|
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
|
import com.stylefeng.guns.core.common.constant.state.ManagerStatus;
|
import com.stylefeng.guns.core.common.exception.BizExceptionEnum;
|
import com.stylefeng.guns.core.datascope.DataScope;
|
import com.stylefeng.guns.core.db.Db;
|
import com.stylefeng.guns.core.exception.GunsException;
|
import com.stylefeng.guns.core.log.LogObjectHolder;
|
import com.stylefeng.guns.core.shiro.ShiroKit;
|
import com.stylefeng.guns.core.shiro.ShiroUser;
|
import com.stylefeng.guns.core.util.ObsUploadUtil;
|
import com.stylefeng.guns.core.util.SinataUtil;
|
import com.stylefeng.guns.core.util.ToolUtil;
|
import com.stylefeng.guns.modular.system.controller.util.UUIDUtil;
|
import com.stylefeng.guns.modular.system.dao.UserMapper;
|
import com.stylefeng.guns.modular.system.factory.UserFactory;
|
import com.stylefeng.guns.modular.system.model.TAgent;
|
import com.stylefeng.guns.modular.system.model.TBranchOffice;
|
import com.stylefeng.guns.modular.system.model.TCompany;
|
import com.stylefeng.guns.modular.system.model.User;
|
import com.stylefeng.guns.modular.system.service.*;
|
import com.stylefeng.guns.modular.system.transfer.UserDto;
|
import com.stylefeng.guns.modular.system.util.OssUploadUtil;
|
import com.stylefeng.guns.modular.system.util.ResultUtil;
|
import com.stylefeng.guns.modular.system.util.huawei.OBSUtil;
|
import com.stylefeng.guns.modular.system.util.qianyuntong.EmployeeUtil;
|
import com.stylefeng.guns.modular.system.util.qianyuntong.NCOSSUtil;
|
import com.stylefeng.guns.modular.system.util.qianyuntong.QianYunTongConfig;
|
import com.stylefeng.guns.modular.system.util.qianyuntong.UserUtil;
|
import com.stylefeng.guns.modular.system.util.qianyuntong.model.DeleteStafNodeRequest;
|
import com.stylefeng.guns.modular.system.util.qianyuntong.model.QYTUserInfo;
|
import com.stylefeng.guns.modular.system.util.qianyuntong.model.SaveStaffNode;
|
import com.stylefeng.guns.modular.system.util.qianyuntong.model.SaveStaffNodeRequest;
|
import org.apache.poi.ss.formula.functions.T;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.Model;
|
import org.springframework.util.CollectionUtils;
|
import org.springframework.validation.BindingResult;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import javax.naming.NoPermissionException;
|
import javax.servlet.http.HttpServletRequest;
|
import javax.validation.Valid;
|
import java.io.File;
|
import java.io.InputStream;
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
/**
|
* 系统管理员控制器
|
*
|
* @author fengshuonan
|
* @Date 2017年1月11日 下午1:08:17
|
*/
|
@Controller
|
@RequestMapping("/mgr")
|
public class UserMgrController extends BaseController {
|
|
private static String PREFIX = "/system/user/";
|
|
@Autowired
|
private GunsProperties gunsProperties;
|
|
@Autowired
|
private IUserService userService;
|
|
@Autowired
|
private ITDriverService itDriverService;
|
@Autowired
|
private ITAgentService agentService;
|
@Autowired
|
private ITBranchOfficeService branchOfficeService;
|
|
@Autowired
|
private QianYunTongConfig qianYunTongConfig;
|
|
@Autowired
|
private ITCompanyService companyService;
|
|
@Autowired
|
private ShiroExtUtil shiroExtUtil;
|
|
|
/**
|
* 跳转到查看管理员列表的页面
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "user.html";
|
}
|
|
/**
|
* 跳转到查看管理员列表的页面
|
*/
|
@RequestMapping("/user_add")
|
public String addView() {
|
return PREFIX + "user_add.html";
|
}
|
|
/**
|
* 跳转到角色分配页面
|
*/
|
//@RequiresPermissions("/mgr/role_assign") //利用shiro自带的权限检查
|
@Permission
|
@RequestMapping("/role_assign/{userId}")
|
public String roleAssign(@PathVariable Integer userId, Model model) {
|
if (ToolUtil.isEmpty(userId)) {
|
throw new GunsException(BizExceptionEnum.REQUEST_NULL);
|
}
|
User user = (User) Db.create(UserMapper.class).selectOneByCon("id", userId);
|
model.addAttribute("userId", userId);
|
model.addAttribute("userAccount", user.getAccount());
|
return PREFIX + "user_roleassign.html";
|
}
|
|
/**
|
* 跳转到编辑管理员页面
|
*/
|
@Permission
|
@RequestMapping("/user_edit/{userId}")
|
public String userEdit(@PathVariable Integer userId, Model model) {
|
if (ToolUtil.isEmpty(userId)) {
|
throw new GunsException(BizExceptionEnum.REQUEST_NULL);
|
}
|
assertAuth(userId);
|
User user = this.userService.selectById(userId);
|
model.addAttribute(user);
|
model.addAttribute("roleName", ConstantFactory.me().getRoleName(user.getRoleid()));
|
model.addAttribute("deptName", ConstantFactory.me().getDeptName(user.getDeptid()));
|
LogObjectHolder.me().set(user);
|
return PREFIX + "user_edit.html";
|
}
|
|
/**
|
* 跳转到查看用户详情页面
|
*/
|
@RequestMapping("/user_info")
|
public String userInfo(Model model) {
|
Integer userId = shiroExtUtil.getUser().getId();
|
if (ToolUtil.isEmpty(userId)) {
|
throw new GunsException(BizExceptionEnum.REQUEST_NULL);
|
}
|
User user = this.userService.selectById(userId);
|
model.addAttribute(user);
|
model.addAttribute("roleName", ConstantFactory.me().getRoleName(user.getRoleid()));
|
model.addAttribute("deptName", user.getDeptid()==0?"顶级":ConstantFactory.me().getDeptName(user.getDeptid()));
|
LogObjectHolder.me().set(user);
|
return PREFIX + "user_view.html";
|
}
|
|
/**
|
* 跳转到修改密码界面
|
*/
|
@RequestMapping("/user_chpwd")
|
public String chPwd() {
|
return PREFIX + "user_chpwd.html";
|
}
|
|
/**
|
* 修改当前用户的密码
|
*/
|
@RequestMapping("/changePwd")
|
@ResponseBody
|
public Object changePwd(@RequestParam String oldPwd, @RequestParam String newPwd, @RequestParam String rePwd) {
|
if (!newPwd.equals(rePwd)) {
|
throw new GunsException(BizExceptionEnum.TWO_PWD_NOT_MATCH);
|
}
|
Integer userId = shiroExtUtil.getUser().getId();
|
User user = userService.selectById(userId);
|
String oldMd5 = ShiroKit.md5(oldPwd, user.getSalt());
|
if (user.getPassword().equals(oldMd5)) {
|
String newMd5 = ShiroKit.md5(newPwd, user.getSalt());
|
user.setPassword(newMd5);
|
user.setPassWordUpdate(new Date());
|
user.updateById();
|
return SUCCESS_TIP;
|
} else {
|
throw new GunsException(BizExceptionEnum.OLD_PWD_NOT_RIGHT);
|
}
|
}
|
|
/**
|
* 查询管理员列表
|
*/
|
@RequestMapping("/list")
|
@Permission
|
@ResponseBody
|
public Object list(@RequestParam(required = false) String name, @RequestParam(required = false) String createTime, @RequestParam(required = false) Integer deptid) {
|
//创建日期
|
String beginTime = null;
|
String endTime = null;
|
if (SinataUtil.isNotEmpty(createTime)){
|
String[] timeArray = createTime.split(" - ");
|
beginTime = timeArray[0];
|
endTime = timeArray[1];
|
}
|
if (ShiroKit.isAdmin()) {
|
Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
|
page.setRecords(userService.getUserListPage(page,null, name, beginTime, endTime, deptid));
|
return super.packForBT(page);
|
} else {
|
Integer objectId = Objects.requireNonNull(shiroExtUtil.getUser()).getObjectId();
|
Integer roleType = Objects.requireNonNull(shiroExtUtil.getUser()).getRoleType();
|
|
if(roleType == 3){
|
// 查询下级分公司账号
|
TAgent tAgent = agentService.selectById(objectId);
|
List<TBranchOffice> branchOffices = branchOfficeService.selectList(new EntityWrapper<TBranchOffice>()
|
.eq("agentId", tAgent.getId()));
|
|
List<Integer> officeIds = branchOffices.stream().map(TBranchOffice::getId).collect(Collectors.toList());
|
if(CollectionUtils.isEmpty(officeIds)){
|
Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
|
page.setRecords(new ArrayList<>());
|
return super.packForBT(page);
|
}
|
|
// List<User> userList = userService.selectList(new EntityWrapper<User>()
|
// .in("object_id", officeIds));
|
// List<Integer> userIds = userList.stream().map(User::getId).collect(Collectors.toList());
|
|
DataScope dataScope = new DataScope(ShiroKit.getDeptDataScope());
|
Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
|
List<Map<String, Object>> userListPage = userService.getUserListPageAgent(page, null, name, beginTime, endTime, deptid,officeIds);
|
page.setRecords(userListPage);
|
return super.packForBT(page);
|
}else {
|
Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
|
page.setRecords(new ArrayList<>());
|
return super.packForBT(page);
|
}
|
}
|
}
|
|
/**
|
* 添加管理员
|
*/
|
@RequestMapping("/add")
|
@BussinessLog(value = "添加管理员", key = "account", dict = UserDict.class)
|
@ResponseBody
|
public Tip add(@Valid UserDto user, BindingResult result) {
|
if (result.hasErrors()) {
|
throw new GunsException(BizExceptionEnum.REQUEST_NULL);
|
}
|
// 判断账号是否重复
|
User theUser = userService.getByAccount(user.getAccount());
|
if (theUser != null) {
|
throw new GunsException(BizExceptionEnum.USER_ALREADY_REG);
|
}
|
|
ShiroUser user1 = shiroExtUtil.getUser();
|
User user2 = userService.selectById(user1.getId());
|
TCompany tCompany = companyService.selectById(user2.getObjectId());
|
List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(user.getPhone(), tCompany.getEnterCode());
|
Long empId = null;
|
Integer empnew = null;
|
if(null == userInfoByPhone || userInfoByPhone.size() == 0){
|
SaveStaffNodeRequest request1 = new SaveStaffNodeRequest();
|
request1.setMobile(user2.getPhone());
|
request1.setEntercode(tCompany.getEnterCode());
|
request1.setEmpName(user.getName());
|
request1.setEmpNickname(user.getName());
|
request1.setLoginNo(user.getAccount());
|
request1.setEmpSex(user.getSex() == 1 ? "男" : "女");
|
request1.setMphone(user.getPhone());
|
request1.setEmail(user.getPhone() + "@qyt.com");
|
request1.setDeptId(0);
|
request1.setPositionId(1);
|
request1.setSuperLevel(0);
|
request1.setHideMobile(0);
|
ResultUtil<SaveStaffNode> resultUtil = EmployeeUtil.saveStaffNode(request1);
|
if(200 != resultUtil.getStatus()){
|
return new ErrorTip(resultUtil.getStatus(), resultUtil.getMsg());
|
}
|
SaveStaffNode saveStaffNode = resultUtil.getData();
|
empId = saveStaffNode.getEmpId();
|
empnew = 1;
|
}else{
|
empId = userInfoByPhone.get(0).getEmpId();
|
empnew = 0;
|
}
|
|
|
// 完善账号信息
|
user.setSalt(ShiroKit.getRandomSalt(5));
|
user.setPassword(ShiroKit.md5(user.getPassword(), user.getSalt()));
|
user.setStatus(ManagerStatus.OK.getCode());
|
user.setCreatetime(new Date());
|
|
User objectUser = UserFactory.createUser(user);
|
objectUser.setRoleType(user1.getRoleType());
|
objectUser.setObjectId(user1.getObjectId());
|
objectUser.setPassWordUpdate(new Date());
|
objectUser.setEnterId(empId);
|
objectUser.setEmpnew(empnew);
|
objectUser.setEntercode(tCompany.getEnterCode());
|
objectUser.setEnterId(Long.valueOf(tCompany.getEnterCode()));
|
this.userService.insert(objectUser);
|
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改管理员
|
*
|
* @throws NoPermissionException
|
*/
|
@RequestMapping("/edit")
|
@BussinessLog(value = "修改管理员", key = "account", dict = UserDict.class)
|
@ResponseBody
|
public Tip edit(@Valid UserDto user, BindingResult result) throws NoPermissionException {
|
if (result.hasErrors()) {
|
throw new GunsException(BizExceptionEnum.REQUEST_NULL);
|
}
|
|
User oldUser = userService.selectById(user.getId());
|
ShiroUser user1 = shiroExtUtil.getUser();
|
User user2 = userService.selectById(user1.getId());
|
TCompany tCompany = companyService.selectById(user2.getObjectId());
|
//调用中台接口
|
Long empId = null;
|
Integer empnew = null;
|
List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(oldUser.getPhone(), tCompany.getEnterCode());
|
if(null == userInfoByPhone || userInfoByPhone.size() == 0){
|
SaveStaffNodeRequest request1 = new SaveStaffNodeRequest();
|
request1.setMobile(user2.getPhone());
|
request1.setEntercode(tCompany.getEnterCode());
|
request1.setEmpName(user.getName());
|
request1.setEmpNickname(user.getName());
|
request1.setLoginNo(user.getAccount());
|
request1.setEmpSex(user.getSex() == 1 ? "男" : "女");
|
request1.setMphone(user.getPhone());
|
request1.setEmail(user.getPhone() + "@qyt.com");
|
request1.setDeptId(0);
|
request1.setPositionId(1);
|
request1.setSuperLevel(0);
|
request1.setHideMobile(0);
|
ResultUtil<SaveStaffNode> resultUtil = EmployeeUtil.saveStaffNode(request1);
|
if(200 != resultUtil.getStatus()){
|
return new ErrorTip(resultUtil.getStatus(), resultUtil.getMsg());
|
}
|
SaveStaffNode saveStaffNode = resultUtil.getData();
|
empId = saveStaffNode.getEmpId();
|
empnew = 1;
|
}else{
|
empId = userInfoByPhone.get(0).getEmpId();
|
empnew = 0;
|
}
|
oldUser.setEmpId(empId);
|
oldUser.setEntercode(tCompany.getEnterCode());
|
oldUser.setEnterId(Long.valueOf(tCompany.getEnterCode()));
|
oldUser.setEmpnew(empnew);
|
if (ShiroKit.hasRole(Const.ADMIN_NAME)) {
|
this.userService.updateById(UserFactory.editUser(user, oldUser));
|
return SUCCESS_TIP;
|
} else {
|
assertAuth(user.getId());
|
ShiroUser shiroUser = shiroExtUtil.getUser();
|
if (shiroUser.getId().equals(user.getId())) {
|
this.userService.updateById(UserFactory.editUser(user, oldUser));
|
return SUCCESS_TIP;
|
} else {
|
throw new GunsException(BizExceptionEnum.NO_PERMITION);
|
}
|
}
|
}
|
|
/**
|
* 删除管理员(逻辑删除)
|
*/
|
@RequestMapping("/delete")
|
@BussinessLog(value = "删除管理员", key = "userId", dict = UserDict.class)
|
@Permission
|
@ResponseBody
|
public Tip delete(@RequestParam Integer userId) {
|
if (ToolUtil.isEmpty(userId)) {
|
throw new GunsException(BizExceptionEnum.REQUEST_NULL);
|
}
|
//不能删除超级管理员
|
if (userId.equals(Const.ADMIN_ID)) {
|
throw new GunsException(BizExceptionEnum.CANT_DELETE_ADMIN);
|
}
|
User user = userService.selectById(userId);
|
ShiroUser user1 = shiroExtUtil.getUser();
|
User user2 = userService.selectById(user1.getId());
|
TCompany tCompany = companyService.selectById(user2.getObjectId());
|
//调用中台接口
|
if(1 == user.getEmpnew()){
|
List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(user.getPhone(), tCompany.getEnterCode());
|
if (null != userInfoByPhone && 0 < userInfoByPhone.size() && 1 == user.getEmpnew()) {
|
DeleteStafNodeRequest request1 = new DeleteStafNodeRequest();
|
request1.setEmpId(user.getEnterId());
|
request1.setMobile(tCompany.getPrincipalPhone());
|
request1.setEntercode(tCompany.getEnterCode());
|
ResultUtil resultUtil = EmployeeUtil.ecrmDeleteStafNode(request1);
|
if(200 != resultUtil.getStatus()){
|
return new ErrorTip(resultUtil.getStatus(), resultUtil.getMsg());
|
}
|
}
|
}
|
|
assertAuth(userId);
|
this.userService.setStatus(userId, ManagerStatus.DELETED.getCode());
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 查看管理员详情
|
*/
|
@RequestMapping("/view/{userId}")
|
@ResponseBody
|
public User view(@PathVariable Integer userId) {
|
if (ToolUtil.isEmpty(userId)) {
|
throw new GunsException(BizExceptionEnum.REQUEST_NULL);
|
}
|
assertAuth(userId);
|
return this.userService.selectById(userId);
|
}
|
|
/**
|
* 重置管理员的密码
|
*/
|
@RequestMapping("/reset")
|
@BussinessLog(value = "重置管理员密码", key = "userId", dict = UserDict.class)
|
@ResponseBody
|
public Tip reset(@RequestParam Integer userId) {
|
if (ToolUtil.isEmpty(userId)) {
|
throw new GunsException(BizExceptionEnum.REQUEST_NULL);
|
}
|
assertAuth(userId);
|
User user = this.userService.selectById(userId);
|
user.setSalt(ShiroKit.getRandomSalt(5));
|
user.setPassword(ShiroKit.md5(Const.DEFAULT_PWD, user.getSalt()));
|
this.userService.updateById(user);
|
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 冻结用户
|
*/
|
@RequestMapping("/freeze")
|
@BussinessLog(value = "冻结用户", key = "userId", dict = UserDict.class)
|
@ResponseBody
|
public Tip freeze(@RequestParam Integer userId) {
|
if (ToolUtil.isEmpty(userId)) {
|
throw new GunsException(BizExceptionEnum.REQUEST_NULL);
|
}
|
//不能冻结超级管理员
|
if (userId.equals(Const.ADMIN_ID)) {
|
throw new GunsException(BizExceptionEnum.CANT_FREEZE_ADMIN);
|
}
|
assertAuth(userId);
|
this.userService.setStatus(userId, ManagerStatus.FREEZED.getCode());
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 解除冻结用户
|
*/
|
@RequestMapping("/unfreeze")
|
@BussinessLog(value = "解除冻结用户", key = "userId", dict = UserDict.class)
|
@ResponseBody
|
public Tip unfreeze(@RequestParam Integer userId) {
|
if (ToolUtil.isEmpty(userId)) {
|
throw new GunsException(BizExceptionEnum.REQUEST_NULL);
|
}
|
assertAuth(userId);
|
this.userService.setStatus(userId, ManagerStatus.OK.getCode());
|
|
User user = userService.selectById(userId);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 分配角色
|
*/
|
@RequestMapping("/setRole")
|
@BussinessLog(value = "分配角色", key = "userId,roleIds", dict = UserDict.class)
|
@ResponseBody
|
public Tip setRole(@RequestParam("userId") Integer userId, @RequestParam("roleIds") String roleIds) {
|
if (ToolUtil.isOneEmpty(userId, roleIds)) {
|
throw new GunsException(BizExceptionEnum.REQUEST_NULL);
|
}
|
//不能修改超级管理员
|
if (userId.equals(Const.ADMIN_ID)) {
|
throw new GunsException(BizExceptionEnum.CANT_CHANGE_ADMIN);
|
}
|
assertAuth(userId);
|
this.userService.setRoles(userId, roleIds);
|
|
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 上传图片
|
*/
|
@RequestMapping(method = RequestMethod.POST, path = "/upload")
|
@ResponseBody
|
public String upload(@RequestPart("file") MultipartFile picture) {
|
|
String pictureName = UUID.randomUUID().toString() + "." + ToolUtil.getFileSuffix(picture.getOriginalFilename());
|
try {
|
String fileSavePath = gunsProperties.getFileUploadPath();
|
picture.transferTo(new File(fileSavePath + pictureName));
|
} catch (Exception e) {
|
throw new GunsException(BizExceptionEnum.UPLOAD_ERROR);
|
}
|
return pictureName;
|
}
|
|
@ResponseBody
|
@RequestMapping("/saveApk")
|
public String saveApk(@RequestPart("myfile") MultipartFile file, HttpServletRequest request){
|
Map<String, Object> m = new HashMap<>();
|
QianYunTongConfig qianYunTongConfig1 = qianYunTongConfig.getQianYunTongConfig();
|
try {
|
String pictureName = UUID.randomUUID().toString() + "." + ToolUtil.getFileSuffix(file.getOriginalFilename());
|
String bucketName = qianYunTongConfig1.getBucketName();
|
Bucket grjyTest = NCOSSUtil.getBucketInfo(bucketName);
|
if (null == grjyTest) {
|
//创建桶
|
Boolean bucket = NCOSSUtil.createBucket(bucketName);
|
if (!bucket) {
|
throw new RuntimeException("创建存储桶失败");
|
}
|
//设置桶策略
|
String policyText = "{\"Version\":\"2025-06-23\",\"Statement\":[{\"Sid\":\"Stmt20250623\",\"Action\":[\"GetObject\"],\"Effect\":\"Allow\",\"Resource\":\"" + bucketName + "/*\",\"Principal\":\"*\"}]}";
|
Boolean bucketPolicy = NCOSSUtil.setBucketPolicy(bucketName, policyText);
|
if (!bucketPolicy) {
|
throw new RuntimeException("设置桶策略失败");
|
}
|
}
|
//上传对象
|
String key = "apk/" + pictureName;
|
String object = NCOSSUtil.putObject(bucketName, key, file.getInputStream());
|
if (null == object) {
|
throw new RuntimeException("上传图片失败");
|
}
|
m.put("imgUrl", "https://traffic.qytzt.cn/v1/AUTH_" + qianYunTongConfig1.getAccount() + "/" + bucketName + "/" + key);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return null;
|
}
|
|
|
/**
|
* 判断当前登录的用户是否有操作这个用户的权限
|
*/
|
private void assertAuth(Integer userId) {
|
if (ShiroKit.isAdmin()) {
|
return;
|
}
|
List<Integer> deptDataScope = ShiroKit.getDeptDataScope();
|
User user = this.userService.selectById(userId);
|
Integer deptid = user.getDeptid();
|
if (deptDataScope.contains(deptid)) {
|
return;
|
} else {
|
throw new GunsException(BizExceptionEnum.NO_PERMITION);
|
}
|
|
}
|
}
|