|
@@ -3,15 +3,18 @@ package com.gis.web.controller;
|
|
|
|
|
|
import com.gis.common.util.PasswordUtils;
|
|
|
import com.gis.common.util.Result;
|
|
|
+import com.gis.domain.dto.UserDto;
|
|
|
import com.gis.domain.po.SysUserEntity;
|
|
|
import com.gis.domain.dto.PasswordRequest;
|
|
|
import com.gis.service.SysUserService;
|
|
|
import com.gis.service.aop.WebControllerLog;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.apache.shiro.authz.annotation.Logical;
|
|
|
import org.apache.shiro.authz.annotation.RequiresRoles;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -49,34 +52,34 @@ public class SysUserController extends BaseController {
|
|
|
// return Result.success(page);
|
|
|
// }
|
|
|
|
|
|
-// @WebControllerLog(description = "用户管理-修改用户")
|
|
|
-// @ApiOperation("新增/修改用户信息")
|
|
|
-// @PostMapping("save")
|
|
|
-// public Result save(@Valid @RequestBody UserDto param) {
|
|
|
-//
|
|
|
-// SysUserEntity entity = null;
|
|
|
-// if (param.getId() == null) {
|
|
|
-// entity = userService.findByUserName(param.getUserName());
|
|
|
-// if (entity != null) {
|
|
|
-// return Result.failure("身份证号已存在");
|
|
|
-// }
|
|
|
-// entity = new SysUserEntity();
|
|
|
-// BeanUtils.copyProperties(param, entity);
|
|
|
-// entity.setPassword(PasswordUtils.encrypt(param.getUserName(), "123456", PasswordUtils.getStaticSalt()));
|
|
|
-// userService.save(entity);
|
|
|
-// } else {
|
|
|
-// entity = userService.findById(param.getId());
|
|
|
-// if (entity == null) {
|
|
|
-// log.error("用户不存在: {}", param.getId());
|
|
|
-// return Result.failure("用户不存在");
|
|
|
-// }
|
|
|
-// BeanUtils.copyProperties(param, entity);
|
|
|
-// entity.setUpdateTime(new Date());
|
|
|
-// userService.update(entity);
|
|
|
-// }
|
|
|
-//
|
|
|
-// return Result.success();
|
|
|
-// }
|
|
|
+ @WebControllerLog(description = "用户管理-修改用户")
|
|
|
+ @ApiOperation("新增/修改用户信息")
|
|
|
+ @PostMapping("save")
|
|
|
+ public Result save(@Valid @RequestBody UserDto param) {
|
|
|
+
|
|
|
+ SysUserEntity entity = null;
|
|
|
+ if (param.getId() == null) {
|
|
|
+ entity = userService.findByUserName(param.getUserName());
|
|
|
+ if (entity != null) {
|
|
|
+ return Result.failure("身份证号已存在");
|
|
|
+ }
|
|
|
+ entity = new SysUserEntity();
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
+ entity.setPassword(PasswordUtils.encrypt(param.getUserName(), "123456", PasswordUtils.getStaticSalt()));
|
|
|
+ userService.save(entity);
|
|
|
+ } else {
|
|
|
+ entity = userService.findById(param.getId());
|
|
|
+ if (entity == null) {
|
|
|
+ log.error("用户不存在: {}", param.getId());
|
|
|
+ return Result.failure("用户不存在");
|
|
|
+ }
|
|
|
+ BeanUtils.copyProperties(param, entity);
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+ userService.update(entity);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@ApiOperation("查询用户信息")
|
|
@@ -91,7 +94,7 @@ public class SysUserController extends BaseController {
|
|
|
return Result.success(user);
|
|
|
}
|
|
|
|
|
|
- @WebControllerLog(description = "用户管理-修改密码")
|
|
|
+ @WebControllerLog(description = "用户管理-修改密码", addDb = true)
|
|
|
@ApiOperation("修改密码")
|
|
|
@PostMapping("updatePwd")
|
|
|
public Result updatePwd(@Valid @RequestBody PasswordRequest param) {
|