| | |
| | | import com.whyc.service.JobService; |
| | | import com.whyc.service.LoginService; |
| | | import com.whyc.service.UserService; |
| | | import com.whyc.util.DigestsUtil; |
| | | import com.whyc.util.UserExcelVerify; |
| | | import io.swagger.annotations.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.shiro.authz.annotation.Logical; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加用户") |
| | | //@RequiresPermissions(value = {"user:add","user:update"},logical = Logical.OR) |
| | | public Response add(@RequestBody User user){ |
| | | return userService.add(user); |
| | | } |
| | | |
| | | @GetMapping |
| | | @ApiOperation(value = "查询用户byId") |
| | | //@RequiresPermissions(value = {"user:get"}) |
| | | public Response getById(@RequestParam int id){ |
| | | User user = userService.getById(id); |
| | | if (user==null){ |
| | |
| | | |
| | | @GetMapping("/all") |
| | | @ApiOperation(value = "查询所有用户") |
| | | //@RequiresPermissions(value = {"user:get"}) |
| | | public List<User> getAll(){ |
| | | return userService.getAll(); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @ApiOperation(value = "查询用户分页") |
| | | //@RequiresPermissions(value = {"user:get"}) |
| | | public IPage<User> getPage(@RequestParam int pageNum,@RequestParam int pageSize){ |
| | | Page<Object> page = new Page<>(pageNum, pageSize); |
| | | return userService.getAllWithPage(page); |
| | | } |
| | | @GetMapping("/search") |
| | | @PostMapping("/search") |
| | | @ApiOperation(value = "查询用户分页-根据筛选条件") |
| | | //@RequiresPermissions(value = {"user:get"}) |
| | | public Response<IPage<User>> getPageByCondition(@RequestParam int pageNum,@RequestParam int pageSize,@RequestBody User user){ |
| | | return userService.getPageByCondition(pageNum,pageSize,user); |
| | | } |
| | | |
| | | @GetMapping("validatePassword") |
| | | @ApiOperation(value = "验证密码") |
| | | public boolean validatePassword(@RequestParam int id, @RequestParam String password){ |
| | | return userService.validatePassword(id,password); |
| | | } |
| | | @GetMapping("getSaltPassword") |
| | | @ApiOperation(value = "获取加密密码") |
| | | public String getSaltPassword(@RequestParam String password,@RequestParam String salt){ |
| | | return DigestsUtil.sha1(password,salt); |
| | | } |
| | | @PutMapping("updatePassword") |
| | | @ApiOperation(value = "修改密码") |
| | | public Response updatePassword(@RequestParam int id,@RequestParam String password){ |
| | | return userService.updatePassword(id,password); |
| | | } |
| | | |
| | | @PutMapping("resetPassword") |
| | | @ApiOperation(value = "重置密码") |
| | | public Response resetPassword(@RequestParam int id){ |
| | | return userService.resetPassword(id); |
| | | } |
| | | |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "编辑用户") |
| | | //@RequiresPermissions(value = {"user:update"}) |
| | | public Response update(@RequestBody User user){ |
| | | return userService.update(user); |
| | | } |
| | | |
| | | @PutMapping("freezeUser") |
| | | @ApiOperation(value = "冻结用户") |
| | | public Response updateUserFreeze(@RequestParam int id){ |
| | | return userService.updateUserFreeze(id); |
| | | @ApiOperation(value = "启动/冻结用户") |
| | | //@RequiresPermissions(value = {"user:update"}) |
| | | public Response updateUserFreeze(@RequestParam int id,@RequestParam int state){ |
| | | return userService.updateUserFreeze(id,state); |
| | | } |
| | | |
| | | @PutMapping("deleteUser") |
| | | @ApiOperation(value = "删除用户") |
| | | //@RequiresPermissions(value = {"user:delete"}) |
| | | public Response delete(@RequestParam int id){ |
| | | return userService.deleteUser(id); |
| | | return userService.delete(id); |
| | | } |
| | | |
| | | /** |
| | |
| | | public Response addDept(@RequestBody Dept dept){ |
| | | return deptService.add(dept); |
| | | } |
| | | |
| | | @PutMapping("updateDept") |
| | | @ApiOperation(value = "编辑部门") |
| | | public Response update(@RequestBody Dept dept){ |
| | |
| | | } |
| | | |
| | | |
| | | @SuppressWarnings("AlibabaRemoveCommentedCode") |
| | | @PostMapping("/importUserExcel") |
| | | @ApiOperation(value = "导入用户数据") |
| | | public Response importExcel2(@RequestParam("file") MultipartFile file) { |
| | | Response response = new Response(); |
| | | ImportParams importParams = new ImportParams(); |
| | | // 数据处理 |
| | | importParams.setTitleRows(0); //设置标题第1行开始 |
| | | importParams.setHeadRows(1); //设置开始行从第3行开始 |
| | | //设置标题第1行开始 |
| | | importParams.setTitleRows(0); |
| | | //设置开始行从第2行开始 |
| | | importParams.setHeadRows(1); |
| | | // 需要验证 |
| | | importParams.setNeedVerify(true); |
| | | //设及一个自定义校验 (自定义校验名字不可重复) 使用注解注入 |