TbAppUserController.java 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. package com.ruoyi.app.controller;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import java.util.List;
  4. import java.util.Arrays;
  5. import com.ruoyi.app.domain.TbAppUser;
  6. import com.ruoyi.app.service.ITbAppUserService;
  7. import com.ruoyi.common.utils.StringUtils;
  8. import lombok.RequiredArgsConstructor;
  9. import org.springframework.security.access.prepost.PreAuthorize;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.web.bind.annotation.GetMapping;
  12. import org.springframework.web.bind.annotation.PostMapping;
  13. import org.springframework.web.bind.annotation.PutMapping;
  14. import org.springframework.web.bind.annotation.DeleteMapping;
  15. import org.springframework.web.bind.annotation.PathVariable;
  16. import org.springframework.web.bind.annotation.RequestBody;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.bind.annotation.RestController;
  19. import com.ruoyi.common.annotation.Log;
  20. import com.ruoyi.common.core.controller.BaseController;
  21. import com.ruoyi.common.core.domain.AjaxResult;
  22. import com.ruoyi.common.enums.BusinessType;
  23. import com.ruoyi.common.utils.poi.ExcelUtil;
  24. import com.ruoyi.common.core.page.TableDataInfo;
  25. /**
  26. * 会员Controller
  27. *
  28. * @author Alex
  29. * @date 2020-09-24
  30. */
  31. @RequiredArgsConstructor(onConstructor_ = @Autowired)
  32. @RestController
  33. @RequestMapping("/app/user" )
  34. public class TbAppUserController extends BaseController {
  35. private final ITbAppUserService iTbAppUserService;
  36. /**
  37. * 查询会员列表
  38. */
  39. @PreAuthorize("@ss.hasPermi('system:user:list')")
  40. @GetMapping("/list")
  41. public TableDataInfo list(TbAppUser tbAppUser)
  42. {
  43. startPage();
  44. LambdaQueryWrapper<TbAppUser> lqw = new LambdaQueryWrapper<TbAppUser>();
  45. if (tbAppUser.getFamilyId() != null){
  46. lqw.eq(TbAppUser::getFamilyId ,tbAppUser.getFamilyId());
  47. }
  48. if (tbAppUser.getTemplateId() != null){
  49. lqw.eq(TbAppUser::getTemplateId ,tbAppUser.getTemplateId());
  50. }
  51. if (StringUtils.isNotBlank(tbAppUser.getRole())){
  52. lqw.eq(TbAppUser::getRole ,tbAppUser.getRole());
  53. }
  54. if (StringUtils.isNotBlank(tbAppUser.getNickName())){
  55. lqw.like(TbAppUser::getNickName ,tbAppUser.getNickName());
  56. }
  57. if (StringUtils.isNotBlank(tbAppUser.getAvatar())){
  58. lqw.eq(TbAppUser::getAvatar ,tbAppUser.getAvatar());
  59. }
  60. if (StringUtils.isNotBlank(tbAppUser.getQrcode())){
  61. lqw.eq(TbAppUser::getQrcode ,tbAppUser.getQrcode());
  62. }
  63. if (tbAppUser.getMobile() != null){
  64. lqw.eq(TbAppUser::getMobile ,tbAppUser.getMobile());
  65. }
  66. if (StringUtils.isNotBlank(tbAppUser.getOpenid())){
  67. lqw.eq(TbAppUser::getOpenid ,tbAppUser.getOpenid());
  68. }
  69. if (StringUtils.isNotBlank(tbAppUser.getVerCode())){
  70. lqw.eq(TbAppUser::getVerCode ,tbAppUser.getVerCode());
  71. }
  72. List<TbAppUser> list = iTbAppUserService.list(lqw);
  73. return getDataTable(list);
  74. }
  75. /**
  76. * 导出会员列表
  77. */
  78. @PreAuthorize("@ss.hasPermi('system:user:export')" )
  79. @Log(title = "会员" , businessType = BusinessType.EXPORT)
  80. @GetMapping("/export" )
  81. public AjaxResult export(TbAppUser tbAppUser) {
  82. LambdaQueryWrapper<TbAppUser> lqw = new LambdaQueryWrapper<TbAppUser>(tbAppUser);
  83. List<TbAppUser> list = iTbAppUserService.list(lqw);
  84. ExcelUtil<TbAppUser> util = new ExcelUtil<TbAppUser>(TbAppUser. class);
  85. return util.exportExcel(list, "user" );
  86. }
  87. /**
  88. * 获取会员详细信息
  89. */
  90. @PreAuthorize("@ss.hasPermi('system:user:query')" )
  91. @GetMapping(value = "/{id}" )
  92. public AjaxResult getInfo(@PathVariable("id" ) Long id) {
  93. return AjaxResult.success(iTbAppUserService.getById(id));
  94. }
  95. /**
  96. * 新增会员
  97. */
  98. @PreAuthorize("@ss.hasPermi('system:user:add')" )
  99. @Log(title = "会员" , businessType = BusinessType.INSERT)
  100. @PostMapping
  101. public AjaxResult add(@RequestBody TbAppUser tbAppUser) {
  102. return toAjax(iTbAppUserService.save(tbAppUser) ? 1 : 0);
  103. }
  104. /**
  105. * 修改会员
  106. */
  107. @PreAuthorize("@ss.hasPermi('system:user:edit')" )
  108. @Log(title = "会员" , businessType = BusinessType.UPDATE)
  109. @PutMapping
  110. public AjaxResult edit(@RequestBody TbAppUser tbAppUser) {
  111. return toAjax(iTbAppUserService.updateById(tbAppUser) ? 1 : 0);
  112. }
  113. /**
  114. * 删除会员
  115. */
  116. @PreAuthorize("@ss.hasPermi('system:user:remove')" )
  117. @Log(title = "会员" , businessType = BusinessType.DELETE)
  118. @DeleteMapping("/{ids}" )
  119. public AjaxResult remove(@PathVariable Long[] ids) {
  120. return toAjax(iTbAppUserService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
  121. }
  122. }