作者 朱兆平

将修改用户密码单独拿出来

package com.tianbo.warehouse.controller;
import com.tianbo.warehouse.annotation.LogAnnotation;
import com.tianbo.warehouse.annotation.UserPasswordMd5;
import com.tianbo.warehouse.controller.response.ResultJson;
import com.tianbo.warehouse.model.USERS;
import com.tianbo.warehouse.service.UserService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.context.SecurityContextImpl;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/admin")
public class AdminController {
@Autowired
UserService userService;
@GetMapping("/admin")
@GetMapping("/")
public String admin(){
return "admin";
}
@ApiOperation(value = "修改用户密码", notes = "超级管理修改其他用户密码")
@LogAnnotation(moduleName = "admin管理",operate = "用户密码修改")
@ApiImplicitParams({@ApiImplicitParam(name = "USERS", value = "用户账号密码", required = true, dataType = "USERS")})
@UserPasswordMd5
@PutMapping("/password")
public ResultJson updateUserPassById(@RequestBody USERS user){
int i = userService.updateByPrimaryKeySelective(user);
return i==1 ? new ResultJson("200","success") :new ResultJson("500","update password faild");
}
}
... ...
... ... @@ -56,7 +56,6 @@ public class UserController {
}
@LogAnnotation(moduleName = "用户管理",operate = "用户编辑")
@UserPasswordMd5
@PutMapping("/edit")
public ResultJson updateUserById(@RequestBody @Valid USERS user){
int i = userService.updateByPrimaryKeySelective(user);
... ... @@ -65,6 +64,14 @@ public class UserController {
}
@LogAnnotation(moduleName = "用户管理",operate = "用户密码修改")
@UserPasswordMd5
@PutMapping("/password")
public ResultJson updateUserPassById(@RequestBody USERS user){
int i = userService.updateByPrimaryKeySelective(user);
return i==1 ? new ResultJson("200","success") :new ResultJson("500","update faild");
}
@UserPasswordMd5
@LogAnnotation(moduleName = "用户管理",operate = "用户添加")
@PostMapping("/add")
... ...