| | |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.db_user.User; |
| | | import com.whyc.service.UserService; |
| | | import com.whyc.util.CommonUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | @RestController |
| | | @RequestMapping("user") |
| | |
| | | public class UserController extends BaseController{ |
| | | |
| | | @Resource |
| | | private UserService userService; |
| | | private UserService service; |
| | | |
| | | //@PostMapping |
| | | //@ApiOperation(value = "添加") |
| | | //public Response add(@RequestBody UserInf user){ |
| | | // return userService.add(user); |
| | | //} |
| | | |
| | | @PostMapping("add") |
| | | @ApiOperation(value = "添加-RSA加密") |
| | | public Response addByRSA(@RequestBody User user){ |
| | | return userService.addByRSA(user); |
| | | @ApiOperation(value = "查询所有用户信息",notes = "排除uid在100以内的(100以内默认是管理员)") |
| | | @GetMapping("getAllUser") |
| | | public Response getAllUser(@RequestParam(required = false) String uname,@RequestParam int pageCurr, @RequestParam int pageSize){ |
| | | return service.getAllUser(uname,pageCurr,pageSize); |
| | | } |
| | | |
| | | /*@PostMapping("register") |
| | | @ApiOperation(value = "注册用户") |
| | | public Response register(@RequestBody User user){ |
| | | return userService.registerUser(user); |
| | | }*/ |
| | | @GetMapping("getById") |
| | | @ApiOperation(value = "查询byId") |
| | | public Response<User> getById(@RequestParam int id){ |
| | | return new Response<User>().set(1,userService.getById(id)); |
| | | @ApiOperation(value = "查询所有用户信息(不分页除内置用户外用于下拉)") |
| | | @GetMapping("getUinf") |
| | | public Response getUinf(){ |
| | | return service.getUinf(); |
| | | } |
| | | |
| | | /*@GetMapping("all") |
| | | @ApiOperation(value = "查询所有") |
| | | public Response<List<User>> getAll(){ |
| | | return new Response<List<User>>().set(1,userService.getAll()); |
| | | }*/ |
| | | |
| | | @GetMapping("getPage") |
| | | @ApiOperation(value = "查询分页") |
| | | public Response getPage(@RequestParam int pageNum,@RequestParam int pageSize){ |
| | | return new Response().set(1,userService.getPage(pageNum,pageSize)); |
| | | @ApiOperation(value = "新添加用户信息") |
| | | @PostMapping("addUser") |
| | | public Response addUser(@RequestBody User uinf){ |
| | | return service.addUser(uinf); |
| | | } |
| | | @ApiOperation(value = "删除用户信息") |
| | | @GetMapping("deleteUser") |
| | | public Response deleteUser(@RequestParam String uname){ |
| | | return service.delUser(uname); |
| | | } |
| | | |
| | | @PostMapping("update") |
| | | @ApiOperation(value = "编辑") |
| | | public Response update(@RequestBody User user){ |
| | | return userService.update(user); |
| | | @ApiOperation(value = "将用户添加至100~10000管理员") |
| | | @GetMapping("improveRole") |
| | | public Response improveRole(@RequestParam int uid){ |
| | | return service.improveRole(uid); |
| | | } |
| | | |
| | | @ApiOperation(value = "将管理员变成普通用户") |
| | | @GetMapping("dropRole") |
| | | public Response dropRole(@RequestParam int uid, HttpServletRequest request){ |
| | | return service.dropRole(uid,request); |
| | | } |
| | | |
| | | @GetMapping("getUserNameList") |
| | | @ApiOperation(tags = "操作日志",value = "操作人姓名-查询-操作日志使用") |
| | | public Response getUserNameList(){ |
| | | return service.getUserNameList(); |
| | | } |
| | | |
| | | @GetMapping("resetSnId") |
| | | @ApiOperation(value = "重置密码") |
| | | public Response resetSnId(@RequestParam int uid){ |
| | | return service.resetSnId( uid); |
| | | } |
| | | |
| | | |
| | | /*@PostMapping("/checkUserPassword") |
| | | @ApiOperation(value = "检查用户密码") |
| | | public Response checkUserPassword(@RequestParam String password){ |
| | | User user = UserUtil.getUser(); |
| | | //前端传递的密码解密 |
| | | password = RSAUtil.decryptFrontP(password, RSAUtil.fontSeparator)[0]; |
| | | //内存存储的密码解密 |
| | | String userPassword = user.getPwd(); |
| | | userPassword = RSAUtil.decrypt(userPassword,RSAUtil.getPrivateKey()); |
| | | if (password.equals(userPassword)){ |
| | | return new Response().set(1); |
| | | }else { |
| | | return new Response().set(0); |
| | | } |
| | | }*/ |
| | | |
| | | |
| | | @PostMapping("/updatePasswordByRSA") |
| | | @ApiOperation(value = "修改密码-RSA") |
| | | public Response updatePasswordByRSA(@RequestParam String password){ |
| | | User user = CommonUtil.getUser(); |
| | | return userService.updatePasswordByRSA(user,password); |
| | | @ApiOperation(value = "编辑用户信息") |
| | | @PostMapping("updateUinf") |
| | | public Response updateUinf(@RequestBody User uinf){ |
| | | return service.updateUinf(uinf); |
| | | } |
| | | |
| | | |
| | | |
| | | |