Browse Source

feat(business): 添加用户管理功能

- 新增用户管理相关的实体类、Mapper、Service、Controller等
- 实现用户信息的增删查改功能
- 添加用户信息的导出功能
-集成MyBatis Plus和Excel导出工具
fugui001 6 tháng trước cách đây
mục cha
commit
40d8b18060

+ 105 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/controller/UserController.java

@@ -0,0 +1,105 @@
+package org.dromara.business.controller;
+
+import java.util.List;
+
+import lombok.RequiredArgsConstructor;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.validation.constraints.*;
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.dromara.business.domain.bo.UserBo;
+import org.dromara.business.domain.vo.UserVo;
+import org.dromara.business.service.IUserService;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.validation.annotation.Validated;
+import org.dromara.common.idempotent.annotation.RepeatSubmit;
+import org.dromara.common.log.annotation.Log;
+import org.dromara.common.web.core.BaseController;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.common.core.domain.R;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.core.validate.EditGroup;
+import org.dromara.common.log.enums.BusinessType;
+import org.dromara.common.excel.utils.ExcelUtil;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+
+/**
+ * 【api用户管理】
+ *
+ * @author Lion Li
+ * @date 2025-06-26
+ */
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/business/user")
+public class UserController extends BaseController {
+
+    private final IUserService userService;
+
+    /**
+     * 查询【api用户管理】列表
+     */
+    @SaCheckPermission("business:user:list")
+    @GetMapping("/list")
+    public TableDataInfo<UserVo> list(UserBo bo, PageQuery pageQuery) {
+        return userService.queryPageList(bo, pageQuery);
+    }
+
+    /**
+     * 导出【api用户管理】列表
+     */
+    @SaCheckPermission("business:user:export")
+    @Log(title = "【导出用户管理】", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(UserBo bo, HttpServletResponse response) {
+        List<UserVo> list = userService.queryList(bo);
+        ExcelUtil.exportExcel(list, "【请填写功能名称】", UserVo.class, response);
+    }
+
+    /**
+     * 获取【api用户管理】详细信息
+     *
+     * @param id 主键
+     */
+    @SaCheckPermission("business:user:query")
+    @GetMapping("/{id}")
+    public R<UserVo> getInfo(@NotNull(message = "主键不能为空")
+                                     @PathVariable Long id) {
+        return R.ok(userService.queryById(id));
+    }
+
+    /**
+     * 新增【api用户管理】
+     */
+    @SaCheckPermission("business:user:add")
+    @Log(title = "【新增用户管理】", businessType = BusinessType.INSERT)
+    @RepeatSubmit()
+    @PostMapping()
+    public R<Void> add(@Validated(AddGroup.class) @RequestBody UserBo bo) {
+        return toAjax(userService.insertByBo(bo));
+    }
+
+    /**
+     * 修改【api用户管理】
+     */
+    @SaCheckPermission("business:user:edit")
+    @Log(title = "【修改用户管理】", businessType = BusinessType.UPDATE)
+    @RepeatSubmit()
+    @PutMapping()
+    public R<Void> edit(@Validated(EditGroup.class) @RequestBody UserBo bo) {
+        return toAjax(userService.updateByBo(bo));
+    }
+
+    /**
+     * 删除【api用户管理】
+     *
+     * @param ids 主键串
+     */
+    @SaCheckPermission("business:user:remove")
+    @Log(title = "【删除用户管理】", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public R<Void> remove(@NotEmpty(message = "主键不能为空")
+                          @PathVariable Long[] ids) {
+        return toAjax(userService.deleteWithValidByIds(List.of(ids), true));
+    }
+}

+ 143 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/User.java

@@ -0,0 +1,143 @@
+package org.dromara.business.domain;
+
+import org.dromara.common.mybatis.core.domain.BaseEntity;
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import java.util.Date;
+
+import java.io.Serial;
+
+/**
+ * 【请填写功能名称】对象 user
+ *
+ * @author Lion Li
+ * @date 2025-06-26
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@TableName("user")
+public class User extends BaseEntity {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     *
+     */
+    @TableId(value = "id")
+    private Long id;
+
+    /**
+     * 登录名称
+     */
+    private String loginName;
+
+    /**
+     * 登录密码
+     */
+    private String loginPass;
+
+    /**
+     * 手机号
+     */
+    private String phone;
+
+    /**
+     * 创建时间
+     */
+    private Date createAt;
+
+    /**
+     * 更新时间
+     */
+    private Date updateAt;
+
+    /**
+     * 性别
+     */
+    private Long sex;
+
+    /**
+     * 邮箱
+     */
+    private String email;
+
+    /**
+     * 昵称
+     */
+    private String nickName;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 验证码
+     */
+    private String captcha;
+
+    /**
+     * 头像
+     */
+    private String avatar;
+
+    /**
+     * 省份
+     */
+    private String province;
+
+    /**
+     * 市
+     */
+    private String city;
+
+    /**
+     * 区/县
+     */
+    private String area;
+
+    /**
+     * 详细地址
+     */
+    private String placeDetail;
+
+    /**
+     * 注册ip
+     */
+    private String registerIp;
+
+    /**
+     * 注册设备信息
+     */
+    private String registerDevice;
+
+    /**
+     * 0:禁用, 1:启用
+     */
+    private Long status;
+
+    /**
+     *  0 锁定 1 未锁定
+     */
+    private Long isLocked;
+
+    /**
+     * 上一次登录时间
+     */
+    private Date lastLoginTime;
+
+    /**
+     * 上一次登录ip
+     */
+    private String lastLoginIp;
+
+    /**
+     * 0 未删除 1已删除
+     */
+    @TableLogic
+    private Long delFlag;
+
+
+}

+ 138 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/bo/UserBo.java

@@ -0,0 +1,138 @@
+package org.dromara.business.domain.bo;
+
+import org.dromara.business.domain.User;
+import org.dromara.common.mybatis.core.domain.BaseEntity;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.core.validate.EditGroup;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import jakarta.validation.constraints.*;
+import java.util.Date;
+
+/**
+ * 【请填写功能名称】业务对象 user
+ *
+ * @author Lion Li
+ * @date 2025-06-26
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@AutoMapper(target = User.class, reverseConvertGenerate = false)
+public class UserBo extends BaseEntity {
+
+    /**
+     *
+     */
+    @NotNull(message = "不能为空", groups = { EditGroup.class })
+    private Long id;
+
+    /**
+     * 登录名称
+     */
+    @NotBlank(message = "登录名称不能为空", groups = { AddGroup.class, EditGroup.class })
+    private String loginName;
+
+    /**
+     * 登录密码
+     */
+    @NotBlank(message = "登录密码不能为空", groups = { AddGroup.class, EditGroup.class })
+    private String loginPass;
+
+    /**
+     * 手机号
+     */
+    private String phone;
+
+    /**
+     * 创建时间
+     */
+    private Date createAt;
+
+    /**
+     * 更新时间
+     */
+    private Date updateAt;
+
+    /**
+     * 性别
+     */
+    private Long sex;
+
+    /**
+     * 邮箱
+     */
+    private String email;
+
+    /**
+     * 昵称
+     */
+    private String nickName;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 验证码
+     */
+    private String captcha;
+
+    /**
+     * 头像
+     */
+    private String avatar;
+
+    /**
+     * 省份
+     */
+    private String province;
+
+    /**
+     * 市
+     */
+    private String city;
+
+    /**
+     * 区/县
+     */
+    private String area;
+
+    /**
+     * 详细地址
+     */
+    private String placeDetail;
+
+    /**
+     * 注册ip
+     */
+    private String registerIp;
+
+    /**
+     * 注册设备信息
+     */
+    private String registerDevice;
+
+    /**
+     * 0:禁用, 1:启用
+     */
+    private Long status;
+
+    /**
+     *  0 锁定 1 未锁定
+     */
+    private Long isLocked;
+
+    /**
+     * 上一次登录时间
+     */
+    private Date lastLoginTime;
+
+    /**
+     * 上一次登录ip
+     */
+    private String lastLoginIp;
+
+
+}

+ 162 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/vo/UserVo.java

@@ -0,0 +1,162 @@
+package org.dromara.business.domain.vo;
+
+import java.util.Date;
+
+import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
+import cn.idev.excel.annotation.ExcelProperty;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+import org.dromara.business.domain.User;
+import java.io.Serial;
+import java.io.Serializable;
+
+
+
+/**
+ * 【请填写功能名称】视图对象 user
+ *
+ * @author Lion Li
+ * @date 2025-06-26
+ */
+@Data
+@ExcelIgnoreUnannotated
+@AutoMapper(target = User.class)
+public class UserVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     *
+     */
+    @ExcelProperty(value = "")
+    private Long id;
+
+    /**
+     * 登录名称
+     */
+    @ExcelProperty(value = "登录名称")
+    private String loginName;
+
+    /**
+     * 登录密码
+     */
+    @ExcelProperty(value = "登录密码")
+    private String loginPass;
+
+    /**
+     * 手机号
+     */
+    @ExcelProperty(value = "手机号")
+    private String phone;
+
+    /**
+     * 创建时间
+     */
+    @ExcelProperty(value = "创建时间")
+    private Date createAt;
+
+    /**
+     * 更新时间
+     */
+    @ExcelProperty(value = "更新时间")
+    private Date updateAt;
+
+    /**
+     * 性别
+     */
+    @ExcelProperty(value = "性别")
+    private Long sex;
+
+    /**
+     * 邮箱
+     */
+    @ExcelProperty(value = "邮箱")
+    private String email;
+
+    /**
+     * 昵称
+     */
+    @ExcelProperty(value = "昵称")
+    private String nickName;
+
+    /**
+     * 备注
+     */
+    @ExcelProperty(value = "备注")
+    private String remark;
+
+    /**
+     * 验证码
+     */
+    @ExcelProperty(value = "验证码")
+    private String captcha;
+
+    /**
+     * 头像
+     */
+    @ExcelProperty(value = "头像")
+    private String avatar;
+
+    /**
+     * 省份
+     */
+    @ExcelProperty(value = "省份")
+    private String province;
+
+    /**
+     * 市
+     */
+    @ExcelProperty(value = "市")
+    private String city;
+
+    /**
+     * 区/县
+     */
+    @ExcelProperty(value = "区/县")
+    private String area;
+
+    /**
+     * 详细地址
+     */
+    @ExcelProperty(value = "详细地址")
+    private String placeDetail;
+
+    /**
+     * 注册ip
+     */
+    @ExcelProperty(value = "注册ip")
+    private String registerIp;
+
+    /**
+     * 注册设备信息
+     */
+    @ExcelProperty(value = "注册设备信息")
+    private String registerDevice;
+
+    /**
+     * 0:禁用, 1:启用
+     */
+    @ExcelProperty(value = "0:禁用, 1:启用")
+    private Long status;
+
+    /**
+     *  0 锁定 1 未锁定
+     */
+    @ExcelProperty(value = " 0 锁定 1 未锁定")
+    private Long isLocked;
+
+    /**
+     * 上一次登录时间
+     */
+    @ExcelProperty(value = "上一次登录时间")
+    private Date lastLoginTime;
+
+    /**
+     * 上一次登录ip
+     */
+    @ExcelProperty(value = "上一次登录ip")
+    private String lastLoginIp;
+
+
+}

+ 44 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/mapper/UserMapper.java

@@ -0,0 +1,44 @@
+package org.dromara.business.mapper;
+
+import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import org.dromara.business.domain.User;
+import org.dromara.business.domain.vo.UserVo;
+import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 【请填写功能名称】Mapper接口
+ *
+ * @author Lion Li
+ * @date 2025-06-26
+ */
+@DS("mysql2")
+public interface UserMapper extends BaseMapperPlus<User, UserVo> {
+
+
+    @InterceptorIgnore(tenantLine = "true")
+    Page<UserVo> selectVoPage(@Param("page") Page<User> page, @Param("ew") Wrapper<User> wrapper);
+
+    @InterceptorIgnore(tenantLine = "true")
+    UserVo selectVoByIdInfo(Long id);
+
+    @InterceptorIgnore(tenantLine = "true")
+    int updateUserById(User update);
+
+    @InterceptorIgnore(tenantLine = "true")
+    int insertUser(User insert);
+
+    @InterceptorIgnore(tenantLine = "true")
+    int deleteByUserById(@Param("ids") Collection<Long> ids);
+
+    @InterceptorIgnore(tenantLine = "true")
+    List<UserVo> selectUserList(@Param("ew") Wrapper<User> wrapper);
+
+
+}

+ 68 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/IUserService.java

@@ -0,0 +1,68 @@
+package org.dromara.business.service;
+
+import org.dromara.business.domain.bo.UserBo;
+import org.dromara.business.domain.vo.UserVo;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.mybatis.core.page.PageQuery;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 【请填写功能名称】Service接口
+ *
+ * @author Lion Li
+ * @date 2025-06-26
+ */
+public interface IUserService {
+
+    /**
+     * 查询【请填写功能名称】
+     *
+     * @param id 主键
+     * @return 【请填写功能名称】
+     */
+    UserVo queryById(Long id);
+
+    /**
+     * 分页查询【请填写功能名称】列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 【请填写功能名称】分页列表
+     */
+    TableDataInfo<UserVo> queryPageList(UserBo bo, PageQuery pageQuery);
+
+    /**
+     * 查询符合条件的【请填写功能名称】列表
+     *
+     * @param bo 查询条件
+     * @return 【请填写功能名称】列表
+     */
+    List<UserVo> queryList(UserBo bo);
+
+    /**
+     * 新增【请填写功能名称】
+     *
+     * @param bo 【请填写功能名称】
+     * @return 是否新增成功
+     */
+    Boolean insertByBo(UserBo bo);
+
+    /**
+     * 修改【请填写功能名称】
+     *
+     * @param bo 【请填写功能名称】
+     * @return 是否修改成功
+     */
+    Boolean updateByBo(UserBo bo);
+
+    /**
+     * 校验并批量删除【请填写功能名称】信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+}

+ 152 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/UserServiceImpl.java

@@ -0,0 +1,152 @@
+package org.dromara.business.service.impl;
+
+import org.dromara.business.domain.User;
+import org.dromara.business.domain.bo.UserBo;
+import org.dromara.business.domain.vo.UserVo;
+import org.dromara.business.mapper.UserMapper;
+import org.dromara.business.service.IUserService;
+import org.dromara.common.core.utils.MapstructUtils;
+import org.dromara.common.core.utils.StringUtils;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+
+import java.util.List;
+import java.util.Map;
+import java.util.Collection;
+
+/**
+ * 【请填写功能名称】Service业务层处理
+ *
+ * @author Lion Li
+ * @date 2025-06-26
+ */
+@Slf4j
+@RequiredArgsConstructor
+@Service
+public class UserServiceImpl implements IUserService {
+
+    private final UserMapper baseMapper;
+
+    /**
+     * 查询【请填写功能名称】
+     *
+     * @param id 主键
+     * @return 【请填写功能名称】
+     */
+    @Override
+    public UserVo queryById(Long id){
+        return baseMapper.selectVoByIdInfo(id);
+    }
+
+    /**
+     * 分页查询【请填写功能名称】列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 【请填写功能名称】分页列表
+     */
+    @Override
+    public TableDataInfo<UserVo> queryPageList(UserBo bo, PageQuery pageQuery) {
+        LambdaQueryWrapper<User> lqw = buildQueryWrapper(bo);
+        Page<UserVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
+        return TableDataInfo.build(result);
+    }
+
+    /**
+     * 查询符合条件的【请填写功能名称】列表
+     *
+     * @param bo 查询条件
+     * @return 【请填写功能名称】列表
+     */
+    @Override
+    public List<UserVo> queryList(UserBo bo) {
+        LambdaQueryWrapper<User> lqw = buildQueryWrapper(bo);
+        return baseMapper.selectUserList(lqw);
+    }
+
+    private LambdaQueryWrapper<User> buildQueryWrapper(UserBo bo) {
+        Map<String, Object> params = bo.getParams();
+        LambdaQueryWrapper<User> lqw = Wrappers.lambdaQuery();
+        lqw.orderByAsc(User::getId);
+        lqw.like(StringUtils.isNotBlank(bo.getLoginName()), User::getLoginName, bo.getLoginName());
+        lqw.eq(StringUtils.isNotBlank(bo.getLoginPass()), User::getLoginPass, bo.getLoginPass());
+        lqw.eq(StringUtils.isNotBlank(bo.getPhone()), User::getPhone, bo.getPhone());
+        lqw.eq(bo.getCreateAt() != null, User::getCreateAt, bo.getCreateAt());
+        lqw.eq(bo.getUpdateAt() != null, User::getUpdateAt, bo.getUpdateAt());
+        lqw.eq(bo.getSex() != null, User::getSex, bo.getSex());
+        lqw.eq(StringUtils.isNotBlank(bo.getEmail()), User::getEmail, bo.getEmail());
+        lqw.like(StringUtils.isNotBlank(bo.getNickName()), User::getNickName, bo.getNickName());
+        lqw.eq(StringUtils.isNotBlank(bo.getCaptcha()), User::getCaptcha, bo.getCaptcha());
+        lqw.eq(StringUtils.isNotBlank(bo.getAvatar()), User::getAvatar, bo.getAvatar());
+        lqw.eq(StringUtils.isNotBlank(bo.getProvince()), User::getProvince, bo.getProvince());
+        lqw.eq(StringUtils.isNotBlank(bo.getCity()), User::getCity, bo.getCity());
+        lqw.eq(StringUtils.isNotBlank(bo.getArea()), User::getArea, bo.getArea());
+        lqw.eq(StringUtils.isNotBlank(bo.getPlaceDetail()), User::getPlaceDetail, bo.getPlaceDetail());
+        lqw.eq(StringUtils.isNotBlank(bo.getRegisterIp()), User::getRegisterIp, bo.getRegisterIp());
+        lqw.eq(StringUtils.isNotBlank(bo.getRegisterDevice()), User::getRegisterDevice, bo.getRegisterDevice());
+        lqw.eq(bo.getStatus() != null, User::getStatus, bo.getStatus());
+        lqw.eq(bo.getIsLocked() != null, User::getIsLocked, bo.getIsLocked());
+        lqw.eq(bo.getLastLoginTime() != null, User::getLastLoginTime, bo.getLastLoginTime());
+        lqw.eq(StringUtils.isNotBlank(bo.getLastLoginIp()), User::getLastLoginIp, bo.getLastLoginIp());
+        return lqw;
+    }
+
+    /**
+     * 新增【请填写功能名称】
+     *
+     * @param bo 【请填写功能名称】
+     * @return 是否新增成功
+     */
+    @Override
+    public Boolean insertByBo(UserBo bo) {
+        User add = MapstructUtils.convert(bo, User.class);
+        validEntityBeforeSave(add);
+        boolean flag = baseMapper.insertUser(add) > 0;
+        if (flag) {
+            bo.setId(add.getId());
+        }
+        return flag;
+    }
+
+    /**
+     * 修改【请填写功能名称】
+     *
+     * @param bo 【请填写功能名称】
+     * @return 是否修改成功
+     */
+    @Override
+    public Boolean updateByBo(UserBo bo) {
+        User update = MapstructUtils.convert(bo, User.class);
+        validEntityBeforeSave(update);
+        return baseMapper.updateUserById(update) > 0;
+    }
+
+    /**
+     * 保存前的数据校验
+     */
+    private void validEntityBeforeSave(User entity){
+        //TODO 做一些数据校验,如唯一约束
+    }
+
+    /**
+     * 校验并批量删除【请填写功能名称】信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
+        if(isValid){
+            //TODO 做一些业务上的校验,判断是否需要校验
+        }
+        return baseMapper.deleteByUserById(ids) > 0;
+    }
+}

+ 191 - 0
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/UserMapper.xml

@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.dromara.business.mapper.UserMapper">
+
+
+
+    <select id="selectVoPage" resultType="org.dromara.business.domain.vo.UserVo">
+        SELECT  id,
+                login_name,
+                login_pass,
+                phone,
+                create_at,
+                update_at,
+                sex,
+                email,
+                nick_name,
+                remark,
+                captcha,
+                avatar,
+                province,
+                city,
+                area,
+                place_detail,
+                register_ip,
+                register_device,
+                status,
+                is_locked,
+                last_login_time,
+                last_login_ip,
+                del_flag
+        FROM user ${ew.customSqlSegment}
+    </select>
+
+
+    <select id="selectUserList" resultType="org.dromara.business.domain.vo.UserVo">
+        SELECT  id,
+                login_name,
+                login_pass,
+                phone,
+                create_at,
+                update_at,
+                sex,
+                email,
+                nick_name,
+                remark,
+                captcha,
+                avatar,
+                province,
+                city,
+                area,
+                place_detail,
+                register_ip,
+                register_device,
+                status,
+                is_locked,
+                last_login_time,
+                last_login_ip,
+                del_flag FROM user  ${ew.customSqlSegment}
+    </select>
+
+    <select id="selectVoByIdInfo" resultType="org.dromara.business.domain.vo.UserVo">
+        SELECT  id,
+                login_name,
+                login_pass,
+                phone,
+                create_at,
+                update_at,
+                sex,
+                email,
+                nick_name,
+                remark,
+                captcha,
+                avatar,
+                province,
+                city,
+                area,
+                place_detail,
+                register_ip,
+                register_device,
+                status,
+                is_locked,
+                last_login_time,
+                last_login_ip,
+                del_flag FROM user WHERE id =  #{id}
+    </select>
+
+    <update id="updateUserById">
+        UPDATE user
+        <set>
+            <if test="loginName != null">login_name = #{loginName},</if>
+            <if test="loginPass != null">login_pass = #{loginPass},</if>
+            <if test="phone != null">phone = #{phone},</if>
+            <if test="updateAt != null">update_at = #{updateAt},</if>
+            <if test="sex != null">sex = #{sex},</if>
+            <if test="email != null">email = #{email},</if>
+            <if test="nickName != null">nick_name = #{nickName},</if>
+            <if test="remark != null">remark = #{remark},</if>
+            <if test="captcha != null">captcha = #{captcha},</if>
+            <if test="avatar != null">avatar = #{avatar},</if>
+            <if test="province != null">province = #{province},</if>
+            <if test="city != null">city = #{city},</if>
+            <if test="area != null">area = #{area},</if>
+            <if test="placeDetail != null">place_detail = #{placeDetail},</if>
+            <if test="registerIp != null">register_ip = #{registerIp},</if>
+            <if test="registerDevice != null">register_device = #{registerDevice},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="isLocked != null">is_locked = #{isLocked},</if>
+            <if test="lastLoginTime != null">last_login_time = #{lastLoginTime},</if>
+            <if test="lastLoginIp != null">last_login_ip = #{lastLoginIp},</if>
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
+        </set>
+        WHERE id = #{id}
+    </update>
+
+
+    <insert id="insertUser" useGeneratedKeys="true" keyProperty="id">
+        INSERT INTO user
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="loginName != null">login_name,</if>
+            <if test="loginPass != null">login_pass,</if>
+            <if test="phone != null">phone,</if>
+            <if test="createAt != null">create_at,</if>
+            <if test="updateAt != null">update_at,</if>
+            <if test="sex != null">sex,</if>
+            <if test="email != null">email,</if>
+            <if test="nickName != null">nick_name,</if>
+            <if test="remark != null">remark,</if>
+            <if test="captcha != null">captcha,</if>
+            <if test="avatar != null">avatar,</if>
+            <if test="province != null">province,</if>
+            <if test="city != null">city,</if>
+            <if test="area != null">area,</if>
+            <if test="placeDetail != null">place_detail,</if>
+            <if test="registerIp != null">register_ip,</if>
+            <if test="registerDevice != null">register_device,</if>
+            <if test="status != null">status,</if>
+            <if test="isLocked != null">is_locked,</if>
+            <if test="lastLoginTime != null">last_login_time,</if>
+            <if test="lastLoginIp != null">last_login_ip,</if>
+            <if test="delFlag != null">del_flag,</if>
+        </trim>
+        VALUES
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="loginName != null">#{loginName},</if>
+            <if test="loginPass != null">#{loginPass},</if>
+            <if test="phone != null">#{phone},</if>
+            <if test="createAt != null">#{createAt},</if>
+            <if test="updateAt != null">#{updateAt},</if>
+            <if test="sex != null">#{sex},</if>
+            <if test="email != null">#{email},</if>
+            <if test="nickName != null">#{nickName},</if>
+            <if test="remark != null">#{remark},</if>
+            <if test="captcha != null">#{captcha},</if>
+            <if test="avatar != null">#{avatar},</if>
+            <if test="province != null">#{province},</if>
+            <if test="city != null">#{city},</if>
+            <if test="area != null">#{area},</if>
+            <if test="placeDetail != null">#{placeDetail},</if>
+            <if test="registerIp != null">#{registerIp},</if>
+            <if test="registerDevice != null">#{registerDevice},</if>
+            <if test="status != null">#{status},</if>
+            <if test="isLocked != null">#{isLocked},</if>
+            <if test="lastLoginTime != null">#{lastLoginTime},</if>
+            <if test="lastLoginIp != null">#{lastLoginIp},</if>
+            <if test="delFlag != null">#{delFlag},</if>
+        </trim>
+    </insert>
+
+
+    <update id="deleteByUserById">
+        <choose>
+            <!-- 如果 ids 不为空,并且每个 id > 0 -->
+            <when test="ids != null and ids.size() > 0">
+                UPDATE user
+                SET del_flag = 1
+                WHERE id IN
+                <foreach item="id" collection="ids" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
+            </when>
+            <!-- 否则不执行任何操作 -->
+            <otherwise>
+                SELECT 1 FROM DUAL WHERE 1 = 0
+            </otherwise>
+        </choose>
+    </update>
+
+
+</mapper>