123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- package com.ruoyi.app.controller;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import java.util.List;
- import java.util.Arrays;
- import com.ruoyi.app.domain.TbAppUser;
- import com.ruoyi.app.service.ITbAppUserService;
- import com.ruoyi.common.utils.StringUtils;
- import lombok.RequiredArgsConstructor;
- import org.springframework.security.access.prepost.PreAuthorize;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PostMapping;
- import org.springframework.web.bind.annotation.PutMapping;
- import org.springframework.web.bind.annotation.DeleteMapping;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import com.ruoyi.common.annotation.Log;
- import com.ruoyi.common.core.controller.BaseController;
- import com.ruoyi.common.core.domain.AjaxResult;
- import com.ruoyi.common.enums.BusinessType;
- import com.ruoyi.common.utils.poi.ExcelUtil;
- import com.ruoyi.common.core.page.TableDataInfo;
- /**
- * 会员Controller
- *
- * @author Alex
- * @date 2020-09-24
- */
- @RequiredArgsConstructor(onConstructor_ = @Autowired)
- @RestController
- @RequestMapping("/app/user" )
- public class TbAppUserController extends BaseController {
- private final ITbAppUserService iTbAppUserService;
- /**
- * 查询会员列表
- */
- @PreAuthorize("@ss.hasPermi('system:user:list')")
- @GetMapping("/list")
- public TableDataInfo list(TbAppUser tbAppUser)
- {
- startPage();
- LambdaQueryWrapper<TbAppUser> lqw = new LambdaQueryWrapper<TbAppUser>();
- if (tbAppUser.getFamilyId() != null){
- lqw.eq(TbAppUser::getFamilyId ,tbAppUser.getFamilyId());
- }
- if (tbAppUser.getTemplateId() != null){
- lqw.eq(TbAppUser::getTemplateId ,tbAppUser.getTemplateId());
- }
- if (StringUtils.isNotBlank(tbAppUser.getRole())){
- lqw.eq(TbAppUser::getRole ,tbAppUser.getRole());
- }
- if (StringUtils.isNotBlank(tbAppUser.getNickName())){
- lqw.like(TbAppUser::getNickName ,tbAppUser.getNickName());
- }
- if (StringUtils.isNotBlank(tbAppUser.getAvatar())){
- lqw.eq(TbAppUser::getAvatar ,tbAppUser.getAvatar());
- }
- if (StringUtils.isNotBlank(tbAppUser.getQrcode())){
- lqw.eq(TbAppUser::getQrcode ,tbAppUser.getQrcode());
- }
- if (tbAppUser.getMobile() != null){
- lqw.eq(TbAppUser::getMobile ,tbAppUser.getMobile());
- }
- if (StringUtils.isNotBlank(tbAppUser.getOpenid())){
- lqw.eq(TbAppUser::getOpenid ,tbAppUser.getOpenid());
- }
- if (StringUtils.isNotBlank(tbAppUser.getVerCode())){
- lqw.eq(TbAppUser::getVerCode ,tbAppUser.getVerCode());
- }
- List<TbAppUser> list = iTbAppUserService.list(lqw);
- return getDataTable(list);
- }
- /**
- * 导出会员列表
- */
- @PreAuthorize("@ss.hasPermi('system:user:export')" )
- @Log(title = "会员" , businessType = BusinessType.EXPORT)
- @GetMapping("/export" )
- public AjaxResult export(TbAppUser tbAppUser) {
- LambdaQueryWrapper<TbAppUser> lqw = new LambdaQueryWrapper<TbAppUser>(tbAppUser);
- List<TbAppUser> list = iTbAppUserService.list(lqw);
- ExcelUtil<TbAppUser> util = new ExcelUtil<TbAppUser>(TbAppUser. class);
- return util.exportExcel(list, "user" );
- }
- /**
- * 获取会员详细信息
- */
- @PreAuthorize("@ss.hasPermi('system:user:query')" )
- @GetMapping(value = "/{id}" )
- public AjaxResult getInfo(@PathVariable("id" ) Long id) {
- return AjaxResult.success(iTbAppUserService.getById(id));
- }
- /**
- * 新增会员
- */
- @PreAuthorize("@ss.hasPermi('system:user:add')" )
- @Log(title = "会员" , businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody TbAppUser tbAppUser) {
- return toAjax(iTbAppUserService.save(tbAppUser) ? 1 : 0);
- }
- /**
- * 修改会员
- */
- @PreAuthorize("@ss.hasPermi('system:user:edit')" )
- @Log(title = "会员" , businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody TbAppUser tbAppUser) {
- return toAjax(iTbAppUserService.updateById(tbAppUser) ? 1 : 0);
- }
- /**
- * 删除会员
- */
- @PreAuthorize("@ss.hasPermi('system:user:remove')" )
- @Log(title = "会员" , businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}" )
- public AjaxResult remove(@PathVariable Long[] ids) {
- return toAjax(iTbAppUserService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
- }
- }
|