UserController.java 4.6 KB

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