feat();代码生成器更改
parent
3ab7f9fec8
commit
72b0510f9e
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.common.core.web.domain;
|
package com.muyu.common.core.web.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
@ -36,12 +37,14 @@ public class BaseEntity implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 创建者
|
* 创建者
|
||||||
*/
|
*/
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private String createBy;
|
private String createBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,11 +56,13 @@ public class BaseEntity implements Serializable {
|
||||||
* 更新时间
|
* 更新时间
|
||||||
*/
|
*/
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@TableField(fill = FieldFill.UPDATE)
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
|
@TableField(fill = FieldFill.UPDATE)
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.common.system.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.annotation.Excel.ColumnType;
|
import com.muyu.common.core.annotation.Excel.ColumnType;
|
||||||
|
@ -21,6 +22,7 @@ import java.util.Date;
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@TableName(value = "sys_logininfor", autoResultMap = true)
|
||||||
public class SysLogininfor {
|
public class SysLogininfor {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -28,7 +30,7 @@ public class SysLogininfor {
|
||||||
* ID
|
* ID
|
||||||
*/
|
*/
|
||||||
@Excel(name = "序号", cellType = ColumnType.NUMERIC)
|
@Excel(name = "序号", cellType = ColumnType.NUMERIC)
|
||||||
@TableId(type = IdType.AUTO)
|
@TableId(value = "info_id", type = IdType.AUTO)
|
||||||
private Long infoId;
|
private Long infoId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package com.muyu.common.system.domain;
|
package com.muyu.common.system.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.annotation.Excel.ColumnType;
|
import com.muyu.common.core.annotation.Excel.ColumnType;
|
||||||
|
@ -19,12 +22,14 @@ import java.util.Date;
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@TableName(value = "sys_oper_log", autoResultMap = true)
|
||||||
public class SysOperLog {
|
public class SysOperLog {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日志主键
|
* 日志主键
|
||||||
*/
|
*/
|
||||||
|
@TableId(value = "oper_id", type = IdType.AUTO)
|
||||||
@Excel(name = "操作序号", cellType = ColumnType.NUMERIC)
|
@Excel(name = "操作序号", cellType = ColumnType.NUMERIC)
|
||||||
private Long operId;
|
private Long operId;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.muyu.common.system.domain;
|
package com.muyu.common.system.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.annotation.Excel.ColumnType;
|
import com.muyu.common.core.annotation.Excel.ColumnType;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
@ -26,12 +25,14 @@ import java.util.Set;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName(value = "sys_role", autoResultMap = true)
|
||||||
public class SysRole extends BaseEntity {
|
public class SysRole extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色ID
|
* 角色ID
|
||||||
*/
|
*/
|
||||||
|
@TableId(value = "role_id", type = IdType.AUTO)
|
||||||
@Excel(name = "角色序号", cellType = ColumnType.NUMERIC)
|
@Excel(name = "角色序号", cellType = ColumnType.NUMERIC)
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package com.muyu.common.system.domain;
|
package com.muyu.common.system.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.annotation.Excel.ColumnType;
|
import com.muyu.common.core.annotation.Excel.ColumnType;
|
||||||
import com.muyu.common.core.annotation.Excel.Type;
|
import com.muyu.common.core.annotation.Excel.Type;
|
||||||
|
@ -28,12 +32,14 @@ import java.util.List;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName(value = "sys_user", autoResultMap = true)
|
||||||
public class SysUser extends BaseEntity {
|
public class SysUser extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
|
@TableId(value = "user_id", type = IdType.AUTO)
|
||||||
@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
|
@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
|
@ -113,26 +119,31 @@ public class SysUser extends BaseEntity {
|
||||||
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
|
@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
|
||||||
@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
|
@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
|
||||||
})
|
})
|
||||||
|
@TableField(exist = false)
|
||||||
private SysDept dept;
|
private SysDept dept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色对象
|
* 角色对象
|
||||||
*/
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
private List<SysRole> roles;
|
private List<SysRole> roles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色组
|
* 角色组
|
||||||
*/
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
private Long[] roleIds;
|
private Long[] roleIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 岗位组
|
* 岗位组
|
||||||
*/
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
private Long[] postIds;
|
private Long[] postIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色ID
|
* 角色ID
|
||||||
*/
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
public SysUser (Long userId) {
|
public SysUser (Long userId) {
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.springframework.stereotype.Component;
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
@Data
|
|
||||||
@Component
|
@Component
|
||||||
@ConfigurationProperties(prefix = "gen")
|
@ConfigurationProperties(prefix = "gen")
|
||||||
public class GenConfig {
|
public class GenConfig {
|
||||||
|
@ -40,4 +39,20 @@ public class GenConfig {
|
||||||
public static boolean getAutoRemovePre () {
|
public static boolean getAutoRemovePre () {
|
||||||
return autoRemovePre;
|
return autoRemovePre;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setAuthor(String author) {
|
||||||
|
GenConfig.author = author;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackageName(String packageName) {
|
||||||
|
GenConfig.packageName = packageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAutoRemovePre(boolean autoRemovePre) {
|
||||||
|
GenConfig.autoRemovePre = autoRemovePre;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTablePrefix(String tablePrefix) {
|
||||||
|
GenConfig.tablePrefix = tablePrefix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class GenController extends BaseController {
|
||||||
* 查询数据库列表
|
* 查询数据库列表
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("tool:gen:list")
|
@RequiresPermissions("tool:gen:list")
|
||||||
@GetMapping("/db/list")
|
@PostMapping("/db/list")
|
||||||
public Result<DataPageResp<GenTable>> dataList (GenTable genTable) {
|
public Result<DataPageResp<GenTable>> dataList (GenTable genTable) {
|
||||||
List<GenTable> list = genTableService.selectDbTableList(genTable);
|
List<GenTable> list = genTableService.selectDbTableList(genTable);
|
||||||
return Result.success(new DataPageResp<>(0,list));
|
return Result.success(new DataPageResp<>(0,list));
|
||||||
|
@ -92,7 +92,7 @@ public class GenController extends BaseController {
|
||||||
@RequiresPermissions("tool:gen:import")
|
@RequiresPermissions("tool:gen:import")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
||||||
@PostMapping("/importTable")
|
@PostMapping("/importTable")
|
||||||
public Result<String> importTableSave (String tables) {
|
public Result<String> importTableSave (@RequestParam("tables") String tables) {
|
||||||
String[] tableNames = Convert.toStrArray(tables);
|
String[] tableNames = Convert.toStrArray(tables);
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
||||||
|
@ -172,7 +172,7 @@ public class GenController extends BaseController {
|
||||||
@RequiresPermissions("tool:gen:code")
|
@RequiresPermissions("tool:gen:code")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
||||||
@GetMapping("/batchGenCode")
|
@GetMapping("/batchGenCode")
|
||||||
public void batchGenCode (HttpServletResponse response, String tables) throws IOException {
|
public void batchGenCode (HttpServletResponse response, @RequestParam("tables") String tables) throws IOException {
|
||||||
String[] tableNames = Convert.toStrArray(tables);
|
String[] tableNames = Convert.toStrArray(tables);
|
||||||
byte[] data = genTableService.downloadCode(tableNames);
|
byte[] data = genTableService.downloadCode(tableNames);
|
||||||
genCode(response, data);
|
genCode(response, data);
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package com.muyu.gen.domain;
|
package com.muyu.gen.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.common.core.constant.GenConstants;
|
import com.muyu.common.core.constant.GenConstants;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
@ -27,12 +31,14 @@ import java.util.List;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName(value = "gen_table", autoResultMap = true)
|
||||||
public class GenTable extends BaseEntity {
|
public class GenTable extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编号
|
* 编号
|
||||||
*/
|
*/
|
||||||
|
@TableId(value = "table_id", type = IdType.AUTO)
|
||||||
private Long tableId;
|
private Long tableId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,17 +117,20 @@ public class GenTable extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 主键信息
|
* 主键信息
|
||||||
*/
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
private GenTableColumn pkColumn;
|
private GenTableColumn pkColumn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 子表信息
|
* 子表信息
|
||||||
*/
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
private GenTable subTable;
|
private GenTable subTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表列信息
|
* 表列信息
|
||||||
*/
|
*/
|
||||||
@Valid
|
@Valid
|
||||||
|
@TableField(exist = false)
|
||||||
private List<GenTableColumn> columns;
|
private List<GenTableColumn> columns;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package com.muyu.gen.domain;
|
package com.muyu.gen.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
@ -21,12 +24,14 @@ import static com.muyu.common.core.constant.SplitConstants.*;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@TableName(value = "gen_table_column", autoResultMap = true)
|
||||||
public class GenTableColumn extends BaseEntity {
|
public class GenTableColumn extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编号
|
* 编号
|
||||||
*/
|
*/
|
||||||
|
@TableId(value = "table_id", type = IdType.AUTO)
|
||||||
private Long columnId;
|
private Long columnId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.gen.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.muyu.common.core.constant.Constants;
|
import com.muyu.common.core.constant.Constants;
|
||||||
import com.muyu.common.core.constant.GenConstants;
|
import com.muyu.common.core.constant.GenConstants;
|
||||||
import com.muyu.common.core.exception.ServiceException;
|
import com.muyu.common.core.exception.ServiceException;
|
||||||
|
@ -164,8 +165,10 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteGenTableByIds (List<Long> tableIds) {
|
public void deleteGenTableByIds (List<Long> tableIds) {
|
||||||
genTableMapper.deleteGenTableByIds(tableIds);
|
this.genTableMapper.deleteByIds(tableIds);
|
||||||
genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
|
LambdaQueryWrapper<GenTableColumn> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.in(GenTableColumn::getTableId, tableIds);
|
||||||
|
this.genTableColumnMapper.delete(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,6 +195,7 @@ public class GenTableServiceImpl implements IGenTableService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error("代码生成器倒入表报错:「{}」", e.getMessage(),e);
|
||||||
throw new ServiceException("导入失败:" + e.getMessage());
|
throw new ServiceException("导入失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,9 +182,9 @@ public class SysUserController extends BaseController {
|
||||||
public Result<String> add (@Validated @RequestBody SysUser user) {
|
public Result<String> add (@Validated @RequestBody SysUser user) {
|
||||||
if (userService.checkUserNameUnique(user)) {
|
if (userService.checkUserNameUnique(user)) {
|
||||||
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && userService.checkPhoneUnique(user)) {
|
||||||
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
|
} else if (StringUtils.isNotEmpty(user.getEmail()) && userService.checkEmailUnique(user)) {
|
||||||
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
|
@ -203,9 +203,9 @@ public class SysUserController extends BaseController {
|
||||||
userService.checkUserDataScope(user.getUserId());
|
userService.checkUserDataScope(user.getUserId());
|
||||||
if (userService.checkUserNameUnique(user)) {
|
if (userService.checkUserNameUnique(user)) {
|
||||||
return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
|
return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && userService.checkPhoneUnique(user)) {
|
||||||
return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
|
} else if (StringUtils.isNotEmpty(user.getEmail()) && userService.checkEmailUnique(user)) {
|
||||||
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}
|
||||||
userService.updateUser(user);
|
userService.updateUser(user);
|
||||||
|
|
|
@ -172,7 +172,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
LambdaQueryWrapper<SysUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
lambdaQueryWrapper.eq(SysUser::getUserName, user.getUserName());
|
lambdaQueryWrapper.eq(SysUser::getUserName, user.getUserName());
|
||||||
lambdaQueryWrapper.eq(SysUser::getDelFlag, SysDelFlagEnum.EXIST.getCode());
|
lambdaQueryWrapper.eq(SysUser::getDelFlag, SysDelFlagEnum.EXIST.getCode());
|
||||||
lambdaQueryWrapper.eq(user.getUserId() != null,SysUser::getUserId, user.getUserId());
|
lambdaQueryWrapper.ne(user.getUserId() != null,SysUser::getUserId, user.getUserId());
|
||||||
if (this.count(lambdaQueryWrapper) > 0) {
|
if (this.count(lambdaQueryWrapper) > 0) {
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
LambdaQueryWrapper<SysUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
lambdaQueryWrapper.eq(SysUser::getPhonenumber, user.getPhonenumber());
|
lambdaQueryWrapper.eq(SysUser::getPhonenumber, user.getPhonenumber());
|
||||||
lambdaQueryWrapper.eq(SysUser::getDelFlag, SysDelFlagEnum.EXIST.getCode());
|
lambdaQueryWrapper.eq(SysUser::getDelFlag, SysDelFlagEnum.EXIST.getCode());
|
||||||
lambdaQueryWrapper.eq(user.getUserId() != null,SysUser::getUserId, user.getUserId());
|
lambdaQueryWrapper.ne(user.getUserId() != null,SysUser::getUserId, user.getUserId());
|
||||||
if (this.count(lambdaQueryWrapper) > 0) {
|
if (this.count(lambdaQueryWrapper) > 0) {
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
LambdaQueryWrapper<SysUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
lambdaQueryWrapper.eq(SysUser::getEmail, user.getEmail());
|
lambdaQueryWrapper.eq(SysUser::getEmail, user.getEmail());
|
||||||
lambdaQueryWrapper.eq(SysUser::getDelFlag, SysDelFlagEnum.EXIST.getCode());
|
lambdaQueryWrapper.eq(SysUser::getDelFlag, SysDelFlagEnum.EXIST.getCode());
|
||||||
lambdaQueryWrapper.eq(user.getUserId() != null,SysUser::getUserId, user.getUserId());
|
lambdaQueryWrapper.ne(user.getUserId() != null,SysUser::getUserId, user.getUserId());
|
||||||
if (this.count(lambdaQueryWrapper) > 0) {
|
if (this.count(lambdaQueryWrapper) > 0) {
|
||||||
return UserConstants.UNIQUE;
|
return UserConstants.UNIQUE;
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
public void updateUserAvatar (String userName, String avatar) {
|
public void updateUserAvatar (String userName, String avatar) {
|
||||||
LambdaUpdateWrapper<SysUser> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
LambdaUpdateWrapper<SysUser> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||||
lambdaUpdateWrapper.eq(SysUser::getUserName, userName);
|
lambdaUpdateWrapper.eq(SysUser::getUserName, userName);
|
||||||
lambdaUpdateWrapper.eq(SysUser::getAvatar, avatar);
|
lambdaUpdateWrapper.set(SysUser::getAvatar, avatar);
|
||||||
this.update(lambdaUpdateWrapper);
|
this.update(lambdaUpdateWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue