使用mybatis-flex重构“部门管理”模块代码

This commit is contained in:
dataprince 2023-09-25 20:36:10 +08:00
parent a73f311afc
commit 5285591fc5
25 changed files with 749 additions and 739 deletions

View File

@ -16,7 +16,7 @@ mybatis-flex:
autoMappingBehavior: FULL
# MyBatis 自动映射时未知列或未知属性处理策
# NONE不做处理 WARNING打印相关警告 FAILING抛出异常和详细信息
autoMappingUnknownColumnBehavior: WARNING
autoMappingUnknownColumnBehavior: NONE
# 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
# 关闭日志记录 org.apache.ibatis.logging.nologging.NoLoggingImpl
# 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl

View File

@ -24,6 +24,12 @@ public class BaseEntity implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 租户编号
*/
@Column(ignore = true)
private Long tenantId;
/**
* 搜索值
*/

View File

@ -2,6 +2,7 @@ package com.ruoyi.demo.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotBlank;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
@ -26,6 +27,8 @@ public class DemoStudent extends BaseEntity
/** 年龄 */
@Excel(name = "年龄")
//@NotBlank
//private int studentAge;
private Long studentAge;
/** 爱好0代码 1音乐 2电影 */

View File

@ -3,13 +3,16 @@ package com.ruoyi.system.controller.system;
import java.util.List;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.core.core.domain.R;
import com.ruoyi.common.core.core.text.Convert;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.utils.LoginHelper;
import com.ruoyi.system.domain.SysDept;
import com.ruoyi.system.domain.bo.SysDeptBo;
import com.ruoyi.system.domain.vo.SysDeptVo;
import com.ruoyi.system.service.ISysUserService;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
@ -38,14 +41,17 @@ public class SysDeptController extends BaseController {
@Resource
private ISysDeptService deptService;
@Resource
private ISysUserService sysUserService;
/**
* 获取部门列表
*/
@SaCheckPermission("system:dept:list")
@GetMapping("/list")
public AjaxResult list(SysDept dept) {
List<SysDept> depts = deptService.selectDeptList(dept);
return success(depts);
public R<List<SysDeptVo>> list(SysDeptBo deptBo) {
List<SysDeptVo> depts = deptService.selectDeptList(deptBo);
return R.ok(depts);
}
/**
@ -53,10 +59,10 @@ public class SysDeptController extends BaseController {
*/
@SaCheckPermission("system:dept:list")
@GetMapping("/list/exclude/{deptId}")
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
List<SysDept> depts = deptService.selectDeptList(new SysDept());
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
return success(depts);
public R<List<SysDeptVo>> excludeChild(@PathVariable(value = "deptId", required = false) Long deptId) {
List<SysDeptVo> depts = deptService.selectDeptList(new SysDeptBo());
depts.removeIf(d -> d.getDeptId().equals(deptId) || StringUtils.splitList(d.getAncestors()).contains(Convert.toStr(deptId)));
return R.ok(depts);
}
/**
@ -65,9 +71,9 @@ public class SysDeptController extends BaseController {
@SaCheckPermission("system:dept:query")
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@GetMapping(value = "/{deptId}")
public AjaxResult getInfo(@PathVariable Long deptId) {
public R<SysDeptVo> getInfo(@PathVariable Long deptId) {
deptService.checkDeptDataScope(deptId);
return success(deptService.selectDeptById(deptId));
return R.ok(deptService.selectDeptById(deptId));
}
/**
@ -75,12 +81,15 @@ public class SysDeptController extends BaseController {
*/
@SaCheckPermission("system:dept:add")
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDept dept) {
public R<Void> add(@Validated @RequestBody SysDeptBo dept) {
if (!deptService.checkDeptNameUnique(dept)) {
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
return R.fail("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
dept.setCreateBy(LoginHelper.getUserId());
return toAjax(deptService.insertDept(dept));
int inserted = deptService.insertDept(dept);
if (inserted != 1) {
return R.fail("新增部门记录失败!");
}
return R.ok();
}
/**
@ -89,22 +98,25 @@ public class SysDeptController extends BaseController {
@SaCheckPermission("system:dept:edit")
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDept dept) {
public R<Void> edit(@Validated @RequestBody SysDeptBo dept) {
Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId);
if (!deptService.checkDeptNameUnique(dept)) {
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
return R.fail("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
} else if (dept.getParentId().equals(deptId)) {
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
return R.fail("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())) {
if (deptService.selectNormalChildrenDeptById(deptId) > 0) {
return error("该部门包含未停用的子部门!");
} else if (deptService.checkDeptExistUser(deptId)) {
return error("该部门下存在已分配用户,不能禁用!");
return R.fail("该部门包含未停用的子部门!");
} else if (sysUserService.checkDeptExistUser(deptId)) {
return R.fail("该部门下存在已分配用户,不能禁用!");
}
}
dept.setUpdateBy(LoginHelper.getUserId());
return toAjax(deptService.updateDept(dept));
boolean updated = deptService.updateDept(dept);
if (!updated) {
return R.fail("修改部门'" + dept.getDeptName() + "'失败");
}
return R.ok();
}
/**
@ -113,14 +125,18 @@ public class SysDeptController extends BaseController {
@SaCheckPermission("system:dept:remove")
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}")
public AjaxResult remove(@PathVariable Long deptId) {
public R<Void> remove(@PathVariable Long deptId) {
if (deptService.hasChildByDeptId(deptId)) {
return warn("存在下级部门,不允许删除");
return R.warn("存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId)) {
return warn("部门存在用户,不允许删除");
if (sysUserService.checkDeptExistUser(deptId)) {
return R.warn("部门存在用户,不允许删除");
}
deptService.checkDeptDataScope(deptId);
return toAjax(deptService.deleteDeptById(deptId));
boolean updated = deptService.deleteDeptById(deptId);
if (!updated) {
return R.fail("删除部门失败");
}
return R.ok();
}
}

View File

@ -10,6 +10,7 @@ import com.ruoyi.common.security.utils.LoginHelper;
import com.ruoyi.system.domain.SysDept;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.domain.bo.SysDeptBo;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
@ -244,7 +245,7 @@ public class SysRoleController extends BaseController
{
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
ajax.put("depts", deptService.selectDeptTreeList(new SysDept()));
ajax.put("depts", deptService.selectDeptTreeList(new SysDeptBo()));
return ajax;
}
}

View File

@ -14,6 +14,7 @@ import com.ruoyi.system.domain.SysDept;
import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.domain.bo.SysDeptBo;
import com.ruoyi.system.domain.bo.SysPostBo;
import com.ruoyi.system.service.*;
import jakarta.annotation.Resource;
@ -238,7 +239,7 @@ public class SysUserController extends BaseController {
*/
@SaCheckPermission("system:user:list")
@GetMapping("/deptTree")
public AjaxResult deptTree(SysDept dept) {
public AjaxResult deptTree(SysDeptBo dept) {
return success(deptService.selectDeptTreeList(dept));
}

View File

@ -3,9 +3,16 @@ package com.ruoyi.system.domain;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.orm.core.domain.BaseEntity;
@ -15,12 +22,14 @@ import com.ruoyi.common.orm.core.domain.BaseEntity;
*
* @author ruoyi
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Table(value = "sys_dept")
public class SysDept extends BaseEntity
{
@Serial
private static final long serialVersionUID = 1L;
/** 部门ID */
@Id(keyType = KeyType.Auto)
private Long deptId;
/** 父部门ID */
@ -36,7 +45,7 @@ public class SysDept extends BaseEntity
private String orderNum;
/** 负责人 */
private String leader;
private String leader;//TODO:修改为Long类型
/** 联系电话 */
private String phone;
@ -51,154 +60,155 @@ public class SysDept extends BaseEntity
private String delFlag;
/** 父部门名称 */
@Column(ignore = true)
private String parentName;
/** 子部门 */
private List<SysDept> children = new ArrayList<SysDept>();
public Long getDeptId()
{
return deptId;
}
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
public Long getParentId()
{
return parentId;
}
public void setParentId(Long parentId)
{
this.parentId = parentId;
}
public String getAncestors()
{
return ancestors;
}
public void setAncestors(String ancestors)
{
this.ancestors = ancestors;
}
@NotBlank(message = "部门名称不能为空")
@Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
public String getDeptName()
{
return deptName;
}
public void setDeptName(String deptName)
{
this.deptName = deptName;
}
@NotBlank(message = "显示顺序不能为空")
public String getOrderNum()
{
return orderNum;
}
public void setOrderNum(String orderNum)
{
this.orderNum = orderNum;
}
public String getLeader()
{
return leader;
}
public void setLeader(String leader)
{
this.leader = leader;
}
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
public String getPhone()
{
return phone;
}
public void setPhone(String phone)
{
this.phone = phone;
}
@Email(message = "邮箱格式不正确")
@Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
public String getEmail()
{
return email;
}
public void setEmail(String email)
{
this.email = email;
}
public String getStatus()
{
return status;
}
public void setStatus(String status)
{
this.status = status;
}
public String getDelFlag()
{
return delFlag;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public String getParentName()
{
return parentName;
}
public void setParentName(String parentName)
{
this.parentName = parentName;
}
public List<SysDept> getChildren()
{
return children;
}
public void setChildren(List<SysDept> children)
{
this.children = children;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("deptId", getDeptId())
.append("parentId", getParentId())
.append("ancestors", getAncestors())
.append("deptName", getDeptName())
.append("orderNum", getOrderNum())
.append("leader", getLeader())
.append("phone", getPhone())
.append("email", getEmail())
.append("status", getStatus())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
// public Long getDeptId()
// {
// return deptId;
// }
//
// public void setDeptId(Long deptId)
// {
// this.deptId = deptId;
// }
//
// public Long getParentId()
// {
// return parentId;
// }
//
// public void setParentId(Long parentId)
// {
// this.parentId = parentId;
// }
//
// public String getAncestors()
// {
// return ancestors;
// }
//
// public void setAncestors(String ancestors)
// {
// this.ancestors = ancestors;
// }
//
// @NotBlank(message = "部门名称不能为空")
// @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
// public String getDeptName()
// {
// return deptName;
// }
//
// public void setDeptName(String deptName)
// {
// this.deptName = deptName;
// }
//
// @NotBlank(message = "显示顺序不能为空")
// public String getOrderNum()
// {
// return orderNum;
// }
//
// public void setOrderNum(String orderNum)
// {
// this.orderNum = orderNum;
// }
//
// public String getLeader()
// {
// return leader;
// }
//
// public void setLeader(String leader)
// {
// this.leader = leader;
// }
//
// @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
// public String getPhone()
// {
// return phone;
// }
//
// public void setPhone(String phone)
// {
// this.phone = phone;
// }
//
// @Email(message = "邮箱格式不正确")
// @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
// public String getEmail()
// {
// return email;
// }
//
// public void setEmail(String email)
// {
// this.email = email;
// }
//
// public String getStatus()
// {
// return status;
// }
//
// public void setStatus(String status)
// {
// this.status = status;
// }
//
// public String getDelFlag()
// {
// return delFlag;
// }
//
// public void setDelFlag(String delFlag)
// {
// this.delFlag = delFlag;
// }
//
// public String getParentName()
// {
// return parentName;
// }
//
// public void setParentName(String parentName)
// {
// this.parentName = parentName;
// }
//
// public List<SysDept> getChildren()
// {
// return children;
// }
//
// public void setChildren(List<SysDept> children)
// {
// this.children = children;
// }
//
// @Override
// public String toString() {
// return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
// .append("deptId", getDeptId())
// .append("parentId", getParentId())
// .append("ancestors", getAncestors())
// .append("deptName", getDeptName())
// .append("orderNum", getOrderNum())
// .append("leader", getLeader())
// .append("phone", getPhone())
// .append("email", getEmail())
// .append("status", getStatus())
// .append("delFlag", getDelFlag())
// .append("createBy", getCreateBy())
// .append("createTime", getCreateTime())
// .append("updateBy", getUpdateBy())
// .append("updateTime", getUpdateTime())
// .toString();
// }
}

View File

@ -1,7 +1,14 @@
package com.ruoyi.system.domain;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.RelationManyToMany;
import com.mybatisflex.annotation.Table;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
@ -9,6 +16,7 @@ import com.ruoyi.common.core.annotation.Excel.ColumnType;
import com.ruoyi.common.orm.core.domain.BaseEntity;
import java.io.Serial;
import java.util.List;
import java.util.Set;
/**
@ -16,13 +24,15 @@ import java.util.Set;
*
* @author ruoyi
*/
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Table(value = "sys_role")
public class SysRole extends BaseEntity
{
@Serial
private static final long serialVersionUID = 1L;
/** 角色ID */
@Excel(name = "角色序号", cellType = ColumnType.NUMERIC)
@Id(keyType = KeyType.Auto)
private Long roleId;
/** 角色名称 */
@ -65,40 +75,35 @@ public class SysRole extends BaseEntity
/** 菜单组 */
private Long[] menuIds;
@RelationManyToMany(
selfField = "roleId",
targetField = "menuId",
joinTable = "sys_role_menu",
joinSelfColumn = "role_id",
joinTargetColumn = "menu_id"
)
private List<SysMenu> menuList;
/** 部门组(数据权限) */
private Long[] deptIds;
@RelationManyToMany(
selfField = "roleId",
targetField = "deptId",
joinTable = "sys_role_dept",
joinSelfColumn = "role_id",
joinTargetColumn = "dept_id"
)
private List<SysDept> deptList;
/** 角色菜单权限 */
private Set<String> permissions;
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public SysRole()
{
}
public SysRole(Long roleId)
{
this.roleId = roleId;
}
public Long getRoleId()
{
return roleId;
}
public void setRoleId(Long roleId)
{
this.roleId = roleId;
}
public boolean isAdmin()
{
return isAdmin(this.roleId);
@ -109,148 +114,4 @@ public class SysRole extends BaseEntity
return roleId != null && 1L == roleId;
}
@NotBlank(message = "角色名称不能为空")
@Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
public String getRoleName()
{
return roleName;
}
public void setRoleName(String roleName)
{
this.roleName = roleName;
}
@NotBlank(message = "权限字符不能为空")
@Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
public String getRoleKey()
{
return roleKey;
}
public void setRoleKey(String roleKey)
{
this.roleKey = roleKey;
}
@NotBlank(message = "显示顺序不能为空")
public String getRoleSort()
{
return roleSort;
}
public void setRoleSort(String roleSort)
{
this.roleSort = roleSort;
}
public String getDataScope()
{
return dataScope;
}
public void setDataScope(String dataScope)
{
this.dataScope = dataScope;
}
public boolean isMenuCheckStrictly()
{
return menuCheckStrictly;
}
public void setMenuCheckStrictly(boolean menuCheckStrictly)
{
this.menuCheckStrictly = menuCheckStrictly;
}
public boolean isDeptCheckStrictly()
{
return deptCheckStrictly;
}
public void setDeptCheckStrictly(boolean deptCheckStrictly)
{
this.deptCheckStrictly = deptCheckStrictly;
}
public String getStatus()
{
return status;
}
public void setStatus(String status)
{
this.status = status;
}
public String getDelFlag()
{
return delFlag;
}
public void setDelFlag(String delFlag)
{
this.delFlag = delFlag;
}
public boolean isFlag()
{
return flag;
}
public void setFlag(boolean flag)
{
this.flag = flag;
}
public Long[] getMenuIds()
{
return menuIds;
}
public void setMenuIds(Long[] menuIds)
{
this.menuIds = menuIds;
}
public Long[] getDeptIds()
{
return deptIds;
}
public void setDeptIds(Long[] deptIds)
{
this.deptIds = deptIds;
}
public Set<String> getPermissions()
{
return permissions;
}
public void setPermissions(Set<String> permissions)
{
this.permissions = permissions;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("roleId", getRoleId())
.append("roleName", getRoleName())
.append("roleKey", getRoleKey())
.append("roleSort", getRoleSort())
.append("dataScope", getDataScope())
.append("menuCheckStrictly", isMenuCheckStrictly())
.append("deptCheckStrictly", isDeptCheckStrictly())
.append("status", getStatus())
.append("delFlag", getDelFlag())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}

View File

@ -1,19 +1,29 @@
package com.ruoyi.system.domain;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 角色和菜单关联 sys_role_menu
*
*
* @author ruoyi
*/
@Data
@Table(value = "sys_role_menu")
public class SysRoleMenu
{
/** 角色ID */
@Id(keyType = KeyType.None)
private Long roleId;
/** 菜单ID */
@Id(keyType = KeyType.None)
private Long menuId;
public Long getRoleId()

View File

@ -1,10 +1,18 @@
package com.ruoyi.system.domain;
import java.io.Serial;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.tenant.core.TenantEntity;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.orm.core.domain.BaseEntity;
import jakarta.validation.constraints.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.fasterxml.jackson.annotation.JsonIgnore;
@ -13,7 +21,6 @@ import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.annotation.Excel.ColumnType;
import com.ruoyi.common.core.annotation.Excel.Type;
import com.ruoyi.common.core.annotation.Excels;
import com.ruoyi.common.orm.core.domain.BaseEntity;
import com.ruoyi.common.core.xss.Xss;
/**
@ -21,12 +28,13 @@ import com.ruoyi.common.core.xss.Xss;
*
* @author ruoyi
*/
public class SysUser extends TenantEntity
{
private static final long serialVersionUID = 1L;
@Table(value = "sys_user")
public class SysUser extends BaseEntity
{
/** 用户ID */
@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
@Id(keyType = KeyType.Auto)
private Long userId;
/** 部门ID */
@ -56,7 +64,7 @@ public class SysUser extends TenantEntity
/** 用户性别 */
@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
private String sex;
private String gender;
/** 用户头像 */
private String avatar;
@ -202,14 +210,14 @@ public class SysUser extends TenantEntity
this.phonenumber = phonenumber;
}
public String getSex()
public String getGender()
{
return sex;
return gender;
}
public void setSex(String sex)
public void setGender(String gender)
{
this.sex = sex;
this.gender = gender;
}
public String getAvatar()
@ -352,7 +360,7 @@ public class SysUser extends TenantEntity
.append("userType", getUserType())
.append("email", getEmail())
.append("phonenumber", getPhonenumber())
.append("sex", getSex())
.append("sex", getGender())
.append("avatar", getAvatar())
.append("password", getPassword())
.append("salt", getSalt())
@ -368,4 +376,9 @@ public class SysUser extends TenantEntity
.append("dept", getDept())
.toString();
}
public boolean isSuperAdmin() {
return UserConstants.SUPER_ADMIN_ID.equals(this.userId);
}
}

View File

@ -1,6 +1,6 @@
package com.ruoyi.system.domain.bo;
import com.ruoyi.common.tenant.core.TenantEntity;
import com.ruoyi.common.orm.core.domain.BaseEntity;
import io.github.linpeilie.annotations.AutoMapper;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
@ -22,7 +22,7 @@ import com.ruoyi.system.domain.SysUser;
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = SysUser.class)
public class SysUserBo extends TenantEntity {
public class SysUserBo extends BaseEntity {
/**
* 用户ID
@ -70,7 +70,7 @@ public class SysUserBo extends TenantEntity {
/**
* 用户性别0男 1女 2未知
*/
private String sex;
private String gender;
/**
* 密码

View File

@ -2,6 +2,7 @@ package com.ruoyi.system.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.mybatisflex.annotation.Column;
import com.ruoyi.common.excel.annotation.ExcelDictFormat;
import com.ruoyi.common.excel.convert.ExcelDictConvert;
import com.ruoyi.system.domain.SysDept;
@ -39,6 +40,7 @@ public class SysDeptVo implements Serializable {
/**
* 父部门名称
*/
@Column(ignore = true)
private String parentName;
/**

View File

@ -73,7 +73,7 @@ public class SysUserVo implements Serializable {
/**
* 用户性别0男 1女 2未知
*/
private String sex;
private String gender;
/**
* 头像地址

View File

@ -2,7 +2,10 @@ package com.ruoyi.system.mapper;
import java.util.List;
import com.mybatisflex.core.BaseMapper;
import com.ruoyi.system.domain.SysDept;
import com.ruoyi.system.domain.vo.SysDeptVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
@ -10,15 +13,16 @@ import org.apache.ibatis.annotations.Param;
*
* @author ruoyi
*/
public interface SysDeptMapper
@Mapper
public interface SysDeptMapper extends BaseMapper<SysDept>
{
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @return 部门信息集合
*/
List<SysDept> selectDeptList(SysDept dept);
// /**
// * 查询部门管理数据
// *
// * @param dept 部门信息
// * @return 部门信息集合
// */
// List<SysDept> selectDeptList(SysDept dept);
/**
* 根据角色ID查询部门树信息
@ -29,91 +33,91 @@ public interface SysDeptMapper
*/
List<Long> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);
/**
* 根据部门ID查询信息
*
* @param deptId 部门ID
* @return 部门信息
*/
SysDept selectDeptById(Long deptId);
// /**
// * 根据部门ID查询信息
// *
// * @param deptId 部门ID
// * @return 部门信息
// */
// SysDeptVo selectDeptById(Long deptId);
/**
* 根据ID查询所有子部门
*
* @param deptId 部门ID
* @return 部门列表
*/
List<SysDept> selectChildrenDeptById(Long deptId);
// /**
// * 根据ID查询所有子部门
// *
// * @param deptId 部门ID
// * @return 部门列表
// */
// List<SysDept> selectChildrenDeptById(Long deptId);
/**
* 根据ID查询所有子部门正常状态
*
* @param deptId 部门ID
* @return 子部门数
*/
int selectNormalChildrenDeptById(Long deptId);
// /**
// * 根据ID查询所有子部门正常状态
// *
// * @param deptId 部门ID
// * @return 子部门数
// */
// int selectNormalChildrenDeptById(Long deptId);
/**
* 是否存在子节点
*
* @param deptId 部门ID
* @return 结果
*/
int hasChildByDeptId(Long deptId);
// /**
// * 是否存在子节点
// *
// * @param deptId 部门ID
// * @return 结果
// */
// int hasChildByDeptId(Long deptId);
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果
*/
int checkDeptExistUser(Long deptId);
// /**
// * 查询部门是否存在用户
// *
// * @param deptId 部门ID
// * @return 结果
// */
// int checkDeptExistUser(Long deptId);
/**
* 校验部门名称是否唯一
*
* @param deptName 部门名称
* @param parentId 父部门ID
* @return 结果
*/
SysDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId);
// /**
// * 校验部门名称是否唯一
// *
// * @param deptName 部门名称
// * @param parentId 父部门ID
// * @return 结果
// */
// SysDept checkDeptNameUnique(@Param("deptName") String deptName, @Param("parentId") Long parentId);
//
// /**
// * 新增部门信息
// *
// * @param dept 部门信息
// * @return 结果
// */
// int insertDept(SysDept dept);
/**
* 新增部门信息
*
* @param dept 部门信息
* @return 结果
*/
int insertDept(SysDept dept);
// /**
// * 修改部门信息
// *
// * @param dept 部门信息
// * @return 结果
// */
// int updateDept(SysDept dept);
/**
* 修改部门信息
*
* @param dept 部门信息
* @return 结果
*/
int updateDept(SysDept dept);
// /**
// * 修改所在部门正常状态
// *
// * @param deptIds 部门ID组
// */
// void updateDeptStatusNormal(Long[] deptIds);
/**
* 修改所在部门正常状态
*
* @param deptIds 部门ID组
*/
void updateDeptStatusNormal(Long[] deptIds);
// /**
// * 修改子元素关系
// *
// * @param depts 子元素
// * @return 结果
// */
// int updateDeptChildren(@Param("depts") List<SysDept> depts);
/**
* 修改子元素关系
*
* @param depts 子元素
* @return 结果
*/
int updateDeptChildren(@Param("depts") List<SysDept> depts);
/**
* 删除部门管理信息
*
* @param deptId 部门ID
* @return 结果
*/
int deleteDeptById(Long deptId);
// /**
// * 删除部门管理信息
// *
// * @param deptId 部门ID
// * @return 结果
// */
// int deleteDeptById(Long deptId);
}

View File

@ -2,8 +2,8 @@ package com.ruoyi.system.mapper;
import java.util.List;
import com.mybatisflex.core.BaseMapper;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.domain.vo.SysUserVo;
import org.apache.ibatis.annotations.Param;
/**
@ -11,7 +11,7 @@ import org.apache.ibatis.annotations.Param;
*
* @author ruoyi
*/
public interface SysUserMapper
public interface SysUserMapper extends BaseMapper<SysUser>
{
/**
* 根据条件分页查询用户列表

View File

@ -1,15 +1,19 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.TreeSelect;
import cn.hutool.core.lang.tree.Tree;
import com.ruoyi.common.orm.core.service.IBaseService;
import com.ruoyi.system.domain.SysDept;
import com.ruoyi.system.domain.bo.SysDeptBo;
import com.ruoyi.system.domain.vo.SysDeptVo;
/**
* 部门管理 服务层
*
* @author ruoyi
*/
public interface ISysDeptService
public interface ISysDeptService extends IBaseService<SysDept>
{
/**
* 查询部门管理数据
@ -17,7 +21,7 @@ public interface ISysDeptService
* @param dept 部门信息
* @return 部门信息集合
*/
List<SysDept> selectDeptList(SysDept dept);
List<SysDeptVo> selectDeptList(SysDeptBo dept);
/**
* 查询部门树结构信息
@ -25,15 +29,7 @@ public interface ISysDeptService
* @param dept 部门信息
* @return 部门树信息集合
*/
List<TreeSelect> selectDeptTreeList(SysDept dept);
/**
* 构建前端所需要树结构
*
* @param depts 部门列表
* @return 树结构列表
*/
List<SysDept> buildDeptTree(List<SysDept> depts);
List<Tree<Long>> selectDeptTreeList(SysDeptBo dept) ;
/**
* 构建前端所需要下拉树结构
@ -41,7 +37,7 @@ public interface ISysDeptService
* @param depts 部门列表
* @return 下拉树结构列表
*/
List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts);
List<Tree<Long>> buildDeptTreeSelect(List<SysDeptVo> depts);
/**
* 根据角色ID查询部门树信息
@ -57,7 +53,7 @@ public interface ISysDeptService
* @param deptId 部门ID
* @return 部门信息
*/
SysDept selectDeptById(Long deptId);
SysDeptVo selectDeptById(Long deptId);
/**
* 根据ID查询所有子部门正常状态
@ -75,21 +71,13 @@ public interface ISysDeptService
*/
boolean hasChildByDeptId(Long deptId);
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
boolean checkDeptExistUser(Long deptId);
/**
* 校验部门名称是否唯一
*
* @param dept 部门信息
* @return 结果
*/
boolean checkDeptNameUnique(SysDept dept);
boolean checkDeptNameUnique(SysDeptBo dept);
/**
* 校验部门是否有数据权限
@ -101,10 +89,10 @@ public interface ISysDeptService
/**
* 新增保存部门信息
*
* @param dept 部门信息
* @return 结果
* @param deptBo 部门信息
* @return 受影响的行数
*/
int insertDept(SysDept dept);
int insertDept(SysDeptBo deptBo);
/**
* 修改保存部门信息
@ -112,7 +100,7 @@ public interface ISysDeptService
* @param dept 部门信息
* @return 结果
*/
int updateDept(SysDept dept);
boolean updateDept(SysDeptBo dept);
/**
* 删除部门管理信息
@ -120,5 +108,5 @@ public interface ISysDeptService
* @param deptId 部门ID
* @return 结果
*/
int deleteDeptById(Long deptId);
boolean deleteDeptById(Long deptId);
}

View File

@ -1,5 +1,6 @@
package com.ruoyi.system.service;
import com.ruoyi.common.orm.core.service.IBaseService;
import com.ruoyi.system.domain.SysUser;
import com.ruoyi.system.domain.bo.SysUserBo;
import com.ruoyi.system.domain.vo.SysUserVo;
@ -11,7 +12,7 @@ import java.util.List;
*
* @author ruoyi
*/
public interface ISysUserService
public interface ISysUserService extends IBaseService<SysUser>
{
/**
* 根据条件分页查询用户列表
@ -107,6 +108,14 @@ public interface ISysUserService
*/
void checkUserDataScope(Long userId);
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
boolean checkDeptExistUser(Long deptId);
/**
* 新增用户信息
*

View File

@ -5,17 +5,31 @@ import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.util.ObjectUtil;
import com.mybatisflex.core.query.QueryMethods;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import com.ruoyi.common.core.constant.CacheNames;
import com.ruoyi.common.core.core.page.PageDomain;
import com.ruoyi.common.core.core.page.TableSupport;
import com.ruoyi.common.core.service.DeptService;
import com.ruoyi.common.core.utils.MapstructUtils;
import com.ruoyi.common.core.utils.TreeBuildUtils;
import com.ruoyi.common.core.utils.sql.SqlUtil;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
import com.ruoyi.common.security.utils.LoginHelper;
import com.ruoyi.system.domain.SysDept;
import com.ruoyi.system.domain.SysRole;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.bo.SysDeptBo;
import com.ruoyi.system.domain.vo.SysDeptVo;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.annotation.DataScope;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.system.domain.TreeSelect;
import com.ruoyi.common.core.core.text.Convert;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.StringUtils;
@ -23,6 +37,9 @@ import com.ruoyi.common.core.utils.SpringUtils;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.service.ISysDeptService;
import org.springframework.transaction.annotation.Transactional;
import static com.ruoyi.system.domain.table.SysDeptTableDef.SYS_DEPT;
/**
* 部门管理 服务实现
@ -31,25 +48,57 @@ import com.ruoyi.system.service.ISysDeptService;
*/
@RequiredArgsConstructor
@Service
public class SysDeptServiceImpl implements ISysDeptService, DeptService {
public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept> implements ISysDeptService, DeptService {
@Resource
private SysDeptMapper deptMapper;
@Resource
private SysRoleMapper roleMapper;
@Override
public QueryWrapper query() {
return super.query().from(SYS_DEPT);
}
/**
* 根据ndeptBo构建QueryWrapper查询条件
*
* @param deptBo
* @return 查询条件
*/
private QueryWrapper buildQueryWrapper(SysDeptBo deptBo) {
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
PageDomain pageDomain = TableSupport.buildPageRequest();
queryWrapper.where(SYS_DEPT.DEL_FLAG.eq("0"));
if (ObjectUtil.isNotNull(deptBo.getDeptId())) {
queryWrapper.and(SYS_DEPT.DEPT_ID.eq(deptBo.getDeptId()));
}
if (ObjectUtil.isNotNull(deptBo.getParentId())) {
queryWrapper.and(SYS_DEPT.PARENT_ID.eq(deptBo.getParentId()));
}
if (StringUtils.isNotNull(deptBo.getDeptName())) {
queryWrapper.and(SYS_DEPT.DEPT_NAME.like(deptBo.getDeptName()));
}
if (StringUtils.isNotNull(deptBo.getStatus())) {
queryWrapper.and(SYS_DEPT.STATUS.eq(deptBo.getStatus()));
}
queryWrapper.orderBy(SYS_DEPT.PARENT_ID.asc(),SYS_DEPT.ORDER_NUM.asc());
return queryWrapper;
}
/**
* 查询部门管理数据
*
* @param dept 部门信息
* @param deptBo 部门信息
* @return 部门信息集合
*/
@Override
@DataScope(deptAlias = "d")
public List<SysDept> selectDeptList(SysDept dept) {
// 只查询未禁用部门
//dept.setStatus(UserConstants.DEPT_NORMAL);
return deptMapper.selectDeptList(dept);
public List<SysDeptVo> selectDeptList(SysDeptBo deptBo) {
QueryWrapper queryWrapper = buildQueryWrapper(deptBo);
return this.listAs(queryWrapper, SysDeptVo.class);
}
/**
@ -59,36 +108,13 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @return 部门树信息集合
*/
@Override
public List<TreeSelect> selectDeptTreeList(SysDept dept) {
public List<Tree<Long>> selectDeptTreeList(SysDeptBo dept) {
// 只查询未禁用部门
dept.setStatus(UserConstants.DEPT_NORMAL);
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
List<SysDeptVo> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
return buildDeptTreeSelect(depts);
}
/**
* 构建前端所需要树结构
*
* @param depts 部门列表
* @return 树结构列表
*/
@Override
public List<SysDept> buildDeptTree(List<SysDept> depts) {
List<SysDept> returnList = new ArrayList<>();
List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
for (SysDept dept : depts) {
// 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempList.contains(dept.getParentId())) {
recursionFn(depts, dept);
returnList.add(dept);
}
}
if (returnList.isEmpty()) {
returnList = depts;
}
return returnList;
}
/**
* 构建前端所需要下拉树结构
*
@ -96,9 +122,15 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @return 下拉树结构列表
*/
@Override
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) {
List<SysDept> deptTrees = buildDeptTree(depts);
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
public List<Tree<Long>> buildDeptTreeSelect(List<SysDeptVo> depts) {
if (CollUtil.isEmpty(depts)) {
return CollUtil.newArrayList();
}
return TreeBuildUtils.build(depts, (dept, tree) ->
tree.setId(dept.getDeptId())
.setParentId(dept.getParentId())
.setName(dept.getDeptName())
.setWeight(dept.getOrderNum()));
}
/**
@ -119,9 +151,12 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @param deptId 部门ID
* @return 部门信息
*/
@Cacheable(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
@Override
public SysDept selectDeptById(Long deptId) {
return deptMapper.selectDeptById(deptId);
public SysDeptVo selectDeptById(Long deptId) {
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq("0"));
queryWrapper.and(SYS_DEPT.DEPT_ID.eq(deptId));
return this.getOneAs(queryWrapper, SysDeptVo.class);//TODO:缺少parent_name
}
/**
@ -132,7 +167,15 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
*/
@Override
public int selectNormalChildrenDeptById(Long deptId) {
return deptMapper.selectNormalChildrenDeptById(deptId);
// return deptMapper.selectNormalChildrenDeptById(deptId);
QueryWrapper queryWrapper = QueryWrapper.create()
.select(QueryMethods.count(SYS_DEPT.DEPT_ID))
.from(SYS_DEPT)
.where(SYS_DEPT.STATUS.eq("0"))
.and(SYS_DEPT.DEL_FLAG.eq("0"))
.and(QueryMethods.findInSet(QueryMethods.number(deptId),SYS_DEPT.ANCESTORS).gt(0));
return deptMapper.selectObjectByQueryAs(queryWrapper,Integer.class);
}
/**
@ -143,21 +186,16 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
*/
@Override
public boolean hasChildByDeptId(Long deptId) {
int result = deptMapper.hasChildByDeptId(deptId);
QueryWrapper queryWrapper = QueryWrapper.create()
.select(QueryMethods.count(SYS_DEPT.DEPT_ID))
.from(SYS_DEPT)
.where(SYS_DEPT.DEL_FLAG.eq("0"))
.and(SYS_DEPT.PARENT_ID.eq(deptId));
int result = deptMapper.selectObjectByQueryAs(queryWrapper,Integer.class);
return result > 0;
}
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
@Override
public boolean checkDeptExistUser(Long deptId) {
int result = deptMapper.checkDeptExistUser(deptId);
return result > 0;
}
/**
* 校验部门名称是否唯一
@ -166,9 +204,14 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @return 结果
*/
@Override
public boolean checkDeptNameUnique(SysDept dept) {
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
public boolean checkDeptNameUnique(SysDeptBo dept) {
Long deptId = ObjectUtil.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
QueryWrapper queryWrapper = query().where(SYS_DEPT.DEL_FLAG.eq("0"));
queryWrapper.and(SYS_DEPT.DEPT_NAME.eq(dept.getDeptName()));
queryWrapper.and(SYS_DEPT.PARENT_ID.eq(dept.getParentId()));
SysDeptVo info = this.getOneAs(queryWrapper, SysDeptVo.class);
if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) {
return UserConstants.NOT_UNIQUE;
}
@ -189,9 +232,9 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
return;
}
SysDept dept = new SysDept();
SysDeptBo dept = new SysDeptBo();
dept.setDeptId(deptId);
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
List<SysDeptVo> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
if (ObjectUtil.isNull(depts)) {
throw new ServiceException("没有权限访问部门数据!");
}
@ -200,37 +243,42 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
/**
* 新增保存部门信息
*
* @param dept 部门信息
* @return 结果
* @param deptBo 部门信息
* @return 受影响的行数
*/
@Override
public int insertDept(SysDept dept) {
SysDept info = deptMapper.selectDeptById(dept.getParentId());
public int insertDept(SysDeptBo deptBo) {
SysDeptVo info = selectDeptById(deptBo.getParentId());
// 如果父节点不为正常状态,则不允许新增子节点
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
throw new ServiceException("部门停用,不允许新增");
}
SysDept dept = MapstructUtils.convert(deptBo, SysDept.class);
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept);
dept.setDelFlag("0");//0代表存在
return deptMapper.insert(dept, false);
}
/**
* 修改保存部门信息
*
* @param dept 部门信息
* @return 结果
* @param deptBo 部门信息
* @return 结果:true 更新成功false 更新失败
*/
@Transactional
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#deptBo.deptId")
@Override
public int updateDept(SysDept dept) {
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
public boolean updateDept(SysDeptBo deptBo) {
SysDept dept = MapstructUtils.convert(deptBo, SysDept.class);
SysDeptVo newParentDept = selectDeptById(dept.getParentId());
SysDeptVo oldDept = selectDeptById(dept.getDeptId());
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
String oldAncestors = oldDept.getAncestors();
dept.setAncestors(newAncestors);
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
}
int result = deptMapper.updateDept(dept);
boolean result = this.updateById(dept);
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
&& !StringUtils.equals("0", dept.getAncestors())) {
// 如果该部门是启用状态则启用该部门的所有上级部门
@ -247,7 +295,11 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
private void updateParentDeptStatusNormal(SysDept dept) {
String ancestors = dept.getAncestors();
Long[] deptIds = Convert.toLongArray(ancestors);
deptMapper.updateDeptStatusNormal(deptIds);
UpdateChain.of(SysDept.class)
.set(SysDept::getStatus, "0")
.where(SysDept::getDeptId).in(deptIds)
.update();
}
/**
@ -258,13 +310,22 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @param oldAncestors 旧的父ID集合
*/
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
for (SysDept child : children) {
//select * from sys_dept where find_in_set(#{deptId}, ancestors)
QueryWrapper queryWrapper = QueryWrapper.create()
.from(SYS_DEPT)
.where(QueryMethods.findInSet(QueryMethods.number(deptId),SYS_DEPT.ANCESTORS).gt(0));
List<SysDeptVo> children = this.listAs(queryWrapper, SysDeptVo.class);
for (SysDeptVo child : children) {
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
UpdateChain.of(SysDept.class)
.set(SysDept::getAncestors, child.getAncestors())
.where(SysDept::getDeptId).eq(child.getDeptId())
.update();
}
if (children.size() > 0) {
deptMapper.updateDeptChildren(children);
}
return;
}
/**
@ -274,45 +335,49 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
* @return 结果
*/
@Override
public int deleteDeptById(Long deptId) {
return deptMapper.deleteDeptById(deptId);
public boolean deleteDeptById(Long deptId) {
//update sys_dept set del_flag = '1' where dept_id = #{deptId}
SysDept sysDept = new SysDept();
sysDept.setDeptId(deptId);
sysDept.setDelFlag("1");
return this.updateById(sysDept);
}
/**
* 递归列表
*/
private void recursionFn(List<SysDept> list, SysDept t) {
// 得到子节点列表
List<SysDept> childList = getChildList(list, t);
t.setChildren(childList);
for (SysDept tChild : childList) {
if (hasChild(list, tChild)) {
recursionFn(list, tChild);
}
}
}
/**
* 得到子节点列表
*/
private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
List<SysDept> tlist = new ArrayList<>();
Iterator<SysDept> it = list.iterator();
while (it.hasNext()) {
SysDept n = (SysDept) it.next();
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) {
tlist.add(n);
}
}
return tlist;
}
/**
* 判断是否有子节点
*/
private boolean hasChild(List<SysDept> list, SysDept t) {
return getChildList(list, t).size() > 0;
}
// /**
// * 递归列表
// */
// private void recursionFn(List<SysDept> list, SysDept t) {
// // 得到子节点列表
// List<SysDept> childList = getChildList(list, t);
// t.setChildren(childList);
// for (SysDept tChild : childList) {
// if (hasChild(list, tChild)) {
// recursionFn(list, tChild);
// }
// }
// }
//
// /**
// * 得到子节点列表
// */
// private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
// List<SysDept> tlist = new ArrayList<>();
// Iterator<SysDept> it = list.iterator();
// while (it.hasNext()) {
// SysDept n = (SysDept) it.next();
// if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) {
// tlist.add(n);
// }
// }
// return tlist;
// }
//
// /**
// * 判断是否有子节点
// */
// private boolean hasChild(List<SysDept> list, SysDept t) {
// return getChildList(list, t).size() > 0;
// }
/**
* 通过部门ID查询部门名称
@ -324,7 +389,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
public String selectDeptNameByIds(String deptIds) {
List<String> list = new ArrayList<>();
for (Long id : StringUtils.splitTo(deptIds, Convert::toLong)) {
SysDept dept = SpringUtils.getAopProxy(this).selectDeptById(id);
SysDeptVo dept = SpringUtils.getAopProxy(this).selectDeptById(id);
if (ObjectUtil.isNotNull(dept)) {
list.add(dept.getDeptName());
}

View File

@ -3,6 +3,7 @@ package com.ruoyi.system.service.impl;
import java.util.Arrays;
import java.util.List;
import cn.hutool.core.util.ObjectUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.core.core.page.PageDomain;
@ -65,7 +66,7 @@ public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNo
if (StringUtils.isNotEmpty(noticeBo.getNoticeType())) {
queryWrapper.and(SYS_NOTICE.NOTICE_TYPE.eq(noticeBo.getNoticeType()));
}
if (StringUtils.isNotNull(noticeBo.getCreateBy())) {
if (ObjectUtil.isNotNull(noticeBo.getCreateBy())) {
queryWrapper.and(SYS_NOTICE.CREATE_BY.like(noticeBo.getCreateBy()));
}

View File

@ -6,12 +6,16 @@ import java.util.stream.Collectors;
import cn.dev33.satoken.secure.BCrypt;
import cn.hutool.core.util.ObjectUtil;
import com.mybatisflex.core.query.QueryMethods;
import com.mybatisflex.core.query.QueryWrapper;
import com.ruoyi.common.core.constant.CacheNames;
import com.ruoyi.common.core.service.UserService;
import com.ruoyi.common.core.utils.MapstructUtils;
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
import com.ruoyi.common.security.utils.LoginHelper;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.bo.SysUserBo;
import com.ruoyi.system.mapper.*;
import jakarta.annotation.Resource;
import jakarta.validation.Validator;
import org.slf4j.Logger;
@ -26,21 +30,19 @@ import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.utils.bean.BeanValidators;
import com.ruoyi.common.core.utils.SpringUtils;
import com.ruoyi.system.mapper.SysPostMapper;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.mapper.SysUserPostMapper;
import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.system.service.ISysConfigService;
import com.ruoyi.system.service.ISysUserService;
import static com.ruoyi.system.domain.table.SysDeptTableDef.SYS_DEPT;
import static com.ruoyi.system.domain.table.SysUserTableDef.SYS_USER;
/**
* 用户 业务层处理
*
* @author ruoyi
*/
@Service
public class SysUserServiceImpl implements ISysUserService, UserService {
public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser> implements ISysUserService, UserService {
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
@Resource
@ -234,6 +236,24 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
}
}
/**
* 查询部门是否存在用户
*
* @param deptId 部门ID
* @return 结果 true 存在 false 不存在
*/
@Override
public boolean checkDeptExistUser(Long deptId) {
QueryWrapper queryWrapper = QueryWrapper.create()
.select(QueryMethods.count(SYS_USER.USER_ID))
.from(SYS_USER)
.where(SYS_USER.DEPT_ID.eq(deptId))
.and(SYS_USER.DEL_FLAG.eq("0"));
int result = userMapper.selectObjectByQueryAs(queryWrapper,Integer.class);
return result > 0;
}
/**
* 新增保存用户信息
*

View File

@ -21,32 +21,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
from sys_dept d
</sql>
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
<include refid="selectDeptVo"/>
where d.del_flag = '0'
<if test="deptId != null and deptId != 0">
AND dept_id = #{deptId}
</if>
<if test="parentId != null and parentId != 0">
AND parent_id = #{parentId}
</if>
<if test="deptName != null and deptName != ''">
AND dept_name like concat('%', #{deptName}, '%')
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
<!-- 数据范围过滤 -->
${params.dataScope}
order by d.parent_id, d.order_num
</select>
<!-- <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">-->
<!-- <include refid="selectDeptVo"/>-->
<!-- where d.del_flag = '0'-->
<!-- <if test="deptId != null and deptId != 0">-->
<!-- AND dept_id = #{deptId}-->
<!-- </if>-->
<!-- <if test="parentId != null and parentId != 0">-->
<!-- AND parent_id = #{parentId}-->
<!-- </if>-->
<!-- <if test="deptName != null and deptName != ''">-->
<!-- AND dept_name like concat('%', #{deptName}, '%')-->
<!-- </if>-->
<!-- <if test="status != null and status != ''">-->
<!-- AND status = #{status}-->
<!-- </if>-->
<!-- &lt;!&ndash; 数据范围过滤 &ndash;&gt;-->
<!-- ${params.dataScope}-->
<!-- order by d.parent_id, d.order_num-->
<!-- </select>-->
<select id="selectDeptListByRoleId" resultType="Long">
select d.dept_id
from sys_dept d
@ -57,103 +57,103 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
order by d.parent_id, d.order_num
</select>
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
from sys_dept d
where d.dept_id = #{deptId}
</select>
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
</select>
<select id="hasChildByDeptId" parameterType="Long" resultType="int">
select count(1) from sys_dept
where del_flag = '0' and parent_id = #{deptId} limit 1
</select>
<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
select * from sys_dept where find_in_set(#{deptId}, ancestors)
</select>
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors)
</select>
<select id="checkDeptNameUnique" resultMap="SysDeptResult">
<include refid="selectDeptVo"/>
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
</select>
<insert id="insertDept" parameterType="SysDept">
insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="parentId != null and parentId != 0">parent_id,</if>
<if test="deptName != null and deptName != ''">dept_name,</if>
<if test="ancestors != null and ancestors != ''">ancestors,</if>
<if test="orderNum != null">order_num,</if>
<if test="leader != null and leader != ''">leader,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="email != null and email != ''">email,</if>
<if test="status != null">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="deptId != null and deptId != 0">#{deptId},</if>
<if test="parentId != null and parentId != 0">#{parentId},</if>
<if test="deptName != null and deptName != ''">#{deptName},</if>
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="leader != null and leader != ''">#{leader},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<update id="updateDept" parameterType="SysDept">
update sys_dept
<set>
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="leader != null">leader = #{leader},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="email != null">email = #{email},</if>
<if test="status != null and status != ''">status = #{status},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where dept_id = #{deptId}
</update>
<update id="updateDeptChildren" parameterType="java.util.List">
update sys_dept set ancestors =
<foreach collection="depts" item="item" index="index"
separator=" " open="case dept_id" close="end">
when #{item.deptId} then #{item.ancestors}
</foreach>
where dept_id in
<foreach collection="depts" item="item" index="index"
separator="," open="(" close=")">
#{item.deptId}
</foreach>
</update>
<update id="updateDeptStatusNormal" parameterType="Long">
update sys_dept set status = '0' where dept_id in
<foreach collection="array" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
</update>
<delete id="deleteDeptById" parameterType="Long">
update sys_dept set del_flag = '1' where dept_id = #{deptId}
</delete>
</mapper>
<!-- <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">-->
<!-- select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status,-->
<!-- (select dept_name from sys_dept where dept_id = d.parent_id) parent_name-->
<!-- from sys_dept d-->
<!-- where d.dept_id = #{deptId}-->
<!-- </select>-->
<!-- <select id="checkDeptExistUser" parameterType="Long" resultType="int">-->
<!-- select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'-->
<!-- </select>-->
<!-- <select id="hasChildByDeptId" parameterType="Long" resultType="int">-->
<!-- select count(1) from sys_dept-->
<!-- where del_flag = '0' and parent_id = #{deptId} limit 1-->
<!-- </select>-->
<!-- <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">-->
<!-- select * from sys_dept where find_in_set(#{deptId}, ancestors)-->
<!-- </select>-->
<!-- <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">-->
<!-- select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors)-->
<!-- </select>-->
<!-- <select id="checkDeptNameUnique" resultMap="SysDeptResult">-->
<!-- <include refid="selectDeptVo"/>-->
<!-- where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1-->
<!-- </select>-->
<!-- <insert id="insertDept" parameterType="SysDept">-->
<!-- insert into sys_dept(-->
<!-- <if test="deptId != null and deptId != 0">dept_id,</if>-->
<!-- <if test="parentId != null and parentId != 0">parent_id,</if>-->
<!-- <if test="deptName != null and deptName != ''">dept_name,</if>-->
<!-- <if test="ancestors != null and ancestors != ''">ancestors,</if>-->
<!-- <if test="orderNum != null">order_num,</if>-->
<!-- <if test="leader != null and leader != ''">leader,</if>-->
<!-- <if test="phone != null and phone != ''">phone,</if>-->
<!-- <if test="email != null and email != ''">email,</if>-->
<!-- <if test="status != null">status,</if>-->
<!-- <if test="createBy != null and createBy != ''">create_by,</if>-->
<!-- create_time-->
<!-- )values(-->
<!-- <if test="deptId != null and deptId != 0">#{deptId},</if>-->
<!-- <if test="parentId != null and parentId != 0">#{parentId},</if>-->
<!-- <if test="deptName != null and deptName != ''">#{deptName},</if>-->
<!-- <if test="ancestors != null and ancestors != ''">#{ancestors},</if>-->
<!-- <if test="orderNum != null">#{orderNum},</if>-->
<!-- <if test="leader != null and leader != ''">#{leader},</if>-->
<!-- <if test="phone != null and phone != ''">#{phone},</if>-->
<!-- <if test="email != null and email != ''">#{email},</if>-->
<!-- <if test="status != null">#{status},</if>-->
<!-- <if test="createBy != null and createBy != ''">#{createBy},</if>-->
<!-- sysdate()-->
<!-- )-->
<!-- </insert>-->
<!-- <update id="updateDept" parameterType="SysDept">-->
<!-- update sys_dept-->
<!-- <set>-->
<!-- <if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>-->
<!-- <if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>-->
<!-- <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>-->
<!-- <if test="orderNum != null">order_num = #{orderNum},</if>-->
<!-- <if test="leader != null">leader = #{leader},</if>-->
<!-- <if test="phone != null">phone = #{phone},</if>-->
<!-- <if test="email != null">email = #{email},</if>-->
<!-- <if test="status != null and status != ''">status = #{status},</if>-->
<!-- <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>-->
<!-- update_time = sysdate()-->
<!-- </set>-->
<!-- where dept_id = #{deptId}-->
<!-- </update>-->
<!-- <update id="updateDeptChildren" parameterType="java.util.List">-->
<!-- update sys_dept set ancestors =-->
<!-- <foreach collection="depts" item="item" index="index"-->
<!-- separator=" " open="case dept_id" close="end">-->
<!-- when #{item.deptId} then #{item.ancestors}-->
<!-- </foreach>-->
<!-- where dept_id in-->
<!-- <foreach collection="depts" item="item" index="index"-->
<!-- separator="," open="(" close=")">-->
<!-- #{item.deptId}-->
<!-- </foreach>-->
<!-- </update>-->
<!-- <update id="updateDeptStatusNormal" parameterType="Long">-->
<!-- update sys_dept set status = '0' where dept_id in-->
<!-- <foreach collection="array" item="deptId" open="(" separator="," close=")">-->
<!-- #{deptId}-->
<!-- </foreach>-->
<!-- </update>-->
<!-- <delete id="deleteDeptById" parameterType="Long">-->
<!-- update sys_dept set del_flag = '1' where dept_id = #{deptId}-->
<!-- </delete>-->
</mapper>

View File

@ -13,7 +13,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="userType" column="user_type" />
<result property="email" column="email" />
<result property="phonenumber" column="phonenumber" />
<result property="sex" column="sex" />
<result property="gender" column="gender" />
<result property="avatar" column="avatar" />
<result property="password" column="password" />
<result property="status" column="status" />
@ -49,7 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectUserVo">
select u.user_id, u.tenant_id,u.dept_id, u.user_name, u.nick_name, u.user_type, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
select u.user_id, u.tenant_id,u.dept_id, u.user_name, u.nick_name, u.user_type, u.email, u.avatar, u.phonenumber, u.password, u.gender, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
from sys_user u
@ -59,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
select u.user_id, u.tenant_id, u.dept_id, u.nick_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
select u.user_id, u.tenant_id, u.dept_id, u.nick_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.gender, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
where u.del_flag = '0'
<if test="userId != null and userId != 0">
@ -157,7 +157,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null and email != ''">email,</if>
<if test="avatar != null and avatar != ''">avatar,</if>
<if test="phonenumber != null and phonenumber != ''">phonenumber,</if>
<if test="sex != null and sex != ''">sex,</if>
<if test="gender != null and gender != ''">gender,</if>
<if test="password != null and password != ''">password,</if>
<if test="status != null and status != ''">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
@ -171,7 +171,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="email != null and email != ''">#{email},</if>
<if test="avatar != null and avatar != ''">#{avatar},</if>
<if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if>
<if test="sex != null and sex != ''">#{sex},</if>
<if test="gender != null and gender != ''">#{gender},</if>
<if test="password != null and password != ''">#{password},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
@ -188,7 +188,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
<if test="email != null ">email = #{email},</if>
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
<if test="sex != null and sex != ''">sex = #{sex},</if>
<if test="gender != null and gender != ''">gender = #{gender},</if>
<if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
<if test="password != null and password != ''">password = #{password},</if>
<if test="status != null and status != ''">status = #{status},</if>

View File

@ -20,7 +20,7 @@
<el-form-item label="客户性别" prop="sex">
<el-select v-model="queryParams.sex" placeholder="请选择客户性别" clearable>
<el-option
v-for="dict in sys_user_sex"
v-for="dict in sys_user_gender"
:key="dict.value"
:label="dict.label"
:value="dict.value"
@ -91,7 +91,7 @@
<el-table-column label="手机号码" align="center" prop="phonenumber" />
<el-table-column label="客户性别" align="center" prop="sex">
<template #default="scope">
<dict-tag :options="sys_user_sex" :value="scope.row.sex"/>
<dict-tag :options="sys_user_gender" :value="scope.row.sex"/>
</template>
</el-table-column>
<el-table-column label="客户生日" align="center" prop="birthday" width="180">
@ -138,7 +138,7 @@
<el-form-item label="客户性别" prop="sex">
<el-select v-model="form.sex" placeholder="请选择客户性别">
<el-option
v-for="dict in sys_user_sex"
v-for="dict in sys_user_gender"
:key="dict.value"
:label="dict.label"
:value="dict.value"
@ -216,7 +216,7 @@
<script setup>
import { listCustomer, getCustomer, delCustomer, addCustomer, updateCustomer } from "@/api/demo/customer";
const { proxy } = getCurrentInstance();
const {sys_goods_type, sys_user_sex } = proxy.useDict('sys_goods_type', 'sys_user_sex');
const {sys_goods_type, sys_user_gender } = proxy.useDict('sys_goods_type', 'sys_user_gender');
//
const loading = ref(true);

View File

@ -77,7 +77,7 @@
</el-table-column>
<el-table-column label="性别" align="center" prop="studentSex">
<template #default="scope">
<dict-tag :options="sys_user_sex" :value="scope.row.studentSex"/>
<dict-tag :options="sys_user_gender" :value="scope.row.studentSex"/>
</template>
</el-table-column>
<el-table-column label="状态" align="center" prop="studentStatus">
@ -138,7 +138,7 @@
<el-form-item label="性别" prop="studentSex">
<el-select v-model="form.studentSex" placeholder="请选择性别">
<el-option
v-for="dict in sys_user_sex"
v-for="dict in sys_user_gender"
:key="dict.value"
:label="dict.label"
:value="dict.value"
@ -179,7 +179,7 @@ import { listStudent, getStudent, delStudent, addStudent, updateStudent } from "
const router = useRouter();
const { proxy } = getCurrentInstance();
const { sys_student_hobby, sys_user_sex, sys_student_status } = proxy.useDict("sys_student_hobby", "sys_user_sex","sys_student_status");
const { sys_student_hobby, sys_user_gender, sys_student_status } = proxy.useDict("sys_student_hobby", "sys_user_gender","sys_student_status");
//

View File

@ -249,7 +249,7 @@
<el-form-item label="用户性别">
<el-select v-model="form.sex" placeholder="请选择">
<el-option
v-for="dict in sys_user_sex"
v-for="dict in sys_user_gender"
:key="dict.value"
:label="dict.label"
:value="dict.value"
@ -355,7 +355,7 @@ import { getToken } from "@/utils/auth";
const router = useRouter();
const { proxy } = getCurrentInstance();
const { sys_normal_disable, sys_user_sex } = proxy.useDict("sys_normal_disable", "sys_user_sex");
const { sys_normal_disable, sys_user_gender } = proxy.useDict("sys_normal_disable", "sys_user_gender");
const userList = ref([]);
const open = ref(false);