UserController.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. package com.zhongzheng.controller.user;
  2. import java.util.List;
  3. import java.util.Arrays;
  4. import com.zhongzheng.modules.user.bo.UserAddBo;
  5. import com.zhongzheng.modules.user.bo.UserEditBo;
  6. import com.zhongzheng.modules.user.bo.UserQueryBo;
  7. import com.zhongzheng.modules.user.service.IUserService;
  8. import com.zhongzheng.modules.user.vo.UserStudyRecordVo;
  9. import com.zhongzheng.modules.user.vo.UserVo;
  10. import lombok.RequiredArgsConstructor;
  11. import org.springframework.security.access.prepost.PreAuthorize;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.web.bind.annotation.GetMapping;
  14. import org.springframework.web.bind.annotation.PostMapping;
  15. import org.springframework.web.bind.annotation.PutMapping;
  16. import org.springframework.web.bind.annotation.DeleteMapping;
  17. import org.springframework.web.bind.annotation.PathVariable;
  18. import org.springframework.web.bind.annotation.RequestBody;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RestController;
  21. import com.zhongzheng.common.annotation.Log;
  22. import com.zhongzheng.common.core.controller.BaseController;
  23. import com.zhongzheng.common.core.domain.AjaxResult;
  24. import com.zhongzheng.common.enums.BusinessType;
  25. import com.zhongzheng.common.utils.poi.ExcelUtil;
  26. import com.zhongzheng.common.core.page.TableDataInfo;
  27. import io.swagger.annotations.Api;
  28. import io.swagger.annotations.ApiOperation;
  29. /**
  30. * 客户端用户Controller
  31. *
  32. * @author ruoyi
  33. * @date 2021-06-08
  34. */
  35. @Api(value = "客户端用户控制器", tags = {"客户端用户管理"})
  36. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  37. @RestController
  38. @RequestMapping("/app/user")
  39. public class UserController extends BaseController {
  40. private final IUserService iUserService;
  41. /**
  42. * 查询客户端用户列表
  43. */
  44. @ApiOperation("查询客户端用户列表")
  45. @PreAuthorize("@ss.hasPermi('app:user:list')")
  46. @GetMapping("/list")
  47. public TableDataInfo<UserVo> list(UserQueryBo bo) {
  48. startPage();
  49. List<UserVo> list = iUserService.selectList(bo);
  50. return getDataTable(list);
  51. }
  52. /**
  53. * 导出客户端用户列表
  54. */
  55. @ApiOperation("导出客户端用户列表")
  56. @PreAuthorize("@ss.hasPermi('app:user:export')")
  57. @Log(title = "客户端用户", businessType = BusinessType.EXPORT)
  58. @GetMapping("/export")
  59. public AjaxResult<UserVo> export(UserQueryBo bo) {
  60. List<UserVo> list = iUserService.queryList(bo);
  61. ExcelUtil<UserVo> util = new ExcelUtil<UserVo>(UserVo.class);
  62. return util.exportExcel(list, "客户端用户");
  63. }
  64. /**
  65. * 获取客户端用户详细信息
  66. */
  67. @ApiOperation("获取客户端用户详细信息")
  68. @PreAuthorize("@ss.hasPermi('app:user:query')")
  69. @GetMapping("/{userId}")
  70. public AjaxResult<UserVo> getInfo(@PathVariable("userId" ) Long userId) {
  71. return AjaxResult.success(iUserService.queryById(userId));
  72. }
  73. /**
  74. * 新增客户端用户
  75. */
  76. @ApiOperation("新增客户端用户")
  77. @PreAuthorize("@ss.hasPermi('app:user:add')")
  78. @Log(title = "客户端用户", businessType = BusinessType.INSERT)
  79. @PostMapping()
  80. public AjaxResult<Void> add(@RequestBody UserAddBo bo) {
  81. return toAjax(iUserService.insertByAddBo(bo) ? 1 : 0);
  82. }
  83. /**
  84. * 修改客户端用户
  85. */
  86. @ApiOperation("修改客户端用户")
  87. @PreAuthorize("@ss.hasPermi('app:user:edit')")
  88. @Log(title = "客户端用户", businessType = BusinessType.UPDATE)
  89. @PostMapping("/edit")
  90. public AjaxResult<Void> edit(@RequestBody UserEditBo bo) throws IllegalAccessException {
  91. return toAjax(iUserService.updateByEditBo(bo) ? 1 : 0);
  92. }
  93. /**
  94. * 删除客户端用户
  95. */
  96. @ApiOperation("删除客户端用户")
  97. @PreAuthorize("@ss.hasPermi('app:user:remove')")
  98. @Log(title = "客户端用户" , businessType = BusinessType.DELETE)
  99. @PostMapping("/delete")
  100. public AjaxResult<Void> remove(@PathVariable Long[] userIds) {
  101. return toAjax(iUserService.deleteWithValidByIds(Arrays.asList(userIds), true) ? 1 : 0);
  102. }
  103. /**
  104. * 查询客户端用户学习记录列表
  105. */
  106. @ApiOperation("客户端用户学习记录列表")
  107. @PreAuthorize("@ss.hasPermi('app:user:studyRecordList')")
  108. @GetMapping("/studyRecordList")
  109. public TableDataInfo<UserStudyRecordVo> studyRecordList(UserQueryBo bo) {
  110. startPage();
  111. List<UserStudyRecordVo> list = iUserService.selectStudyRecordList(bo);
  112. return getDataTable(list);
  113. }
  114. }