用户修改
This commit is contained in:
parent
e45bcd2901
commit
13f99d6687
@ -11,6 +11,7 @@ import com.xinelu.common.enums.BusinessType;
|
||||
import com.xinelu.common.utils.SecurityUtils;
|
||||
import com.xinelu.common.utils.StringUtils;
|
||||
import com.xinelu.common.utils.poi.ExcelUtil;
|
||||
import com.xinelu.system.domain.vo.AgencyNameVO;
|
||||
import com.xinelu.system.service.ISysPostService;
|
||||
import com.xinelu.system.service.ISysRoleService;
|
||||
import com.xinelu.system.service.ISysUserService;
|
||||
@ -205,4 +206,22 @@ public class SysUserController extends BaseController {
|
||||
userService.insertUserAuth(userId, roleIds);
|
||||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 剩余机构查询
|
||||
*/
|
||||
@GetMapping("/selectUserAgency")
|
||||
public TableDataInfo selectUserAgency(String userName, String agencyName) {
|
||||
return userService.selectUserAgency(userName, agencyName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 所属机构查询
|
||||
*/
|
||||
@GetMapping("/selectUserBelongAgency")
|
||||
public TableDataInfo selectUserBelongAgency(String userName) {
|
||||
startPage();
|
||||
List<AgencyNameVO> list = userService.selectUserBelongAgency(userName);
|
||||
return getDataTable(list);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.xinelu.common.core.domain.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xinelu.common.annotation.Excel;
|
||||
import com.xinelu.common.annotation.Excel.ColumnType;
|
||||
import com.xinelu.common.annotation.Excel.Type;
|
||||
@ -127,6 +128,22 @@ public class SysUser extends BaseEntity {
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
/**
|
||||
* 角色身份证号
|
||||
*/
|
||||
private String userCardNo;
|
||||
|
||||
/**
|
||||
* 角色出生日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private Date userBirthDate;
|
||||
|
||||
/**
|
||||
* 机构id
|
||||
*/
|
||||
private Long agencyId;
|
||||
|
||||
public SysUser() {
|
||||
|
||||
}
|
||||
@ -143,6 +160,14 @@ public class SysUser extends BaseEntity {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public Long getAgencyId() {
|
||||
return agencyId;
|
||||
}
|
||||
|
||||
public void setAgencyId(Long agencyId) {
|
||||
this.agencyId = agencyId;
|
||||
}
|
||||
|
||||
public boolean isAdmin() {
|
||||
return isAdmin(this.userId);
|
||||
}
|
||||
@ -295,6 +320,22 @@ public class SysUser extends BaseEntity {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getUserCardNo() {
|
||||
return userCardNo;
|
||||
}
|
||||
|
||||
public void setUserCardNo(String userCardNo) {
|
||||
this.userCardNo = userCardNo;
|
||||
}
|
||||
|
||||
public Date getUserBirthDate() {
|
||||
return userBirthDate;
|
||||
}
|
||||
|
||||
public void setUserBirthDate(Date userBirthDate) {
|
||||
this.userBirthDate = userBirthDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
package com.xinelu.common.utils;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import com.xinelu.common.constant.HttpStatus;
|
||||
import com.xinelu.common.core.page.TableDataInfo;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description 业务层分页工具类
|
||||
* @Author 纪寒
|
||||
* @Date 2022-08-08 11:03:27
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Component
|
||||
public class PageServiceUtil {
|
||||
|
||||
/**
|
||||
* 设置请求分页数据
|
||||
*/
|
||||
public void startPage() {
|
||||
PageUtils.startPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 响应请求分页数据
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public TableDataInfo getDataTable(List<?> list) {
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.SUCCESS);
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(list);
|
||||
rspData.setTotal(new PageInfo(list).getTotal());
|
||||
return rspData;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package com.xinelu.system.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户机构信息对象vo agency
|
||||
*
|
||||
* @author xinelu
|
||||
* @date 2024-02-26
|
||||
*/
|
||||
@Data
|
||||
public class AgencyNameVO {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long agencyId;
|
||||
|
||||
/**
|
||||
* 机构名称
|
||||
*/
|
||||
private String agencyName;
|
||||
|
||||
/**
|
||||
* 机构代码
|
||||
*/
|
||||
private String agencyCode;
|
||||
|
||||
/**
|
||||
* 机构数量
|
||||
*/
|
||||
private Integer agencyNum;
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package com.xinelu.system.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户机构信息对象vo agency
|
||||
*
|
||||
* @author xinelu
|
||||
* @date 2024-02-26
|
||||
*/
|
||||
@Data
|
||||
public class UserAgencyVO {
|
||||
|
||||
|
||||
/**
|
||||
* 机构
|
||||
*/
|
||||
private List<AgencyNameVO> agencyList;
|
||||
|
||||
/**
|
||||
* 机构数量
|
||||
*/
|
||||
private Integer agencyNum;
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package com.xinelu.system.mapper;
|
||||
|
||||
import com.xinelu.common.core.domain.entity.SysUser;
|
||||
import com.xinelu.system.domain.vo.AgencyNameVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
@ -124,4 +125,8 @@ public interface SysUserMapper {
|
||||
* @return 结果
|
||||
*/
|
||||
public SysUser checkEmailUnique(String email);
|
||||
|
||||
List<AgencyNameVO> selectAgencyList(String agencyName);
|
||||
|
||||
List<AgencyNameVO> selectBelongAgencyList(Long agencyId);
|
||||
}
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
package com.xinelu.system.service;
|
||||
|
||||
import com.xinelu.common.core.domain.AjaxResult;
|
||||
import com.xinelu.common.core.domain.entity.SysUser;
|
||||
import com.xinelu.common.core.page.TableDataInfo;
|
||||
import com.xinelu.system.domain.vo.AgencyNameVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -203,4 +206,20 @@ public interface ISysUserService {
|
||||
* @return 结果
|
||||
*/
|
||||
public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName);
|
||||
|
||||
/**
|
||||
* 所属机构查询
|
||||
*
|
||||
* @param userName 用户账号
|
||||
* @return AjaxResult
|
||||
*/
|
||||
TableDataInfo selectUserAgency(String userName, String agencyName);
|
||||
|
||||
/**
|
||||
* 所属机构查询
|
||||
*
|
||||
* @param userName 用户账号
|
||||
* @return AjaxResult
|
||||
*/
|
||||
List<AgencyNameVO> selectUserBelongAgency(String userName);
|
||||
}
|
||||
|
||||
@ -4,7 +4,9 @@ import com.xinelu.common.annotation.DataScope;
|
||||
import com.xinelu.common.constant.UserConstants;
|
||||
import com.xinelu.common.core.domain.entity.SysRole;
|
||||
import com.xinelu.common.core.domain.entity.SysUser;
|
||||
import com.xinelu.common.core.page.TableDataInfo;
|
||||
import com.xinelu.common.exception.ServiceException;
|
||||
import com.xinelu.common.utils.PageServiceUtil;
|
||||
import com.xinelu.common.utils.SecurityUtils;
|
||||
import com.xinelu.common.utils.StringUtils;
|
||||
import com.xinelu.common.utils.bean.BeanValidators;
|
||||
@ -12,19 +14,21 @@ import com.xinelu.common.utils.spring.SpringUtils;
|
||||
import com.xinelu.system.domain.SysPost;
|
||||
import com.xinelu.system.domain.SysUserPost;
|
||||
import com.xinelu.system.domain.SysUserRole;
|
||||
import com.xinelu.system.domain.vo.AgencyNameVO;
|
||||
import com.xinelu.system.mapper.*;
|
||||
import com.xinelu.system.service.ISysConfigService;
|
||||
import com.xinelu.system.service.ISysUserService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Validator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -57,6 +61,9 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
@Resource
|
||||
protected Validator validator;
|
||||
|
||||
@Resource
|
||||
private PageServiceUtil pageServiceUtil;
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
@ -480,4 +487,39 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
}
|
||||
return successMsg.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 剩余机构查询
|
||||
*
|
||||
* @param userName 用户账号
|
||||
* @return AjaxResult
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo selectUserAgency(String userName, String agencyName) {
|
||||
pageServiceUtil.startPage();
|
||||
List<AgencyNameVO> agencyList = userMapper.selectAgencyList(agencyName);
|
||||
if (CollectionUtils.isNotEmpty(agencyList)) {
|
||||
SysUser sysUser = userMapper.selectUserByUserName(userName);
|
||||
if (Objects.nonNull(sysUser) && Objects.nonNull(sysUser.getAgencyId())) {
|
||||
List<AgencyNameVO> collect = agencyList.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getAgencyId()) && sysUser.getAgencyId().equals(item.getAgencyId())).collect(Collectors.toList());
|
||||
agencyList.removeAll(collect);
|
||||
}
|
||||
}
|
||||
return pageServiceUtil.getDataTable(agencyList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 所属机构查询
|
||||
*
|
||||
* @param userName 用户账号
|
||||
* @return AjaxResult
|
||||
*/
|
||||
@Override
|
||||
public List<AgencyNameVO> selectUserBelongAgency(String userName) {
|
||||
SysUser sysUser = userMapper.selectUserByUserName(userName);
|
||||
if (Objects.nonNull(sysUser) && Objects.nonNull(sysUser.getAgencyId())) {
|
||||
return userMapper.selectBelongAgencyList(sysUser.getAgencyId());
|
||||
}
|
||||
return new ArrayList<AgencyNameVO>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,6 +23,8 @@
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="userCardNo" column="user_card_no"/>
|
||||
<result property="userBirthDate" column="user_birth_date"/>
|
||||
<association property="dept" column="dept_id" javaType="SysDept" resultMap="deptResult"/>
|
||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult"/>
|
||||
</resultMap>
|
||||
@ -47,8 +49,8 @@
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectUserVo">
|
||||
select u.user_id, u.dept_id, u.user_name, u.nick_name, 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,
|
||||
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
||||
select u.user_id, u.dept_id, u.user_name, u.nick_name, 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,
|
||||
u.user_card_no,u.user_birth_date,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
|
||||
left join sys_dept d on u.dept_id = d.dept_id
|
||||
@ -58,7 +60,7 @@
|
||||
|
||||
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
select u.user_id, u.dept_id, u.nick_name, u.user_name, 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.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.user_card_no,u.user_birth_date, 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'
|
||||
@ -71,6 +73,12 @@
|
||||
<if test="status != null and status != ''">
|
||||
AND u.status = #{status}
|
||||
</if>
|
||||
<if test="userCardNo != null and userCardNo != ''">
|
||||
AND u.user_card_no = #{userCardNo}
|
||||
</if>
|
||||
<if test="userBirthDate != null">
|
||||
AND u.user_birth_date = #{userBirthDate}
|
||||
</if>
|
||||
<if test="phonenumber != null and phonenumber != ''">
|
||||
AND u.phonenumber like concat('%', #{phonenumber}, '%')
|
||||
</if>
|
||||
@ -160,6 +168,8 @@
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="userCardNo != null and userCardNo != ''">user_card_no,</if>
|
||||
<if test="userBirthDate != null">user_birth_date,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
@ -174,6 +184,8 @@
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="userCardNo != null and userCardNo != ''">#{userCardNo},</if>
|
||||
<if test="userBirthDate != null">#{userBirthDate},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
@ -194,6 +206,8 @@
|
||||
<if test="loginDate != null">login_date = #{loginDate},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
<if test="userCardNo != null and userCardNo != ''"> user_card_no = #{userCardNo},</if>
|
||||
<if test="userBirthDate != null">user_birth_date = #{userBirthDate},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where user_id = #{userId}
|
||||
@ -222,4 +236,31 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectAgencyList" resultType="com.xinelu.system.domain.vo.AgencyNameVO">
|
||||
select id agencyId,
|
||||
agency_name,
|
||||
agency_code,
|
||||
(select COUNT(1)
|
||||
from agency
|
||||
where 1 = 1
|
||||
<if test="agencyName != null and agencyName != ''">
|
||||
and agency_name = #{agencyName}
|
||||
or agency_code = #{agencyName}
|
||||
</if>
|
||||
) as agencyNum
|
||||
from agency
|
||||
where 1 = 1
|
||||
<if test="agencyName != null and agencyName != ''">
|
||||
and agency_name = #{agencyName}
|
||||
or agency_code = #{agencyName}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectBelongAgencyList" resultType="com.xinelu.system.domain.vo.AgencyNameVO">
|
||||
select id agencyId,
|
||||
agency_name,
|
||||
agency_code
|
||||
from agency
|
||||
where id = #{agencyId}
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user