新增用户拓展属性字段

This commit is contained in:
wanggeng 2022-01-22 20:37:54 +08:00
parent 630211df12
commit f979cc9a7c
7 changed files with 414 additions and 12 deletions

View File

@ -18,6 +18,13 @@ public class UserExpandDTO extends UserDTO {
private String areaCode;
private String areaName;
private Integer userLevel;
private String userSex;
private String userSexName;
private String userBirth;
private String userEducation;
private String userEducationName;
private String userPolitic;
private String userPoliticName;
private List<DepartmentDTO> departments;
public void setUserDTO(UserDTO userDTO) {
@ -48,6 +55,62 @@ public class UserExpandDTO extends UserDTO {
this.userLevel = userLevel;
}
public String getUserSex() {
return userSex == null ? "" : userSex.trim();
}
public void setUserSex(String userSex) {
this.userSex = userSex;
}
public String getUserSexName() {
return userSexName == null ? "" : userSexName.trim();
}
public void setUserSexName(String userSexName) {
this.userSexName = userSexName;
}
public String getUserBirth() {
return userBirth == null ? "" : userBirth.trim();
}
public void setUserBirth(String userBirth) {
this.userBirth = userBirth;
}
public String getUserEducation() {
return userEducation == null ? "" : userEducation.trim();
}
public void setUserEducation(String userEducation) {
this.userEducation = userEducation;
}
public String getUserEducationName() {
return userEducationName == null ? "" : userEducationName.trim();
}
public void setUserEducationName(String userEducationName) {
this.userEducationName = userEducationName;
}
public String getUserPolitic() {
return userPolitic == null ? "" : userPolitic.trim();
}
public void setUserPolitic(String userPolitic) {
this.userPolitic = userPolitic;
}
public String getUserPoliticName() {
return userPoliticName == null ? "" : userPoliticName.trim();
}
public void setUserPoliticName(String userPoliticName) {
this.userPoliticName = userPoliticName;
}
public List<DepartmentDTO> getDepartments() {
return departments == null ? new ArrayList<>() : departments;
}

View File

@ -13,6 +13,13 @@ public class UserExpandPO {
private String areaCode;
private String areaName;
private Integer userLevel;
private String userSex;
private String userSexName;
private String userBirth;
private String userEducation;
private String userEducationName;
private String userPolitic;
private String userPoliticName;
private String creator;
private String gmtCreate;
private String modifier;
@ -50,6 +57,62 @@ public class UserExpandPO {
this.userLevel = userLevel;
}
public String getUserSex() {
return userSex == null ? "" : userSex.trim();
}
public void setUserSex(String userSex) {
this.userSex = userSex;
}
public String getUserSexName() {
return userSexName == null ? "" : userSexName.trim();
}
public void setUserSexName(String userSexName) {
this.userSexName = userSexName;
}
public String getUserBirth() {
return userBirth == null ? "" : userBirth.trim();
}
public void setUserBirth(String userBirth) {
this.userBirth = userBirth;
}
public String getUserEducation() {
return userEducation == null ? "" : userEducation.trim();
}
public void setUserEducation(String userEducation) {
this.userEducation = userEducation;
}
public String getUserEducationName() {
return userEducationName == null ? "" : userEducationName.trim();
}
public void setUserEducationName(String userEducationName) {
this.userEducationName = userEducationName;
}
public String getUserPolitic() {
return userPolitic == null ? "" : userPolitic.trim();
}
public void setUserPolitic(String userPolitic) {
this.userPolitic = userPolitic;
}
public String getUserPoliticName() {
return userPoliticName == null ? "" : userPoliticName.trim();
}
public void setUserPoliticName(String userPoliticName) {
this.userPoliticName = userPoliticName;
}
public String getCreator() {
return creator == null ? "" : creator.trim();
}

View File

@ -23,6 +23,10 @@ public class UserExpandVO {
@ApiModelProperty(name = "userLevel", value = "用户级别")
@CheckEmptyAnnotation(name = "用户级别")
private Integer userLevel;
private String userSex;
private String userBirth;
private String userEducation;
private String userPolitic;
public String getAreaCode() {
return areaCode == null ? "" : areaCode.trim();
@ -47,4 +51,36 @@ public class UserExpandVO {
public void setUserLevel(Integer userLevel) {
this.userLevel = userLevel;
}
public String getUserSex() {
return userSex == null ? "" : userSex.trim();
}
public void setUserSex(String userSex) {
this.userSex = userSex;
}
public String getUserBirth() {
return userBirth == null ? "" : userBirth.trim();
}
public void setUserBirth(String userBirth) {
this.userBirth = userBirth;
}
public String getUserEducation() {
return userEducation == null ? "" : userEducation.trim();
}
public void setUserEducation(String userEducation) {
this.userEducation = userEducation;
}
public String getUserPolitic() {
return userPolitic == null ? "" : userPolitic.trim();
}
public void setUserPolitic(String userPolitic) {
this.userPolitic = userPolitic;
}
}

View File

@ -11,6 +11,8 @@ import ink.wgink.interfaces.department.IDepartmentBaseService;
import ink.wgink.interfaces.department.IDepartmentUserBaseService;
import ink.wgink.interfaces.role.IRoleUserBaseService;
import ink.wgink.interfaces.user.IUserBaseService;
import ink.wgink.module.dictionary.pojo.dtos.DataDTO;
import ink.wgink.mongo.module.dictionary.service.IMongoDataService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.dtos.department.DepartmentDTO;
import ink.wgink.pojo.dtos.department.DepartmentUserDTO;
@ -49,6 +51,8 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
private IDepartmentBaseService departmentBaseService;
@Autowired
private IRoleUserBaseService roleUserBaseService;
@Autowired
private IMongoDataService mongoDataService;
@Override
public String getRoute() {
@ -140,6 +144,8 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
public void update(String userId, UserExpandVO userExpandVO) throws Exception {
UserExpandPO userExpandPO = getPO(userId);
Map<String, Object> params = HashMapUtil.beanToMap(userExpandVO);
setData(userExpandVO, params);
params.put("userId", userId);
if (userExpandPO == null) {
setSaveInfo(params);
@ -304,4 +310,44 @@ public class UserExpandServiceImpl extends DefaultBaseService implements IUserEx
}
userExpandDTO.setDepartments(departmentDTOs);
}
/**
* 设置数据字典
*
* @param userExpandVO
* @param params
*/
private void setData(UserExpandVO userExpandVO, Map<String, Object> params) {
// 性别
if (!StringUtils.isBlank(userExpandVO.getUserSex())) {
List<DataDTO> userSexDTOs = mongoDataService.listByParentId("4ef46940-76ab-4758-b5f0-0cbc93ffc660");
for (DataDTO userSexDTO : userSexDTOs) {
if (StringUtils.equals(userExpandVO.getUserSex(), userSexDTO.getDataId())) {
params.put("userSexName", userSexDTO.getDataName());
break;
}
}
}
// 学历
if (!StringUtils.isBlank(userExpandVO.getUserSex())) {
List<DataDTO> userEducationDTOs = mongoDataService.listByParentId("d6b9f026-6ea9-456a-b48b-0c18d502523b");
for (DataDTO userEducationDTO : userEducationDTOs) {
if (StringUtils.equals(userExpandVO.getUserEducation(), userEducationDTO.getDataId())) {
params.put("userEducationName", userEducationDTO.getDataName());
break;
}
}
}
// 政治面貌
if (!StringUtils.isBlank(userExpandVO.getUserPolitic())) {
List<DataDTO> userPoliticDTOs = mongoDataService.listByParentId("b2c96de0-3df8-41db-99b1-bc4e24ac6c24");
for (DataDTO userPoliticDTO : userPoliticDTOs) {
if (StringUtils.equals(userExpandVO.getUserPolitic(), userPoliticDTO.getDataId())) {
params.put("userPoliticName", userPoliticDTO.getDataName());
break;
}
}
}
}
}

View File

@ -68,7 +68,7 @@ spring:
max-idle: 8
min-idle: 0
kafka:
bootstrap-servers: 127.0.0.1:9092
bootstrap-servers: localhost:9092
producer:
# 写入失败时重试次数。当leader节点失效一个repli节点会替代成为leader节点此时可能出现写入失败
# 当retris为0时produce不会重复。retirs重发此时repli节点完全成为leader节点不会产生消息丢失。

View File

@ -7,6 +7,13 @@
<result column="area_code" property="areaCode"/>
<result column="area_name" property="areaName"/>
<result column="user_level" property="userLevel"/>
<result column="user_sex" property="userSex"/>
<result column="user_sex_name" property="userSexName"/>
<result column="user_birth" property="userBirth"/>
<result column="user_education" property="userEducation"/>
<result column="user_education_name" property="userEducationName"/>
<result column="user_politic" property="userPolitic"/>
<result column="user_politic_name" property="userPoliticName"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
@ -18,6 +25,13 @@
<result column="area_code" property="areaCode"/>
<result column="area_name" property="areaName"/>
<result column="user_level" property="userLevel"/>
<result column="user_sex" property="userSex"/>
<result column="user_sex_name" property="userSexName"/>
<result column="user_birth" property="userBirth"/>
<result column="user_education" property="userEducation"/>
<result column="user_education_name" property="userEducationName"/>
<result column="user_politic" property="userPolitic"/>
<result column="user_politic_name" property="userPoliticName"/>
<result column="gmt_create" property="gmtCreate"/>
</resultMap>
@ -26,16 +40,21 @@
CREATE TABLE IF NOT EXISTS `sys_user_expand` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_id` char(36) DEFAULT NULL COMMENT '主键',
`area_code` varchar(255) DEFAULT NULL COMMENT '地区编码',
`area_name` varchar(255) DEFAULT NULL COMMENT '地区名称',
`user_level` int(2) DEFAULT NULL COMMENT '地区级别',
`area_code` varchar(255) DEFAULT NULL COMMENT '名称',
`area_name` varchar(255) DEFAULT NULL COMMENT '描述',
`user_level` int(2) DEFAULT '1' COMMENT '用户级别',
`user_sex` varchar(255) DEFAULT NULL COMMENT '性别',
`user_sex_name` varchar(255) DEFAULT NULL COMMENT '性别',
`user_birth` varchar(255) DEFAULT NULL COMMENT '出生年月',
`user_politic` varchar(255) DEFAULT NULL COMMENT '政治面貌',
`user_politic_name` varchar(255) DEFAULT NULL COMMENT '政治面貌',
`creator` char(36) DEFAULT NULL COMMENT '创建人',
`gmt_create` datetime DEFAULT NULL COMMENT '创建时间',
`modifier` char(36) DEFAULT NULL COMMENT '修改人',
`gmt_modified` datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `user_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='';
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='用户拓展属性';
</update>
<!-- 新增 -->
@ -45,6 +64,13 @@
area_code,
area_name,
user_level,
user_sex,
user_sex_name,
user_birth,
user_education,
user_education_name,
user_politic,
user_politic_name,
creator,
gmt_create,
modifier,
@ -54,6 +80,13 @@
#{areaCode},
#{areaName},
#{userLevel},
#{userSex},
#{userSexName},
#{userBirth},
#{userEducation},
#{userEducationName},
#{userPolitic},
#{userPoliticName},
#{creator},
#{gmtCreate},
#{modifier},
@ -85,6 +118,27 @@
</if>
<if test="userLevel != null">
user_level = #{userLevel},
</if>
<if test="userSex != null">
user_sex = #{userSex},
</if>
<if test="userSexName != null">
user_sex_name = #{userSexName},
</if>
<if test="userBirth != null">
user_birth = #{userBirth},
</if>
<if test="userEducation != null">
user_education = #{userEducation},
</if>
<if test="userEducationName != null">
user_education_name = #{userEducationName},
</if>
<if test="userPolitic != null">
user_politic = #{userPolitic},
</if>
<if test="userPoliticName != null">
user_politic_name = #{userPoliticName},
</if>
gmt_modified = #{gmtModified},
modifier = #{modifier}
@ -99,6 +153,13 @@
t1.area_code,
t1.area_name,
t1.user_level,
t1.user_sex,
t1.user_sex_name,
t1.user_birth,
t1.user_education,
t1.user_education_name,
t1.user_politic,
t1.user_politic_name,
t1.gmt_create
FROM
sys_user_expand t1
@ -113,6 +174,13 @@
t1.area_code,
t1.area_name,
t1.user_level,
t1.user_sex,
t1.user_sex_name,
t1.user_birth,
t1.user_education,
t1.user_education_name,
t1.user_politic,
t1.user_politic_name,
t1.creator,
t1.gmt_create,
t1.modifier,
@ -130,6 +198,13 @@
t1.area_code,
t1.area_name,
t1.user_level,
t1.user_sex,
t1.user_sex_name,
t1.user_birth,
t1.user_education,
t1.user_education_name,
t1.user_politic,
t1.user_politic_name,
t1.creator,
t1.gmt_create,
t1.modifier,
@ -156,7 +231,14 @@
t1.user_id,
t1.area_code,
t1.area_name,
t1.user_level
t1.user_level,
t1.user_sex,
t1.user_sex_name,
t1.user_birth,
t1.user_education,
t1.user_education_name,
t1.user_politic,
t1.user_politic_name
FROM
sys_user_expand t1
<where>

View File

@ -9,6 +9,9 @@
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<style>
.layui-form-selected dl{max-height: 200px;}
</style>
</head>
<body>
<div class="layui-anim layui-anim-fadein">
@ -19,7 +22,7 @@
<label class="layui-form-label layui-form-label-up">所在区域 *</label>
<div class="layui-input-block layui-input-block-down">
<input type="hidden" id="areaCode" name="areaCode">
<input type="text" id="areaName" name="areaName" class="layui-input" value="" placeholder="请选择地区" maxlength="255" readonly lay-verify="required" style="cursor:pointer;">
<input type="text" id="areaName" name="areaName" class="layui-input" value="" placeholder="请选择地区" maxlength="255" lay-verify="required" style="cursor:pointer;">
</div>
</div>
<div class="layui-form-item" pane>
@ -31,6 +34,48 @@
<input type="radio" name="userLevel" value="4" title="社区、嘎查村">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label layui-form-label-up">出生年月</label>
<div class="layui-input-block layui-input-block-down">
<input type="text" id="userBirth" name="userBirth" class="layui-input" value="" placeholder="请选择出生年月" maxlength="255" readonly style="cursor:pointer;">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">性别</label>
<div class="layui-input-block layui-form" id="userSexSelectTemplateBox" lay-filter="userSexSelectTemplateBox"></div>
<script id="userSexSelectTemplate" type="text/html">
<select id="userSex" name="userSex" lay-filter="userSex">
<option value="">暂无性别</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.dataId}}">{{item.dataName}}</option>
{{# } }}
</select>
</script>
</div>
<div class="layui-form-item">
<label class="layui-form-label">学历</label>
<div class="layui-input-block layui-form" id="userEducationSelectTemplateBox" lay-filter="userEducationSelectTemplateBox"></div>
<script id="userEducationSelectTemplate" type="text/html">
<select id="userEducation" name="userEducation" lay-filter="userEducation">
<option value="">暂无学历</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.dataId}}">{{item.dataName}}</option>
{{# } }}
</select>
</script>
</div>
<div class="layui-form-item">
<label class="layui-form-label">政治面貌</label>
<div class="layui-input-block layui-form" id="userPoliticSelectTemplateBox" lay-filter="userPoliticSelectTemplateBox"></div>
<script id="userPoliticSelectTemplate" type="text/html">
<select id="userPolitic" name="userPolitic" lay-filter="userPolitic">
<option value="">暂无政治面貌</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.dataId}}">{{item.dataName}}</option>
{{# } }}
</select>
</script>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
@ -60,8 +105,72 @@
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 统一渲染方法
function initSelectRadioCheckboxTemplate(templateId, templateBoxId, data, callback) {
laytpl(document.getElementById(templateId).innerHTML).render(data, function(html) {
document.getElementById(templateBoxId).innerHTML = html;
});
form.render('select', templateBoxId);
if(callback) {
callback();
}
}
// 初始化用户性别下拉选择
function initUserSexSelect(selectValue) {
top.restAjax.get(top.restAjax.path('api/mongo/data/list/parent-id/4ef46940-76ab-4758-b5f0-0cbc93ffc660', []), {
}, null, function(code, data, args) {
initSelectRadioCheckboxTemplate('userSexSelectTemplate', 'userSexSelectTemplateBox', data, function() {
var selectObj = {};
selectObj['userSex'] = selectValue;
form.val('dataForm', selectObj);
});
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化学历下拉选择
function initUserEducationSelect(selectValue) {
top.restAjax.get(top.restAjax.path('api/mongo/data/list/parent-id/d6b9f026-6ea9-456a-b48b-0c18d502523b', []), {
}, null, function(code, data, args) {
initSelectRadioCheckboxTemplate('userEducationSelectTemplate', 'userEducationSelectTemplateBox', data, function() {
var selectObj = {};
selectObj['userEducation'] = selectValue;
form.val('dataForm', selectObj);
});
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化政治面貌下拉选择
function initUserPoliticSelect(selectValue) {
top.restAjax.get(top.restAjax.path('api/mongo/data/list/parent-id/b2c96de0-3df8-41db-99b1-bc4e24ac6c24', []), {
}, null, function(code, data, args) {
initSelectRadioCheckboxTemplate('userPoliticSelectTemplate', 'userPoliticSelectTemplateBox', data, function() {
var selectObj = {};
selectObj['userPolitic'] = selectValue;
form.val('dataForm', selectObj);
});
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
function updateUserBirth() {
laydate.render({
elem: '#userBirth',
type: 'month',
format: 'yyyy-MM',
trigger: 'click'
});
}
updateUserBirth();
// 初始化内容
function initData() {
var loadLayerIndex;
top.restAjax.get(top.restAjax.path('api/user-expand/get/{userId}', [userId]), {}, null, function(code, data) {
var dataFormData = {};
@ -70,6 +179,9 @@
}
form.val('dataForm', dataFormData);
form.render(null, 'dataForm');
initUserSexSelect(data.userSex);
initUserEducationSelect(data.userEducation);
initUserPoliticSelect(data.userPolitic);
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
@ -117,20 +229,20 @@
height: '225px',
onClose: function() {
var selectedAreaArray = top.dialog.dialogData.selectedAreaArray;
if(selectedAreaArray.length > 0) {
var areaCode = '';
var areaName = '';
if(selectedAreaArray.length > 0) {
areaCode = selectedAreaArray[selectedAreaArray.length - 1].areaCode;
for(var i = 0, item; item = selectedAreaArray[i++];) {
if(areaName) {
areaName += ',';
areaName += ' / ';
}
areaName += item.areaName;
}
}
$('#areaCode').val(areaCode);
$('#areaName').val(areaName);
}
}
})
})