This commit is contained in:
周源 2021-08-06 22:45:06 +08:00
parent 28ef580019
commit 9032cfa7b1
25 changed files with 854 additions and 140 deletions

View File

@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.xiaoymin.knife4j.annotations.DynamicParameter; import com.github.xiaoymin.knife4j.annotations.DynamicParameter;
import com.github.xiaoymin.knife4j.annotations.DynamicResponseParameters; import com.github.xiaoymin.knife4j.annotations.DynamicResponseParameters;
import com.ydool.boot.api.util.CodecUtils;
import com.ydool.boot.api.util.Kv; import com.ydool.boot.api.util.Kv;
import com.ydool.boot.api.util.SmsUtil; import com.ydool.boot.api.util.SmsUtil;
import com.ydool.boot.api.util.TokenUtil; import com.ydool.boot.api.util.TokenUtil;
@ -99,6 +100,7 @@ public class ApiAuthController extends ApiBaseController {
if (StrUtil.isBlank(type)) fail("身份类型不能为空"); if (StrUtil.isBlank(type)) fail("身份类型不能为空");
if ((!"admin".equals(type)) && (!"admin".equals(type)) && (!"street".equals(type)) && (!"contact".equals(type)) && (!"rddb".equals(type)) && (!"voter".equals(type))) if ((!"admin".equals(type)) && (!"admin".equals(type)) && (!"street".equals(type)) && (!"contact".equals(type)) && (!"rddb".equals(type)) && (!"voter".equals(type)))
fail("请检查身份类型"); fail("请检查身份类型");
phone= CodecUtils.encrypt(phone);
User user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getLoginName, phone).eq(User::getAccountType, type)); User user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getLoginName, phone).eq(User::getAccountType, type));
if (user != null) { if (user != null) {
//直接登录 //直接登录
@ -106,6 +108,7 @@ public class ApiAuthController extends ApiBaseController {
} else { } else {
user = new User(); user = new User();
user.setLoginName(phone); user.setLoginName(phone);
user.setPhone(phone);
user.setSalt(RandomUtil.randomString(6)); user.setSalt(RandomUtil.randomString(6));
user.setPassword(Ydool.password(user.getSalt(), ConfigUtils.getStr("sys.user.initPassword", "888888"))); user.setPassword(Ydool.password(user.getSalt(), ConfigUtils.getStr("sys.user.initPassword", "888888")));
user.setInitPwd(false); user.setInitPwd(false);
@ -163,6 +166,7 @@ public class ApiAuthController extends ApiBaseController {
@DynamicParameter(name = "type", value = "身份 admin县级人大工作人员 street乡镇负责人 contact联络站负责人 rddb各级人大代表 voter选民用户") @DynamicParameter(name = "type", value = "身份 admin县级人大工作人员 street乡镇负责人 contact联络站负责人 rddb各级人大代表 voter选民用户")
}) })
public void auth(String login, String pwd) { public void auth(String login, String pwd) {
login=CodecUtils.encrypt(login);
Ret ret = userService.login(login, pwd); Ret ret = userService.login(login, pwd);
if (ret.isFail()) { if (ret.isFail()) {
render(Ret.fail(ret.get("msg").toString())); render(Ret.fail(ret.get("msg").toString()));
@ -185,8 +189,9 @@ public class ApiAuthController extends ApiBaseController {
render(Ret.fail("发送验证码过于频繁,请稍后重试")); render(Ret.fail("发送验证码过于频繁,请稍后重试"));
} }
String secretPhone=CodecUtils.encrypt(phone);
//作为loginName的手机号不能重复 //作为loginName的手机号不能重复
User repeatUser = checkPhoneRepeat(phone); User repeatUser = checkPhoneRepeat(secretPhone);
if (repeatUser != null) render(Ret.fail("该手机号已被占用")); if (repeatUser != null) render(Ret.fail("该手机号已被占用"));
//存储验证码 //存储验证码
@ -207,16 +212,18 @@ public class ApiAuthController extends ApiBaseController {
}) })
public void register(String phone, String code, @NumberLetter(message = "密码需带有英文,数字") String password, String type) { public void register(String phone, String code, @NumberLetter(message = "密码需带有英文,数字") String password, String type) {
if (StringUtils.isNotBlank(phone) && StringUtils.isNotBlank(code) && StringUtils.isNotBlank(password)) { if (StringUtils.isNotBlank(phone) && StringUtils.isNotBlank(code) && StringUtils.isNotBlank(password)) {
String secretPhone=CodecUtils.encrypt(phone);
//作为loginName的手机号不能重复 //作为loginName的手机号不能重复
User repeatUser = checkPhoneRepeat(phone); User repeatUser = checkPhoneRepeat(secretPhone);
if (repeatUser != null) render(Ret.fail("该手机号已被占用")); if (repeatUser != null) render(Ret.fail("该手机号已被占用"));
if (redisTemplate.hasKey(phone)) { if (redisTemplate.hasKey(phone)) {
String redisCode = (String) redisTemplate.opsForValue().get(phone); String redisCode = (String) redisTemplate.opsForValue().get(phone);
if (code.equals(redisCode)) { if (code.equals(redisCode)) {
User user = new User(); User user = new User();
user.setLoginName(phone); user.setLoginName(secretPhone);
user.setPhone(secretPhone);
user.setSalt(RandomUtil.randomString(6)); user.setSalt(RandomUtil.randomString(6));
user.setPassword(Ydool.password(user.getSalt(), password)); user.setPassword(Ydool.password(user.getSalt(), password));
user.setInitPwd(false); user.setInitPwd(false);
@ -285,8 +292,9 @@ public class ApiAuthController extends ApiBaseController {
System.out.println("login:"+login); System.out.println("login:"+login);
System.out.println("password:"+password); System.out.println("password:"+password);
System.out.println("dingOpenid:"+dingOpenid); System.out.println("dingOpenid:"+dingOpenid);
String secretPhone=CodecUtils.encrypt(login);
User user = userService.getOne(new QueryWrapper<User>().eq("login_name", login)); User user = userService.getOne(new QueryWrapper<User>().eq("login_name", secretPhone));
if (user!=null) { if (user!=null) {
if(!user.getPassword().equals(Ydool.password(user.getSalt(), password))) return Ret.fail("账号或密码错误,绑定失败"); if(!user.getPassword().equals(Ydool.password(user.getSalt(), password))) return Ret.fail("账号或密码错误,绑定失败");

View File

@ -7,6 +7,7 @@ import com.ydool.boot.common.cache.StreetUtils;
import com.ydool.boot.common.result.Ret; import com.ydool.boot.common.result.Ret;
import com.ydool.boot.modules.rddb.entity.*; import com.ydool.boot.modules.rddb.entity.*;
import com.ydool.boot.modules.rddb.service.*; import com.ydool.boot.modules.rddb.service.*;
import com.ydool.boot.modules.rddb.wrapper.OfficeWrapper;
import com.ydool.boot.modules.sys.entity.DictData; import com.ydool.boot.modules.sys.entity.DictData;
import com.ydool.boot.modules.sys.entity.Street; import com.ydool.boot.modules.sys.entity.Street;
import com.ydool.boot.modules.sys.service.StreetService; import com.ydool.boot.modules.sys.service.StreetService;
@ -84,8 +85,7 @@ public class ApiBaseDataController extends ApiBaseController {
@ApiImplicitParam(name = "id", value = "联络站id") @ApiImplicitParam(name = "id", value = "联络站id")
public void contactDetail(String id) { public void contactDetail(String id) {
Office office = officeService.getById(id); Office office = officeService.getById(id);
if (office != null) office.fullInfo(); render(Ret.ok().data(OfficeWrapper.build().entityVO(office)));
render(Ret.ok().data(office));
} }
@GetMapping("dict") @GetMapping("dict")

View File

@ -24,7 +24,6 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List; import java.util.List;
@ -59,7 +58,7 @@ public class ApiDbController extends ApiBaseController {
render(Ret.ok().paged(DbWrapper.build().pageVO(paged))); render(Ret.ok().paged(DbWrapper.build().pageVO(paged)));
} else { } else {
List<Db> list = dbService.list(qw); List<Db> list = dbService.list(qw);
render(Ret.ok().data(list)); render(Ret.ok().data(DbWrapper.build().listVO(list)));
} }
} }

View File

@ -13,7 +13,6 @@ import com.ydool.boot.common.cache.ConfigUtils;
import com.ydool.boot.common.config.Global; import com.ydool.boot.common.config.Global;
import com.ydool.boot.common.result.Ret; import com.ydool.boot.common.result.Ret;
import com.ydool.boot.core.validator.NumberLetter; import com.ydool.boot.core.validator.NumberLetter;
import com.ydool.boot.core.validator.Password;
import com.ydool.boot.modules.rddb.entity.Const; import com.ydool.boot.modules.rddb.entity.Const;
import com.ydool.boot.modules.rddb.entity.Db; import com.ydool.boot.modules.rddb.entity.Db;
import com.ydool.boot.modules.rddb.entity.Office; import com.ydool.boot.modules.rddb.entity.Office;
@ -22,6 +21,7 @@ import com.ydool.boot.modules.rddb.service.DbService;
import com.ydool.boot.modules.rddb.service.OfficeService; import com.ydool.boot.modules.rddb.service.OfficeService;
import com.ydool.boot.modules.rddb.service.SyncNameService; import com.ydool.boot.modules.rddb.service.SyncNameService;
import com.ydool.boot.modules.rddb.service.UserTypeService; import com.ydool.boot.modules.rddb.service.UserTypeService;
import com.ydool.boot.modules.rddb.wrapper.OfficeWrapper;
import com.ydool.boot.modules.sys.entity.User; import com.ydool.boot.modules.sys.entity.User;
import com.ydool.boot.modules.sys.service.UserService; import com.ydool.boot.modules.sys.service.UserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -67,10 +67,7 @@ public class ApiUserController extends ApiBaseController {
//机关干部 //机关干部
if (isAdmin() || isStreet() || isContact()) { if (isAdmin() || isStreet() || isContact()) {
Office office = officeService.getOne(new QueryWrapper<Office>().eq("user_id", user.getId())); Office office = officeService.getOne(new QueryWrapper<Office>().eq("user_id", user.getId()));
if (office != null) { kv.set("office", OfficeWrapper.build().entityVO(office));
office.fullInfo();
}
kv.set("office", office);
} }
//人大代表 //人大代表
if (isRddb()) { if (isRddb()) {

View File

@ -1,8 +1,8 @@
package com.ydool.boot.api.util; package com.ydool.boot.api.util;
import cn.hutool.core.util.StrUtil;
import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex; import org.apache.commons.codec.binary.Hex;
import org.springframework.util.ObjectUtils;
import javax.crypto.BadPaddingException; import javax.crypto.BadPaddingException;
import javax.crypto.Cipher; import javax.crypto.Cipher;
@ -54,7 +54,7 @@ public class CodecUtils {
*/ */
public static String encrypt(String encryptString) { public static String encrypt(String encryptString) {
try { try {
if(encryptString == null) return null; if (StrUtil.isBlank(encryptString)) return "";
return new String(Hex.encodeHex(encryptCipher.doFinal(encryptString.getBytes(ENCODING)))).toUpperCase(); return new String(Hex.encodeHex(encryptCipher.doFinal(encryptString.getBytes(ENCODING)))).toUpperCase();
} catch (BadPaddingException e) { } catch (BadPaddingException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@ -73,15 +73,16 @@ public class CodecUtils {
*/ */
public static String decrypt(String decryptString) { public static String decrypt(String decryptString) {
if(ObjectUtils.isEmpty(decryptString)) return null; if (StrUtil.isBlank(decryptString)) return "";
try { try {
return new String(decryptChipher.doFinal(Hex.decodeHex(decryptString.toCharArray()))); return new String(decryptChipher.doFinal(Hex.decodeHex(decryptString.toCharArray())));
} catch (DecoderException nspe) { } catch (DecoderException nspe) {
throw new RuntimeException(nspe); return decryptString;
} catch (BadPaddingException nsae) { } catch (BadPaddingException nsae) {
throw new RuntimeException(nsae); return decryptString;
} catch (IllegalBlockSizeException ike) { } catch (IllegalBlockSizeException ike) {
throw new RuntimeException(ike); return decryptString;
} }
} }
} }

View File

@ -3,6 +3,7 @@ package com.ydool.boot.modules.rddb.entity;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.ydool.boot.api.util.CodecUtils;
import com.ydool.boot.core.entity.BaseEntity; import com.ydool.boot.core.entity.BaseEntity;
import com.ydool.boot.core.validator.Chinese; import com.ydool.boot.core.validator.Chinese;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
@ -121,4 +122,11 @@ public class Db extends BaseEntity {
return this.phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2"); return this.phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
return null; return null;
} }
/**
* 解密手机号
*/
public void decryptPhone() {
this.phone = CodecUtils.decrypt(phone);
}
} }

View File

@ -1,11 +1,9 @@
package com.ydool.boot.modules.rddb.entity; package com.ydool.boot.modules.rddb.entity;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.ydool.boot.common.cache.DictUtils; import com.ydool.boot.api.util.CodecUtils;
import com.ydool.boot.common.cache.StreetUtils;
import com.ydool.boot.core.entity.BaseEntity; import com.ydool.boot.core.entity.BaseEntity;
import com.ydool.boot.core.validator.Chinese; import com.ydool.boot.core.validator.Chinese;
import com.ydool.boot.core.validator.Number;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -109,13 +107,10 @@ public class Office extends BaseEntity {
private String content; private String content;
/** /**
* 字典值转中文 * 加密手机号
*/ */
public void fullInfo() { public void encryptPhone() {
//辖区 this.phone = CodecUtils.encrypt(phone);
setStreet(StreetUtils.getStreetName(street));
//职务
setDuty(DictUtils.getDictLabel("office_duty", getDuty()));
} }
} }

View File

@ -0,0 +1,301 @@
package com.ydool.boot.modules.rddb.entity.dto;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ydool.boot.common.Ydool;
import com.ydool.boot.common.cache.ConfigUtils;
import com.ydool.boot.core.entity.BaseEntity;
import com.ydool.boot.core.validator.Phone;
import com.ydool.boot.core.validator.Unique;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
@EqualsAndHashCode(callSuper = true)
public class UserDto extends BaseEntity {
/**
* 部门ID
*/
@NotBlank(message = "请选择所属部门")
private String deptId;
/**
* 所属街道
*/
private String streetId;
/**
* 登录账号
*/
@NotBlank(message = "请输入登录账号")
@Unique(message = "登录账号必须是唯一的")
private String loginName;
private String openId;
@NotBlank(message = "请选择账号类型")
private String accountType;
/**
* 用户昵称
*/
@NotBlank(message = "请输入用户昵称")
private String userName;
/**
* 用户邮箱
*/
@Email(message = "用户邮箱格式不正确")
private String email;
/**
* 手机号码
*/
@Phone(message = "手机号码格式不正确")
private String phone;
/**
* 办公室号码
*/
private String officePhone;
/**
* 用户性别0男 1女 2未知
*/
private String sex;
/**
* 头像路径
*/
private String avatar;
/**
* 密码
*/
@JsonIgnore
private String password;
/**
* 盐加密
*/
@JsonIgnore
private String salt;
/**
* 帐号状态1正常 0停用
*/
private Integer status;
private String remarks;
/**
* true 需要提示 是否重置密码
*/
private Boolean initPwd;
/**
* 最后修改密码的时间
*/
private LocalDateTime lastUpdatePwd;
/**
* 最后登陆IP
*/
private String loginIp;
/**
* 最后登陆时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime loginDate;
public String getDeptId() {
return deptId;
}
public void setDeptId(String deptId) {
this.deptId = deptId;
}
public String getStreetId() {
return streetId;
}
public void setStreetId(String streetId) {
this.streetId = streetId;
}
public String getLoginName() {
return loginName;
}
public void setLoginName(String loginName) {
this.loginName = loginName;
}
public String getOpenId() {
return openId;
}
public void setOpenId(String openId) {
this.openId = openId;
}
public String getAccountType() {
return accountType;
}
public void setAccountType(String accountType) {
this.accountType = accountType;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getOfficePhone() {
return officePhone;
}
public void setOfficePhone(String officePhone) {
this.officePhone = officePhone;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getAvatar() {
return avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getSalt() {
return salt;
}
public void setSalt(String salt) {
this.salt = salt;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public Boolean getInitPwd() {
return initPwd;
}
public void setInitPwd(Boolean initPwd) {
this.initPwd = initPwd;
}
public LocalDateTime getLastUpdatePwd() {
return lastUpdatePwd;
}
public void setLastUpdatePwd(LocalDateTime lastUpdatePwd) {
this.lastUpdatePwd = lastUpdatePwd;
}
public String getLoginIp() {
return loginIp;
}
public void setLoginIp(String loginIp) {
this.loginIp = loginIp;
}
public LocalDateTime getLoginDate() {
return loginDate;
}
public void setLoginDate(LocalDateTime loginDate) {
this.loginDate = loginDate;
}
public Boolean isLocked() {
return this.status == 0;
}
// 是否要提示修改面膜
public String isModifyPwdTip() {
if (ConfigUtils.getInt("sys.user.initPasswordModify", 0) == 1) {
if (this.initPwd) return "您的密码还是初始密码,请修改密码!";
if (ConfigUtils.getInt("sys.user.passwordModifyCycle", 0) > 0) {
if (ObjectUtil.isEmpty(this.lastUpdatePwd)) return "为了安全,请修改您的密码!";
if (this.lastUpdatePwd.plusDays(ConfigUtils.getInt("sys.user.passwordModifyCycle") + 1L).isBefore(LocalDateTime.now()))
return "您的密码已有 " + Ydool.toDiffDays(this.lastUpdatePwd) + " 天未修改,请修改您的密码!";
}
}
return null;
}
private String deptName;
private String streetName;
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public String getStreetName() {
return streetName;
}
public void setStreetName(String streetName) {
this.streetName = streetName;
}
}

View File

@ -58,6 +58,8 @@ public class DbService extends BaseService<DbMapper, Db> {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Ret saveOrUpdate(DbVO vo) { public Ret saveOrUpdate(DbVO vo) {
vo.encryptPhone();
Boolean repeatFlag = false; Boolean repeatFlag = false;
//校验手机号重复 //校验手机号重复

View File

@ -55,7 +55,7 @@ public class OfficeService extends BaseService<OfficeMapper, Office> {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Ret insertOrUpdate(Office office, User loginUser) { public Ret insertOrUpdate(Office office, User loginUser) {
office.encryptPhone();
//校验名称重复 //校验名称重复
Office repeatOffice = getOne(office.getName()); Office repeatOffice = getOne(office.getName());
if (repeatOffice != null) { if (repeatOffice != null) {

View File

@ -1,23 +1,106 @@
package com.ydool.boot.modules.rddb.vo; package com.ydool.boot.modules.rddb.vo;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.ydool.boot.api.util.CodecUtils;
import com.ydool.boot.common.cache.DictUtils; import com.ydool.boot.common.cache.DictUtils;
import com.ydool.boot.common.cache.StreetUtils; import com.ydool.boot.common.cache.StreetUtils;
import com.ydool.boot.common.utils.SpringUtils; import com.ydool.boot.common.utils.SpringUtils;
import com.ydool.boot.modules.rddb.entity.Db; import com.ydool.boot.core.entity.BaseEntity;
import com.ydool.boot.core.validator.Chinese;
import com.ydool.boot.modules.rddb.entity.Office; import com.ydool.boot.modules.rddb.entity.Office;
import com.ydool.boot.modules.rddb.service.OfficeService; import com.ydool.boot.modules.rddb.service.OfficeService;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
/** /**
* @author chenchen * @author chenchen
* @date 2020/09/29 * @date 2020/09/29
*/ */
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
public class DbVO extends Db { public class DbVO extends BaseEntity {
private String createdId;
private String updatedId;
private String userId;
/**
* 姓名
*/
@NotBlank(message = "请输入姓名")
@Chinese(message = "姓名只能输入中文")
@Size(max = 20, message = "姓名最大长度为20")
@ApiModelProperty(value = "姓名")
private String name;
/**
* 联系方式
*/
@NotBlank(message = "请输入联系方式")
@ApiModelProperty(value = "联系方式")
private String phone;
/**
* 性别
*/
@NotBlank(message = "请选择性别")
@ApiModelProperty(value = "性别")
private String sex;
/**
* 籍贯
*/
@Chinese(message = "籍贯只能输入中文")
@ApiModelProperty(value = "籍贯")
private String nativePlace;
/**
* 工作单位及职务
*/
@NotBlank(message = "请输入工作单位及职务")
@Chinese(message = "工作单位及职务只能输入中文")
@ApiModelProperty(value = "工作单位及职务")
private String unit;
/**
* 选区地址
*/
@NotBlank(message = "请选择选区地址")
@ApiModelProperty(value = "选区地址")
private String precinctAddress;
/**
* 代表身份
*/
@NotBlank(message = "请选择代表身份 省级人大代表1 市级人大代表2 县级人大代表3 乡镇级人大代表4")
@ApiModelProperty(value = "代表身份")
private String dbIdentity;
/* @NotBlank(message = "请选择是否连任")
private String isReappointment;*/
/**
* 机关人员id 联络站
*/
@NotBlank(message = "请选择联络站")
@ApiModelProperty(value = "联络站")
private String officeId;
@ApiModelProperty(value = "排序")
private Integer sortNo;
@ApiModelProperty(value = "是否显示到大屏")
private Integer showScreen;
@TableField(exist = false)
private String phoneNumber;
public String getPhoneNumber(){
if(StrUtil.isNotBlank(this.phone))
return this.phone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
return null;
}
/** /**
* 选区地址 * 选区地址
@ -40,10 +123,6 @@ public class DbVO extends Db {
if (StrUtil.isNotBlank(getSex())) { if (StrUtil.isNotBlank(getSex())) {
setSex(DictUtils.getDictLabel("sys_user_sex", getSex())); setSex(DictUtils.getDictLabel("sys_user_sex", getSex()));
} }
//民族
// if (StrUtil.isNotBlank(getNation())) {
// setNation(DictUtils.getDictLabel("sys_nation", getNation()));
// }
//选区地址 //选区地址
if (StrUtil.isNotBlank(getPrecinctAddress())) { if (StrUtil.isNotBlank(getPrecinctAddress())) {
setPrecinctAddress(StreetUtils.getStreetName(getPrecinctAddress())); setPrecinctAddress(StreetUtils.getStreetName(getPrecinctAddress()));
@ -52,10 +131,6 @@ public class DbVO extends Db {
if (StrUtil.isNotBlank(getDbIdentity())) { if (StrUtil.isNotBlank(getDbIdentity())) {
setDbIdentity(DictUtils.getDictLabel("sys_db_identity", getDbIdentity())); setDbIdentity(DictUtils.getDictLabel("sys_db_identity", getDbIdentity()));
} }
//是否连任
// if (StrUtil.isNotBlank(getIsReappointment())) {
// setIsReappointment(DictUtils.getDictLabel("sys_yes_no", getIsReappointment()));
// }
//联络站用户 //联络站用户
if (StrUtil.isNotBlank(getOfficeId())) { if (StrUtil.isNotBlank(getOfficeId())) {
OfficeService officeService = SpringUtils.getBean(OfficeService.class); OfficeService officeService = SpringUtils.getBean(OfficeService.class);
@ -63,4 +138,11 @@ public class DbVO extends Db {
setOfficeId(office!=null?office.getName():""); setOfficeId(office!=null?office.getName():"");
} }
} }
/**
* 加密手机号
*/
public void encryptPhone() {
this.phone = CodecUtils.encrypt(phone);
}
} }

View File

@ -0,0 +1,102 @@
package com.ydool.boot.modules.rddb.vo;
import com.ydool.boot.core.entity.BaseEntity;
import com.ydool.boot.core.validator.Chinese;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* <p>
* 机关
* </p>
*
* @author zhouyuan
* @since 2020-09-29
*/
@Data
public class OfficeVo extends BaseEntity {
private String userId;
/**
* 创建者
*/
private String createdId;
/**
* 更新者
*/
private String updatedId;
/**
* 姓名
*/
@NotBlank(message = "姓名不能为空")
private String name;
/**
* 联系方式
*/
@NotBlank(message = "联系方式不能为空")
private String phone;
/**
* 性别
*/
@NotBlank(message = "性别不能为空")
private String sex;
/**
* 出生年月
*/
@NotBlank(message = "出生年月不能为空")
private String birthday;
/**
* 党派
*/
@Chinese(message = "党派只能是中文")
private String partyCadre;
/**
* 民族
*/
private String nation;
/**
* 籍贯
*/
@Chinese(message = "籍贯只能是中文")
@NotBlank(message = "籍贯不能为空")
private String nativePlace;
/**
* 学历
*/
@NotBlank(message = "学历不能为空")
private String culture;
/**
* 职务
*/
@NotBlank(message = "职务不能为空")
private String duty;
/**
* 辖区
*/
private String street;
/**
* 该联络站的简介
*/
private String remarks;
/**
* 该联络站的执勤表
*/
private String content;
}

View File

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.boot.common.result.Ret; import com.ydool.boot.common.result.Ret;
import com.ydool.boot.core.web.BaseController; import com.ydool.boot.core.web.BaseController;
import com.ydool.boot.modules.rddb.entity.ActivityAuditUser; import com.ydool.boot.modules.rddb.entity.ActivityAuditUser;
import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper;
import com.ydool.boot.modules.rddb.service.ActivityAuditUserService; import com.ydool.boot.modules.rddb.service.ActivityAuditUserService;
import com.ydool.boot.modules.rddb.service.ActivityService; import com.ydool.boot.modules.rddb.service.ActivityService;
import com.ydool.boot.modules.rddb.wrapper.ActivityAuditUserWrapper; import com.ydool.boot.modules.rddb.wrapper.ActivityAuditUserWrapper;
@ -73,7 +74,7 @@ public class ActivityAuditUserController extends BaseController {
if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName); if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName);
if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName); if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName);
Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper); Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper);
render(Ret.ok().paged(page)); render(Ret.ok().paged(UserDtoWrapper.build().pageVO(page)));
} }
} }

View File

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.boot.api.controller.ApiBaseController; import com.ydool.boot.api.controller.ApiBaseController;
import com.ydool.boot.common.result.Ret; import com.ydool.boot.common.result.Ret;
import com.ydool.boot.modules.rddb.entity.AuditUser; import com.ydool.boot.modules.rddb.entity.AuditUser;
import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper;
import com.ydool.boot.modules.rddb.service.AuditUserService; import com.ydool.boot.modules.rddb.service.AuditUserService;
import com.ydool.boot.modules.sys.entity.User; import com.ydool.boot.modules.sys.entity.User;
import com.ydool.boot.modules.sys.service.UserService; import com.ydool.boot.modules.sys.service.UserService;
@ -65,7 +66,7 @@ public class AuditUserController extends ApiBaseController {
if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName); if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName);
if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName); if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName);
Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper); Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper);
render(Ret.ok().paged(page)); render(Ret.ok().paged(UserDtoWrapper.build().pageVO(page)));
} }
} }

View File

@ -5,18 +5,17 @@ import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.boot.common.result.Ret; import com.ydool.boot.common.result.Ret;
import com.ydool.boot.core.web.BaseController;
import com.ydool.boot.modules.rddb.entity.ConferenceUser; import com.ydool.boot.modules.rddb.entity.ConferenceUser;
import com.ydool.boot.modules.rddb.entity.SuperviseThingUser; import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper;
import com.ydool.boot.modules.rddb.service.ConferenceUserService; import com.ydool.boot.modules.rddb.service.ConferenceUserService;
import com.ydool.boot.modules.sys.entity.User; import com.ydool.boot.modules.sys.entity.User;
import com.ydool.boot.modules.sys.service.UserService; import com.ydool.boot.modules.sys.service.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import com.ydool.boot.core.web.BaseController;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
/** /**
@ -67,7 +66,7 @@ public class ConferenceUserController extends BaseController {
if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName); if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName);
if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName); if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName);
Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper); Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper);
render(Ret.ok().paged(page)); render(Ret.ok().paged(UserDtoWrapper.build().pageVO(page)));
} }
} }

View File

@ -80,7 +80,7 @@ public class DbController extends BaseAdminController {
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public void list(DbVO dbVO) { public void list(DbVO dbVO) {
QueryWrapper<Db> qw = getQueryWrapper(dbVO.getName(), dbVO.getPhone(), dbVO.getSex(),dbVO.getShowScreen()); QueryWrapper<Db> qw = getQueryWrapper(dbVO.getName(), dbVO.getPhone(), dbVO.getSex(), dbVO.getShowScreen());
IPage<Db> paged = dbService.page(new Page<>(getPageNum(), getPageSize()), qw); IPage<Db> paged = dbService.page(new Page<>(getPageNum(), getPageSize()), qw);
renderJson(Ret.ok().paged(DbWrapper.build().pageVO(paged))); renderJson(Ret.ok().paged(DbWrapper.build().pageVO(paged)));
} }
@ -98,7 +98,7 @@ public class DbController extends BaseAdminController {
public void save(String id) { public void save(String id) {
Db db = dbService.getById(id); Db db = dbService.getById(id);
User user = userService.getById(db.getUserId()); User user = userService.getById(db.getUserId());
if(user!=null){ if (user != null) {
user.setOpenId(""); user.setOpenId("");
userService.updateById(user); userService.updateById(user);
} }
@ -118,8 +118,7 @@ public class DbController extends BaseAdminController {
Db bean = dbService.getById(id); Db bean = dbService.getById(id);
if (bean != null) { if (bean != null) {
List<UserType> list = userTypeService.list(new LambdaQueryWrapper<UserType>().eq(UserType::getUserId, bean.getUserId()).ne(UserType::getType, Const.TYPE_RDDB)); List<UserType> list = userTypeService.list(new LambdaQueryWrapper<UserType>().eq(UserType::getUserId, bean.getUserId()).ne(UserType::getType, Const.TYPE_RDDB));
if (CollectionUtil.isNotEmpty(list)) { if (CollectionUtil.isEmpty(list)) {
if (list.size() == 0) {
//仅有代表角色时候删掉整个user //仅有代表角色时候删掉整个user
userRoleService.remove(new QueryWrapper<UserRole>().eq("user_id", bean.getUserId())); userRoleService.remove(new QueryWrapper<UserRole>().eq("user_id", bean.getUserId()));
userService.removeById(bean.getUserId()); userService.removeById(bean.getUserId());
@ -129,7 +128,6 @@ public class DbController extends BaseAdminController {
user.setAccountType(list.get(0).getType()); user.setAccountType(list.get(0).getType());
userService.updateById(user); userService.updateById(user);
} }
}
//删除代表的角色 //删除代表的角色
userTypeService.remove(new LambdaQueryWrapper<UserType>().eq(UserType::getUserId, bean.getUserId()).eq(UserType::getType, Const.TYPE_RDDB)); userTypeService.remove(new LambdaQueryWrapper<UserType>().eq(UserType::getUserId, bean.getUserId()).eq(UserType::getType, Const.TYPE_RDDB));
dbService.removeById(id); dbService.removeById(id);
@ -165,7 +163,7 @@ public class DbController extends BaseAdminController {
@PostMapping("/export") @PostMapping("/export")
@ResponseBody @ResponseBody
public void export(DbVO dbVO, String[] ids) { public void export(DbVO dbVO, String[] ids) {
QueryWrapper qw = getQueryWrapper(dbVO.getName(), dbVO.getPhone(), dbVO.getSex(),dbVO.getShowScreen()); QueryWrapper qw = getQueryWrapper(dbVO.getName(), dbVO.getPhone(), dbVO.getSex(), dbVO.getShowScreen());
if (ArrayUtil.isNotEmpty(ids)) { if (ArrayUtil.isNotEmpty(ids)) {
qw.in("id", Arrays.asList(ids)); qw.in("id", Arrays.asList(ids));
} }
@ -195,7 +193,7 @@ public class DbController extends BaseAdminController {
render(Ret.ok().data(officeList)); render(Ret.ok().data(officeList));
} }
private QueryWrapper<Db> getQueryWrapper(String name, String phone, String sex,Integer showScreen) { private QueryWrapper<Db> getQueryWrapper(String name, String phone, String sex, Integer showScreen) {
QueryWrapper<Db> qw = new QueryWrapper<>(); QueryWrapper<Db> qw = new QueryWrapper<>();
Condition.appendIfNotEmpty(name, "name#like", qw); Condition.appendIfNotEmpty(name, "name#like", qw);
Condition.appendIfNotEmpty(phone, "phone#like", qw); Condition.appendIfNotEmpty(phone, "phone#like", qw);
@ -221,7 +219,7 @@ public class DbController extends BaseAdminController {
@PostMapping("/show") @PostMapping("/show")
public void show(String id) { public void show(String id) {
Db db = dbService.getById(id); Db db = dbService.getById(id);
if(db!=null){ if (db != null) {
db.setShowScreen(1); db.setShowScreen(1);
dbService.updateById(db); dbService.updateById(db);
render(Ret.ok()); render(Ret.ok());
@ -232,7 +230,7 @@ public class DbController extends BaseAdminController {
@PostMapping("/hide") @PostMapping("/hide")
public void hide(String id) { public void hide(String id) {
Db db = dbService.getById(id); Db db = dbService.getById(id);
if(db!=null){ if (db != null) {
db.setShowScreen(0); db.setShowScreen(0);
dbService.updateById(db); dbService.updateById(db);
render(Ret.ok()); render(Ret.ok());

View File

@ -0,0 +1,143 @@
package com.ydool.boot.modules.rddb.web;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil;
import com.ydool.boot.api.util.CodecUtils;
import com.ydool.boot.common.Ydool;
import com.ydool.boot.common.cache.ConfigUtils;
import com.ydool.boot.common.properties.YdoolProperty;
import com.ydool.boot.common.result.Ret;
import com.ydool.boot.common.utils.TokenUtils;
import com.ydool.boot.common.utils.WebUtils;
import com.ydool.boot.common.utils.YdConst;
import com.ydool.boot.core.web.BaseController;
import com.ydool.boot.modules.sys.entity.User;
import com.ydool.boot.modules.sys.entity.UserRole;
import com.ydool.boot.modules.sys.service.UserRoleService;
import com.ydool.boot.modules.sys.service.UserService;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.constraints.NotBlank;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author zhouyuan
* @date 2021年08月06日22:07:48
*/
@Controller("_loginController")
@RequestMapping("${ydool.path}")
@Validated
public class LoginController extends BaseController {
private String USER_LOGIN_TIMES = "USER_LOGIN_TIMES";
private String USER_LOGIN_LOCKED_TIME = "USER_LOGIN_LOCKED_TIME";
@Autowired
private UserService userService;
@Autowired
private UserRoleService userRoleService;
@Autowired
private YdoolProperty ydoolProperty;
@GetMapping(value = "login")
public String login(Model model) {
String userId = (String) WebUtils.getSession().getAttribute(Ydool.LOGIN_NAME);
String returnUrl = request.getParameter("returnUrl");
if(StrUtil.isEmpty(returnUrl)) returnUrl = ydoolProperty.getPath();
else returnUrl = Base64.decodeStr(returnUrl);
if(StrUtil.isBlank(userId)) {
String token = WebUtils.getCookie("rememberMe");
Claims claims = TokenUtils.parseToken(token);
if (claims != null) {
userId = claims.get(Ydool.LOGIN_NAME, String.class);
}
}
if(StrUtil.isNotBlank(userId)) {
User user = userService.getById(userId);
if(user != null) {
List<UserRole> userRoleList = userRoleService.getUserRoleList(user.getId());
if(!userRoleList.isEmpty()) {
WebUtils.getSession().setAttribute(Ydool.LOGIN_NAME, userId);
WebUtils.redirect(response, returnUrl);
}
}
}
model.addAttribute("returnUrl", returnUrl);
return "themes/default/modules/sysLogin.html";
}
@PostMapping(value = "login")
public void doLogin(@NotBlank(message = "请输入账号或邮箱") String login, @NotBlank(message = "请输入登录密码") String pwd, String captcha, @RequestParam(defaultValue = "false") Boolean rememberUserCode, @RequestParam(defaultValue = "false") Boolean rememberMe) {
Boolean checkCaptchaCode = ConfigUtils.getInt(ConfigUtils.LOGIN_CAPTCHA_CODE, 1) == 1;
if(checkCaptchaCode && StrUtil.isEmpty(captcha)) renderJson(Ret.fail("请输入验证码"));
if(WebUtils.getSession().getAttribute(USER_LOGIN_LOCKED_TIME) != null) {
LocalDateTime datetime = (LocalDateTime) WebUtils.getSession().getAttribute(USER_LOGIN_LOCKED_TIME);
if(LocalDateTime.now().isBefore(datetime)) {
renderJson(Ret.fail("连续登录失败多次,当前禁止登录"));
}else {
WebUtils.getSession().removeAttribute(USER_LOGIN_TIMES);
WebUtils.getSession().removeAttribute(USER_LOGIN_LOCKED_TIME);
}
}
if(checkCaptchaCode) {
String code = (String) WebUtils.getSession().getAttribute(Ydool.CAPTCHA_CODE);
if (!captcha.equals(code)&&!YdConst.SUPER_CODE.equals(captcha)) renderJson(Ret.fail("验证码错误"));
}
Ret ret = userService.login(CodecUtils.encrypt(login), pwd);
if(ret.isFail() && ret.get("msg").equals("账号或者密码错误")) {
// 记录次数
int failedTimes = ConfigUtils.getInt(ConfigUtils.LOGIN_FAILED_TIMES, 0);
if(failedTimes == 0) {
renderJson(ret);
}
int times = Convert.toInt(WebUtils.getSession().getAttribute(USER_LOGIN_TIMES), 0) + 1;
WebUtils.getSession().setAttribute(USER_LOGIN_TIMES, times);
if(times == failedTimes) {
int minute = ConfigUtils.getInt(ConfigUtils.LOGIN_FAILED_LOCK_MINUTE, 5);
WebUtils.getSession().setAttribute(USER_LOGIN_LOCKED_TIME, LocalDateTime.now().plusMinutes(minute));
renderJson(ret.msg("连续登录失败多次,禁止登录,请在" + minute + "分钟后在尝试登录"));
}
renderJson(ret);
}else {
if(rememberUserCode) WebUtils.setCookie("rememberUserCode", login);
else WebUtils.removeCookie("rememberUserCode");
if(rememberMe) {
String token = TokenUtils.getUserLoginToken();
WebUtils.setCookie("rememberMe", token);
}else {
WebUtils.removeCookie("rememberMe");
}
WebUtils.getSession().removeAttribute(USER_LOGIN_TIMES);
WebUtils.getSession().removeAttribute(USER_LOGIN_LOCKED_TIME);
if(checkCaptchaCode) WebUtils.getSession().removeAttribute(Ydool.CAPTCHA_CODE);
renderJson(ret);
}
}
}

View File

@ -4,11 +4,11 @@ package com.ydool.boot.modules.rddb.web;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.boot.common.cache.StreetUtils;
import com.ydool.boot.common.result.Ret; import com.ydool.boot.common.result.Ret;
import com.ydool.boot.core.auth.PreAuth; import com.ydool.boot.core.auth.PreAuth;
import com.ydool.boot.modules.rddb.entity.Office; import com.ydool.boot.modules.rddb.entity.Office;
import com.ydool.boot.modules.rddb.service.OfficeService; import com.ydool.boot.modules.rddb.service.OfficeService;
import com.ydool.boot.modules.rddb.wrapper.OfficeWrapper;
import com.ydool.boot.modules.sys.entity.User; import com.ydool.boot.modules.sys.entity.User;
import com.ydool.boot.modules.sys.service.UserService; import com.ydool.boot.modules.sys.service.UserService;
import com.ydool.boot.modules.sys.web.BaseAdminController; import com.ydool.boot.modules.sys.web.BaseAdminController;
@ -51,12 +51,9 @@ public class OfficeController extends BaseAdminController {
if (StringUtils.isNotBlank(office.getName())) wrapper.like("name", office.getName()); if (StringUtils.isNotBlank(office.getName())) wrapper.like("name", office.getName());
if (StringUtils.isNotBlank(office.getPhone())) wrapper.like("phone", office.getPhone()); if (StringUtils.isNotBlank(office.getPhone())) wrapper.like("phone", office.getPhone());
if (StringUtils.isNotBlank(office.getDuty())) wrapper.like("duty", office.getDuty()); if (StringUtils.isNotBlank(office.getDuty())) wrapper.like("duty", office.getDuty());
wrapper.orderByDesc("created_at");
Page page = officeService.page(new Page(getPageNum(), getPageSize()), wrapper); Page page = officeService.page(new Page(getPageNum(), getPageSize()), wrapper);
page.getRecords().forEach(item -> { render(Ret.ok().paged(OfficeWrapper.build().pageVO(page)));
Office o = (Office) item;
o.setStreet(StreetUtils.getStreetName(o.getStreet()));
});
render(Ret.ok().paged(page));
} }
@PreAuth("rddb:office:form") @PreAuth("rddb:office:form")
@ -69,7 +66,7 @@ public class OfficeController extends BaseAdminController {
//新增的生日默认1980 //新增的生日默认1980
office.setBirthday("1980-01"); office.setBirthday("1980-01");
} }
model.addAttribute("office", office); model.addAttribute("office", OfficeWrapper.build().entityVO(office));
return "modules/rddb/office/form.html"; return "modules/rddb/office/form.html";
} }

View File

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.boot.common.result.Ret; import com.ydool.boot.common.result.Ret;
import com.ydool.boot.modules.rddb.entity.ReadFileUser; import com.ydool.boot.modules.rddb.entity.ReadFileUser;
import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper;
import com.ydool.boot.modules.rddb.service.ReadFileUserService; import com.ydool.boot.modules.rddb.service.ReadFileUserService;
import com.ydool.boot.modules.sys.entity.User; import com.ydool.boot.modules.sys.entity.User;
import com.ydool.boot.modules.sys.service.UserService; import com.ydool.boot.modules.sys.service.UserService;
@ -65,7 +66,7 @@ public class ReadFileUserController extends BaseAdminController {
if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName); if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName);
if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName); if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName);
Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper); Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper);
render(Ret.ok().paged(page)); render(Ret.ok().paged(UserDtoWrapper.build().pageVO(page)));
} }
} }

View File

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.boot.common.result.Ret; import com.ydool.boot.common.result.Ret;
import com.ydool.boot.core.web.BaseController; import com.ydool.boot.core.web.BaseController;
import com.ydool.boot.modules.rddb.entity.SuperviseThingUser; import com.ydool.boot.modules.rddb.entity.SuperviseThingUser;
import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper;
import com.ydool.boot.modules.rddb.service.SuperviseThingUserService; import com.ydool.boot.modules.rddb.service.SuperviseThingUserService;
import com.ydool.boot.modules.sys.entity.User; import com.ydool.boot.modules.sys.entity.User;
import com.ydool.boot.modules.sys.service.UserService; import com.ydool.boot.modules.sys.service.UserService;
@ -65,7 +66,7 @@ public class SuperviseThingUserController extends BaseController {
if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName); if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName);
if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName); if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName);
Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper); Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper);
render(Ret.ok().paged(page)); render(Ret.ok().paged(UserDtoWrapper.build().pageVO(page)));
} }
} }

View File

@ -2,9 +2,9 @@ package com.ydool.boot.modules.rddb.web;
import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ydool.boot.api.util.CodecUtils;
import com.ydool.boot.common.Ydool; import com.ydool.boot.common.Ydool;
import com.ydool.boot.common.cache.ConfigUtils; import com.ydool.boot.common.cache.ConfigUtils;
import com.ydool.boot.common.config.Global; import com.ydool.boot.common.config.Global;
@ -12,18 +12,15 @@ import com.ydool.boot.common.result.Ret;
import com.ydool.boot.core.auth.PreAuth; import com.ydool.boot.core.auth.PreAuth;
import com.ydool.boot.core.mybatis.Condition; import com.ydool.boot.core.mybatis.Condition;
import com.ydool.boot.core.mybatis.Query; import com.ydool.boot.core.mybatis.Query;
import com.ydool.boot.modules.rddb.entity.Const; import com.ydool.boot.modules.rddb.entity.dto.UserDto;
import com.ydool.boot.modules.rddb.entity.UserType; import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper;
import com.ydool.boot.modules.rddb.service.UserTypeService;
import com.ydool.boot.modules.sys.entity.Role; import com.ydool.boot.modules.sys.entity.Role;
import com.ydool.boot.modules.sys.entity.User; import com.ydool.boot.modules.sys.entity.User;
import com.ydool.boot.modules.sys.entity.UserRole; import com.ydool.boot.modules.sys.entity.UserRole;
import com.ydool.boot.modules.sys.service.RoleService; import com.ydool.boot.modules.sys.service.RoleService;
import com.ydool.boot.modules.sys.service.UserRoleService; import com.ydool.boot.modules.sys.service.UserRoleService;
import com.ydool.boot.modules.sys.service.UserService; import com.ydool.boot.modules.sys.service.UserService;
import com.ydool.boot.modules.sys.vo.UserVO;
import com.ydool.boot.modules.sys.web.BaseAdminController; import com.ydool.boot.modules.sys.web.BaseAdminController;
import com.ydool.boot.modules.sys.wrapper.UserWrapper;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -41,8 +38,6 @@ public class VoterController extends BaseAdminController {
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired @Autowired
private UserTypeService userTypeService;
@Autowired
private RoleService roleService; private RoleService roleService;
@Autowired @Autowired
private UserRoleService userRoleService; private UserRoleService userRoleService;
@ -60,22 +55,26 @@ public class VoterController extends BaseAdminController {
@PostMapping("list") @PostMapping("list")
@PreAuth("sys:rddb:list") @PreAuth("sys:rddb:list")
public void list(User user, Query query) { public void list(User user, Query query) {
user.setLoginName(CodecUtils.decrypt(user.getLoginName()));
QueryWrapper<User> wrapper = Condition.getQueryWrapper(user, "loginName#like", "accountType"); QueryWrapper<User> wrapper = Condition.getQueryWrapper(user, "loginName#like", "accountType");
IPage<User> paged = userService.page(Condition.getPage(query), wrapper.orderByDesc("created_at")); IPage<User> paged = userService.page(Condition.getPage(query), wrapper.orderByDesc("created_at"));
render(Ret.ok().paged(UserWrapper.build().pageVO(paged))); render(Ret.ok().paged(UserDtoWrapper.build().pageVO(paged)));
} }
@GetMapping("form") @GetMapping("form")
@PreAuth("sys:rddb:add") @PreAuth("sys:rddb:add")
public String form(User user, Model model) { public String form(User user, Model model) {
UserVO userVO = UserWrapper.build().entityVO(user); UserDto userDto = UserDtoWrapper.build().entityVO(user);
model.addAttribute("voter", userVO); model.addAttribute("voter", userDto);
return "modules/rddb/voter/form.html"; return "modules/rddb/voter/form.html";
} }
@PostMapping("save") @PostMapping("save")
@PreAuth("sys:rddb:add") @PreAuth("sys:rddb:add")
public void save(User user) { public void save(User user) {
String secretPhone = CodecUtils.encrypt(user.getLoginName());
user.setLoginName(secretPhone);
user.setPhone(secretPhone);
if (StrUtil.isBlank(user.getLoginName())) renderJson(Ret.fail("登录账号不能为空")); if (StrUtil.isBlank(user.getLoginName())) renderJson(Ret.fail("登录账号不能为空"));
if (StrUtil.isBlank(user.getUserName())) renderJson(Ret.fail("用户名不能为空")); if (StrUtil.isBlank(user.getUserName())) renderJson(Ret.fail("用户名不能为空"));
@ -111,7 +110,6 @@ public class VoterController extends BaseAdminController {
user.setInitPwd(true); user.setInitPwd(true);
user.setAccountType("voter"); user.setAccountType("voter");
} }
user.setPhone(user.getLoginName());
boolean flag = userService.saveOrUpdate(user); boolean flag = userService.saveOrUpdate(user);
Role role = roleService.getOne(new QueryWrapper<Role>().eq("code", "default")); Role role = roleService.getOne(new QueryWrapper<Role>().eq("code", "default"));

View File

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ydool.boot.common.result.Ret; import com.ydool.boot.common.result.Ret;
import com.ydool.boot.core.web.BaseController; import com.ydool.boot.core.web.BaseController;
import com.ydool.boot.modules.rddb.entity.VoterSuggestSolve; import com.ydool.boot.modules.rddb.entity.VoterSuggestSolve;
import com.ydool.boot.modules.rddb.wrapper.UserDtoWrapper;
import com.ydool.boot.modules.rddb.service.VoterSuggestService; import com.ydool.boot.modules.rddb.service.VoterSuggestService;
import com.ydool.boot.modules.rddb.service.VoterSuggestSolveService; import com.ydool.boot.modules.rddb.service.VoterSuggestSolveService;
import com.ydool.boot.modules.rddb.wrapper.VoterSuggestSolveWrapper; import com.ydool.boot.modules.rddb.wrapper.VoterSuggestSolveWrapper;
@ -73,7 +74,7 @@ public class VoterSuggestSolveController extends BaseController {
if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName); if(StrUtil.isNotBlank(userName)) userQueryWrapper.like("user_name",userName);
if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName); if(StrUtil.isNotBlank(loginName)) userQueryWrapper.like("login_name",loginName);
Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper); Page page = userService.page(new Page(getPageNum(), getPageSize()), userQueryWrapper);
render(Ret.ok().paged(page)); render(Ret.ok().paged(UserDtoWrapper.build().pageVO(page)));
} }
} }

View File

@ -25,6 +25,7 @@ public class DbWrapper extends BaseWrapper<Db, DbVO> {
@Override @Override
public DbVO entityVO(Db db) { public DbVO entityVO(Db db) {
db.decryptPhone();
DbVO vo = BeanUtil.copyProperties(db, DbVO.class); DbVO vo = BeanUtil.copyProperties(db, DbVO.class);
vo.setPrecinctAddressStr(StreetUtils.getStreetName(db.getPrecinctAddress())); vo.setPrecinctAddressStr(StreetUtils.getStreetName(db.getPrecinctAddress()));
vo.setDbIdentityStr(DictUtils.getDictLabel("sys_db_identity", db.getDbIdentity())); vo.setDbIdentityStr(DictUtils.getDictLabel("sys_db_identity", db.getDbIdentity()));
@ -41,6 +42,7 @@ public class DbWrapper extends BaseWrapper<Db, DbVO> {
@SuppressWarnings({"unchecked"}) @SuppressWarnings({"unchecked"})
public <T> T entityReadHead(DbReadHead dbReadHead, Class<T> vo) { public <T> T entityReadHead(DbReadHead dbReadHead, Class<T> vo) {
DbVO dbVO = (DbVO) BeanUtil.copyProperties(dbReadHead, vo); DbVO dbVO = (DbVO) BeanUtil.copyProperties(dbReadHead, vo);
dbVO.encryptPhone();
//性别 //性别
if (StrUtil.isNotBlank(dbVO.getSex())) { if (StrUtil.isNotBlank(dbVO.getSex())) {
@ -71,8 +73,10 @@ public class DbWrapper extends BaseWrapper<Db, DbVO> {
@SuppressWarnings({"unchecked", "DuplicatedCode"}) @SuppressWarnings({"unchecked", "DuplicatedCode"})
@Override @Override
public <T> T entityHead(Db entity, Class<T> head) { public <T> T entityHead(Db entity, Class<T> head) {
entity.decryptPhone();
DbReadHead entityHead = (DbReadHead) super.entityHead(entity, head); DbReadHead entityHead = (DbReadHead) super.entityHead(entity, head);
//性别 //性别
if (StrUtil.isNotBlank(entityHead.getSex())) { if (StrUtil.isNotBlank(entityHead.getSex())) {
entityHead.setSex(DictUtils.getDictLabel("sys_user_sex", entityHead.getSex())); entityHead.setSex(DictUtils.getDictLabel("sys_user_sex", entityHead.getSex()));

View File

@ -0,0 +1,36 @@
package com.ydool.boot.modules.rddb.wrapper;
import cn.hutool.core.bean.BeanUtil;
import com.ydool.boot.api.util.CodecUtils;
import com.ydool.boot.common.cache.DictUtils;
import com.ydool.boot.common.cache.StreetUtils;
import com.ydool.boot.core.wrapper.BaseWrapper;
import com.ydool.boot.modules.rddb.entity.Office;
import com.ydool.boot.modules.rddb.vo.OfficeVo;
/**
* @author chenchen
* @date 2020/06/05
*/
public class OfficeWrapper extends BaseWrapper<Office, OfficeVo> {
public static OfficeWrapper build() {
return new OfficeWrapper();
}
@Override
public OfficeVo entityVO(Office office) {
if(office!=null){
OfficeVo vo = BeanUtil.copyProperties(office, OfficeVo.class);
vo.setPhone(CodecUtils.decrypt(vo.getPhone()));
//辖区
vo.setStreet(StreetUtils.getStreetName(vo.getStreet()));
//职务
vo.setDuty(DictUtils.getDictLabel("office_duty", vo.getDuty()));
return vo;
}
return null;
}
}

View File

@ -0,0 +1,39 @@
package com.ydool.boot.modules.rddb.wrapper;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.ydool.boot.api.util.CodecUtils;
import com.ydool.boot.common.cache.SysCacheUtils;
import com.ydool.boot.core.wrapper.BaseWrapper;
import com.ydool.boot.modules.rddb.entity.dto.UserDto;
import com.ydool.boot.modules.sys.entity.Dept;
import com.ydool.boot.modules.sys.entity.Street;
import com.ydool.boot.modules.sys.entity.User;
/**
* @author zhouyuan
* @date 2021年08月06日19:47:57
*/
public class UserDtoWrapper extends BaseWrapper<User, UserDto> {
public static UserDtoWrapper build() {
return new UserDtoWrapper();
}
@Override
public UserDto entityVO(User entity) {
UserDto userDto = BeanUtil.copyProperties(entity, UserDto.class);
if (StrUtil.isNotBlank(userDto.getDeptId())) {
Dept dept = SysCacheUtils.getDept(userDto.getDeptId());
if (dept != null) userDto.setDeptName(dept.getName());
}
if (StrUtil.isNotBlank(userDto.getStreetId())) {
Street street = SysCacheUtils.getStreet(userDto.getStreetId());
if (street != null) userDto.setStreetName(street.getName());
}
userDto.setLoginName(CodecUtils.decrypt(userDto.getLoginName()));
userDto.setPhone(CodecUtils.decrypt(userDto.getPhone()));
return userDto;
}
}