IntelligentRecognition/ah-jjsp-service/.svn/pristine/1c/1c97735c5111cab7c5c80720182...

183 lines
6.7 KiB
Plaintext
Raw Normal View History

2024-05-24 16:09:40 +08:00
package com.securityControl.system.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.securityControl.common.core.domain.R;
import com.securityControl.common.core.utils.StringUtils;
import com.securityControl.common.log.annotation.Log;
import com.securityControl.common.log.enums.BusinessType;
import com.securityControl.common.log.enums.OperationType;
import com.securityControl.common.security.annotation.InnerAuth;
import com.securityControl.system.api.domain.SysUser;
import com.securityControl.system.api.model.LoginUser;
import com.securityControl.system.domain.vo.ReturnCodeEntity;
import com.securityControl.system.domain.vo.SysUserEntity;
import com.securityControl.system.service.SysMenuService;
import com.securityControl.system.service.UserManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* 用户管理
*/
@RestController
@RequestMapping(value = "/userManage/")
public class UserManageController {
@Autowired
private UserManageService service;
@Autowired
private SysMenuService sysMenuService;
@PostMapping("getUserList")
@Log(title = "用户管理", menu = "用户管理", businessType = BusinessType.QUERY, details = "用户列表", grade = OperationType.QUERY_SYS, type = "系统日志")
public Map<String, Object> getUserList(SysUserEntity sysUser) {
// String josn = Aes.aesDecrypt(param);
// SysUserEntity sysUser = JSON.parseObject(josn, SysUserEntity.class);//把json字符串转为实体类
PageHelper.startPage(sysUser.getPage(), sysUser.getLimit());
List<SysUserEntity> studentsList = service.getUserList(sysUser);
PageInfo<SysUserEntity> pageInfo = new PageInfo<SysUserEntity>(studentsList);
Map<String, Object> map = new HashMap<String, Object>(16);
map.put("code", 200);
map.put("msg", "数据获取成功");
map.put("count", pageInfo.getTotal());
map.put("data", pageInfo.getList());
map.put("curr", sysUser.getPage());
map.put("limit", sysUser.getLimit());
return map;
}
/**
* 用户管理新增
*
* @param params
* @return
*/
@PostMapping("getUserDetail")
@Log(title = "用户管理", menu = "用户管理", businessType = BusinessType.QUERY, details = "用户详情", grade = OperationType.QUERY_SYS, type = "系统日志")
public SysUserEntity getUserDetail(String params) {
SysUserEntity user = null;
try {
user = service.getUserDetail(params);
return user;
} catch (Exception e) {
// log.error(e.toString(),e);
}
return user;
}
@PostMapping("insertUser")
@Log(title = "用户管理", menu = "用户管理", businessType = BusinessType.INSERT, details = "用户新增", grade = OperationType.ADD_SYS, type = "系统日志")
public ReturnCodeEntity insertUser(SysUserEntity sysUser) {
ReturnCodeEntity entity = new ReturnCodeEntity();
try {
entity = service.insertUser(sysUser);
} catch (Exception e) {
entity.setCode("202");
entity.setMsg("解析异常,请联系管理员");
// log.error(e.toString(),e);
}
return entity;
}
@PostMapping("updateUser")
@Log(title = "用户管理", menu = "用户管理", businessType = BusinessType.UPDATE, details = "修改用户", grade = OperationType.UPDATE_SYS, type = "系统日志")
public ReturnCodeEntity updateUser(SysUserEntity sysUser) {
ReturnCodeEntity entity = new ReturnCodeEntity();
try {
entity = service.updateUser(sysUser);
} catch (Exception e) {
entity.setCode("202");
entity.setMsg("解析异常,请联系管理员");
// log.error(e.toString(),e);
}
return entity;
}
/**
* 删除角色
*
* @param params
* @return
*/
@PostMapping("deleteUser")
@Log(title = "用户管理", menu = "用户管理", businessType = BusinessType.DELETE, details = "删除用户", grade = OperationType.DELETE_SYS, type = "系统日志")
public ReturnCodeEntity deleteUser(String params) {
ReturnCodeEntity entity = new ReturnCodeEntity();
try {
entity = service.deleteUser(params);
} catch (Exception e) {
entity.setCode("202");
entity.setMsg("解析异常,请联系管理员");
// log.error(e.toString(),e);
}
return entity;
}
/**
* 修改密码
*
* @param params
* @return
*/
@PostMapping("updatePwd")
@Log(title = "用户管理", menu = "用户管理", businessType = BusinessType.UPDATE, details = "修改密码", grade = OperationType.UPDATE_SYS, type = "系统日志")
public ReturnCodeEntity updatePwd(SysUserEntity sysUser) {
ReturnCodeEntity entity = new ReturnCodeEntity();
try {
entity = service.updatePwd(sysUser);
} catch (Exception e) {
entity.setCode("202");
entity.setMsg("解析异常,请联系管理员");
// log.error(e.toString(),e);
}
return entity;
}
/**
* 获取当前用户信息
*/
@InnerAuth
@GetMapping("info/{username}")
//@Log(title = "用户管理", menu = "用户管理", businessType = BusinessType.QUERY, details = "查询用户信息", grade = OperationType.QUERY_SYS, type = "系统日志")
public R<LoginUser> info(@PathVariable("username") String username) {
SysUser sysUser = service.selectUserByUserName(username);
if (StringUtils.isNull(sysUser)) {
return R.fail("用户名或密码错误");
}
if (sysUser.getRoleName().contains("管理员")) {
sysUser.setIsSup("1");
} else if (sysUser.getRoleName().contains("督查") || sysUser.getRoleName().contains("专责") ) {
sysUser.setIsSup("2");
} else {
sysUser.setIsSup("3");
}
// 角色集合
Set<String> roles = new HashSet<String>();
roles.add(sysUser.getRoleId().toString());
// 权限集合
Set<String> permissions = sysMenuService.getMenuPermission(sysUser);
LoginUser sysUserVo = new LoginUser();
sysUserVo.setSysUser(sysUser);
sysUserVo.setRoles(roles);
sysUserVo.setPermissions(permissions);
return R.ok(sysUserVo);
}
/**
* 查询用户详情
*
* @param userId
* @return
*/
@PostMapping("getUserById/{userId}")
public R<SysUserEntity> getUserById(@PathVariable("userId") String userId) {
return R.ok(service.getUserDetail(userId));
}
}