update 企业管理员修改密码,退出接口
This commit is contained in:
+8
-8
@@ -4122,8 +4122,8 @@ Shadow=0</a:DisplayPreferences>
|
||||
<o:ExtendedDependencySymbol Id="o5">
|
||||
<a:CreationDate>1629861867</a:CreationDate>
|
||||
<a:ModificationDate>1630547920</a:ModificationDate>
|
||||
<a:Rect>((18886,17352), (20286,19513))</a:Rect>
|
||||
<a:ListOfPoints>((19586,19113),(19586,17752))</a:ListOfPoints>
|
||||
<a:Rect>((18864,16490), (20264,19775))</a:Rect>
|
||||
<a:ListOfPoints>((19564,19375),(19564,16890))</a:ListOfPoints>
|
||||
<a:CornerStyle>1</a:CornerStyle>
|
||||
<a:ArrowStyle>8</a:ArrowStyle>
|
||||
<a:LineColor>16744576</a:LineColor>
|
||||
@@ -4142,8 +4142,8 @@ Shadow=0</a:DisplayPreferences>
|
||||
<o:ExtendedDependencySymbol Id="o9">
|
||||
<a:CreationDate>1629861867</a:CreationDate>
|
||||
<a:ModificationDate>1630546617</a:ModificationDate>
|
||||
<a:Rect>((-4926,14243), (-3526,16575))</a:Rect>
|
||||
<a:ListOfPoints>((-4226,14643),(-4226,16175))</a:ListOfPoints>
|
||||
<a:Rect>((-4624,14425), (-2824,15825))</a:Rect>
|
||||
<a:ListOfPoints>((-4176,15168),(-4200,15168),(-4200,15125),(-4224,15125))</a:ListOfPoints>
|
||||
<a:CornerStyle>1</a:CornerStyle>
|
||||
<a:ArrowStyle>8</a:ArrowStyle>
|
||||
<a:LineColor>16744576</a:LineColor>
|
||||
@@ -4163,7 +4163,7 @@ Shadow=0</a:DisplayPreferences>
|
||||
<a:CreationDate>1629861867</a:CreationDate>
|
||||
<a:ModificationDate>1630546617</a:ModificationDate>
|
||||
<a:IconMode>-1</a:IconMode>
|
||||
<a:Rect>((-18525,-9623), (10127,16175))</a:Rect>
|
||||
<a:Rect>((-17112,-8573), (8714,15125))</a:Rect>
|
||||
<a:LineColor>12615680</a:LineColor>
|
||||
<a:FillColor>16570034</a:FillColor>
|
||||
<a:ShadowColor>12632256</a:ShadowColor>
|
||||
@@ -4188,7 +4188,7 @@ LABL 0 新宋体,8,N</a:FontList>
|
||||
<a:CreationDate>1629861867</a:CreationDate>
|
||||
<a:ModificationDate>1629861867</a:ModificationDate>
|
||||
<a:IconMode>-1</a:IconMode>
|
||||
<a:Rect>((-16114,14643), (8646,27841))</a:Rect>
|
||||
<a:Rect>((-14909,15168), (7441,27316))</a:Rect>
|
||||
<a:LineColor>12615680</a:LineColor>
|
||||
<a:FillColor>16570034</a:FillColor>
|
||||
<a:ShadowColor>12632256</a:ShadowColor>
|
||||
@@ -4213,7 +4213,7 @@ LABL 0 新宋体,8,N</a:FontList>
|
||||
<a:CreationDate>1629861867</a:CreationDate>
|
||||
<a:ModificationDate>1630547913</a:ModificationDate>
|
||||
<a:IconMode>-1</a:IconMode>
|
||||
<a:Rect>((10411,19113), (27816,26011))</a:Rect>
|
||||
<a:Rect>((11222,19375), (27005,25749))</a:Rect>
|
||||
<a:LineColor>12615680</a:LineColor>
|
||||
<a:FillColor>16570034</a:FillColor>
|
||||
<a:ShadowColor>12632256</a:ShadowColor>
|
||||
@@ -4238,7 +4238,7 @@ LABL 0 新宋体,8,N</a:FontList>
|
||||
<a:CreationDate>1629861867</a:CreationDate>
|
||||
<a:ModificationDate>1630547920</a:ModificationDate>
|
||||
<a:IconMode>-1</a:IconMode>
|
||||
<a:Rect>((8696,-3546), (30428,17752))</a:Rect>
|
||||
<a:Rect>((9739,-2684), (29385,16890))</a:Rect>
|
||||
<a:LineColor>12615680</a:LineColor>
|
||||
<a:FillColor>16570034</a:FillColor>
|
||||
<a:ShadowColor>12632256</a:ShadowColor>
|
||||
|
||||
+87
-8
@@ -9,10 +9,7 @@ import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.api.ISysBaseAPI;
|
||||
import com.jero.common.system.util.JwtUtil;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.CommonUtils;
|
||||
import com.jero.common.util.MD5Util;
|
||||
import com.jero.common.util.PasswordUtil;
|
||||
import com.jero.common.util.RedisUtil;
|
||||
import com.jero.common.util.*;
|
||||
import com.jero.company.entity.PayCompanyManagement;
|
||||
import com.jero.company.entity.PayContactsManagement;
|
||||
import com.jero.company.entity.PayManagerManagement;
|
||||
@@ -20,6 +17,8 @@ import com.jero.company.mapper.WxSecretMapper;
|
||||
import com.jero.company.service.IPayCompanyManagementService;
|
||||
import com.jero.company.service.IPayContactsManagementService;
|
||||
import com.jero.company.service.IPayManagerManagementService;
|
||||
import com.jero.company.vo.CompanyLoginVO;
|
||||
import com.jero.company.vo.CompanyManagerLoginVO;
|
||||
import com.jero.data.entity.PayCaseCouncilSubitem;
|
||||
import com.jero.data.service.IPayCaseCouncilSubitemService;
|
||||
import com.jero.modules.base.service.BaseCommonService;
|
||||
@@ -30,15 +29,14 @@ import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -220,6 +218,87 @@ public class CompanyManagerLoginController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
@RequestMapping(value = "/logout")
|
||||
public Result<Object> logout(HttpServletRequest request) {
|
||||
//用户退出逻辑
|
||||
String token = request.getHeader(CommonConstant.X_ACCESS_TOKEN);
|
||||
if (oConvertUtils.isEmpty(token)) {
|
||||
return Result.error("退出登录失败!");
|
||||
}
|
||||
String phone = JwtUtil.getUsername(token);
|
||||
LambdaQueryWrapper<PayManagerManagement> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PayManagerManagement::getPhone, phone);
|
||||
PayManagerManagement managerManagement = payManagerManagementService.getOne(queryWrapper);
|
||||
if (managerManagement != null) {
|
||||
baseCommonService.addLog("手机号: " + PasswordUtil.decrypt(phone) + ",退出成功!", CommonConstant.LOG_TYPE_1, null, null);
|
||||
log.info(" 企业端用户: " + managerManagement.getName() + ",退出成功! ");
|
||||
//清空用户登录Token缓存
|
||||
redisUtil.del(CommonConstant.PREFIX_USER_TOKEN + token);
|
||||
//调用shiro的logout
|
||||
SecurityUtils.getSubject().logout();
|
||||
return Result.OK("退出登录成功!");
|
||||
} else {
|
||||
return Result.error("Token无效!");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "发送手机号验证码")
|
||||
@GetMapping(value = "/sendVerificationCode")
|
||||
public Result<?> sendVerificationCode(@RequestParam(name="phone") String phone,
|
||||
@RequestParam(name="codeType") String codeType) {
|
||||
LambdaQueryWrapper<PayManagerManagement> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PayManagerManagement::getPhone, PasswordUtil.encrypt(phone));
|
||||
PayManagerManagement payManagerManagement = payManagerManagementService.getOne(queryWrapper);
|
||||
if (Objects.isNull(payManagerManagement)) {
|
||||
throw new JeroBootException("手机号不是管理员");
|
||||
}
|
||||
sysBaseAPI.sendVerificationCode(phone,codeType,"300",null);
|
||||
return Result.OK();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "短信验证码修改密码")
|
||||
@PostMapping(value = "/verificationChangePassword")
|
||||
public Result<?> verificationChangePassword(@RequestBody CompanyManagerLoginVO companyManagerLoginVO) {
|
||||
payManagerManagementService.verificationChangePassword(companyManagerLoginVO);
|
||||
return Result.OK("修改密码成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改密码")
|
||||
@PostMapping(value = "/changePassword")
|
||||
public Result<?> changePassword(@RequestBody CompanyManagerLoginVO companyManagerLoginVO) {
|
||||
payManagerManagementService.changePassword(companyManagerLoginVO);
|
||||
return Result.OK("修改密码成功");
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用token修改密码")
|
||||
@PostMapping(value = "/changePasswordWithToken")
|
||||
public Result<?> changePasswordWithToken(@RequestBody CompanyManagerLoginVO companyManagerLoginVO) {
|
||||
payManagerManagementService.changePasswordWithToken(companyManagerLoginVO);
|
||||
return Result.OK("修改密码成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据token获取用户信息
|
||||
*/
|
||||
@GetMapping(value = "/getLoginUser/{token}")
|
||||
public Result<JSONObject> getThirdLoginUser(@PathVariable("token") String token) {
|
||||
Result<JSONObject> result = new Result<>();
|
||||
String phone = JwtUtil.getUsername(token);
|
||||
LambdaQueryWrapper<PayManagerManagement> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PayManagerManagement::getPhone, phone);
|
||||
PayManagerManagement managerManagement = payManagerManagementService.getOne(queryWrapper);
|
||||
if (managerManagement == null) {
|
||||
result.error500("登录失败,账号或密码错误!");
|
||||
baseCommonService.addLog("用户登录失败,用户不存在!", CommonConstant.LOG_TYPE_1, null);
|
||||
return result;
|
||||
}
|
||||
userInfo(managerManagement, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
|
||||
+75
-4
@@ -1,19 +1,31 @@
|
||||
package com.jero.company.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.base.controller.JeroController;
|
||||
import com.jero.common.system.query.QueryGenerator;
|
||||
import com.jero.common.util.*;
|
||||
import com.jero.company.common.PayContactsManagementCommon;
|
||||
import com.jero.company.entity.PayCompanyManagement;
|
||||
import com.jero.company.entity.PayContactsManagement;
|
||||
import com.jero.company.entity.PayManagerManagement;
|
||||
import com.jero.company.service.IPayCompanyManagementService;
|
||||
import com.jero.company.service.IPayManagerManagementService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
@@ -35,7 +47,10 @@ import com.jero.common.aspect.annotation.AutoLog;
|
||||
public class PayManagerManagementController extends JeroController<PayManagerManagement, IPayManagerManagementService> {
|
||||
@Resource
|
||||
private IPayManagerManagementService payManagerManagementService;
|
||||
|
||||
@Resource
|
||||
private IPayCompanyManagementService payCompanyManagementService;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
/**
|
||||
* 分页列表查询
|
||||
*/
|
||||
@@ -67,9 +82,65 @@ public class PayManagerManagementController extends JeroController<PayManagerMan
|
||||
@AutoLog(value = "企业管理员管理-添加")
|
||||
@ApiOperation(value="企业管理员管理-添加", notes="企业管理员管理-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@Validated @RequestBody PayManagerManagement payManagerManagement) {
|
||||
payManagerManagementService.add(payManagerManagement);
|
||||
return Result.OK("添加成功!");
|
||||
public Result<?> add(@RequestBody PayManagerManagement payManagerManagement){
|
||||
String rsaPublicKey = payManagerManagement.getRsaPublicKey();
|
||||
String rsaPrivateKey = String.valueOf(redisUtil.get(rsaPublicKey));
|
||||
String phone = payManagerManagement.getPhone();
|
||||
try{
|
||||
phone = CommonUtils.decryptBtRsaPriKey(phone, rsaPrivateKey);
|
||||
}catch (Exception e){
|
||||
throw new JeroBootException("解密失败!", e);
|
||||
}
|
||||
payManagerManagement.setPhone(phone);
|
||||
StringBuilder msg = ValidUtil.validateAll(payManagerManagement);
|
||||
if(!StringUtils.isBlank(msg)){
|
||||
return Result.error(msg.toString());
|
||||
}
|
||||
PayCompanyManagement payCompanyManagement = payCompanyManagementService.getById(payManagerManagement.getCompanyId());
|
||||
if(Objects.isNull(payCompanyManagement)){
|
||||
return Result.error("企业不存在!");
|
||||
}
|
||||
payManagerManagement.setCompanyName(payCompanyManagement.getCompanyName());
|
||||
try {
|
||||
// 新增管理员前在次校验手机号是否存在
|
||||
LambdaQueryWrapper<PayManagerManagement> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PayManagerManagement::getPhone,PasswordUtil.encrypt(phone));
|
||||
PayManagerManagement payManagerManagementNew = payManagerManagementService.getOne(queryWrapper);
|
||||
// 手机号存在,并且编辑id与查询不同,则校验不通过
|
||||
if(!Objects.isNull(payManagerManagementNew)) {
|
||||
return Result.error("手机号已存在!");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.info("管理员管理-添加异常",e);
|
||||
return Result.error("手机号已存在!");
|
||||
}
|
||||
try {
|
||||
// 新增管理员前校验同企业下管理员是否存在
|
||||
LambdaQueryWrapper<PayManagerManagement> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PayManagerManagement::getName,payManagerManagement.getName());
|
||||
queryWrapper.eq(PayManagerManagement::getCompanyId,payManagerManagement.getCompanyId());
|
||||
PayManagerManagement payManagerManagementNew = payManagerManagementService.getOne(queryWrapper);
|
||||
// 姓名存在,则校验不通过
|
||||
if(!Objects.isNull(payManagerManagementNew)) {
|
||||
return Result.error("管理员姓名已存在!");
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.info("管理员管理-添加异常",e);
|
||||
return Result.error("管理员姓名已存在!!");
|
||||
}
|
||||
// 存在数据
|
||||
try {
|
||||
if (!StringUtils.isBlank(phone)){
|
||||
payManagerManagement.setPhone(PasswordUtil.encrypt(phone));
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("手机号加密异常!",e);
|
||||
}
|
||||
|
||||
payManagerManagement.setRoleCode(Integer.valueOf(PayContactsManagementCommon.ROLE_CODE1));
|
||||
payManagerManagement.setDelFlag(Integer.valueOf(PayContactsManagementCommon.DEL_FLAG0));
|
||||
payManagerManagementService.save(payManagerManagement);
|
||||
return Result.OK("添加成功!",payManagerManagement);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+45
-22
@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.jero.common.util.superSearch.ConstantUtils;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
@@ -18,6 +20,10 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* @Description: 企业管理员管理
|
||||
* @Author: jero-boot
|
||||
@@ -38,73 +44,88 @@ public class PayManagerManagement implements Serializable {
|
||||
private String id;
|
||||
|
||||
/**企业id*/
|
||||
@Excel(name = "企业id", width = 15)
|
||||
@ApiModelProperty(value = "企业id")
|
||||
@Size(max = 32, message = "企业id长度不能大于32个字符")
|
||||
private String companyId;
|
||||
|
||||
/**企业名称(未审核状态下会多出5位,因此修改成55长度)*/
|
||||
@Excel(name = "企业名称(未审核状态下会多出5位,因此修改成55长度)", width = 15)
|
||||
@ApiModelProperty(value = "企业名称(未审核状态下会多出5位,因此修改成55长度)")
|
||||
@Excel(name = "企业名称", width = 15)
|
||||
@ApiModelProperty(value = "企业名称")
|
||||
private String companyName;
|
||||
|
||||
/**姓名*/
|
||||
@Excel(name = "姓名", width = 15)
|
||||
@ApiModelProperty(value = "姓名")
|
||||
@NotEmpty(message = "姓名不能为空")
|
||||
@Size(max = 50, message = "姓名长度不能大于50个字符")
|
||||
private String name;
|
||||
|
||||
/**性别(1:男,2:女)*/
|
||||
@Excel(name = "性别(1:男,2:女)", width = 15)
|
||||
@ApiModelProperty(value = "性别(1:男,2:女)")
|
||||
@Excel(name = "性别", width = 15)
|
||||
@ApiModelProperty(value = "性别")
|
||||
@Dict(dicCode = "sex")
|
||||
private Integer gender;
|
||||
|
||||
/**职务*/
|
||||
@Excel(name = "职务", width = 15)
|
||||
@ApiModelProperty(value = "职务")
|
||||
@Size(max = 50, message = "职务长度不能大于50个字符")
|
||||
private String post;
|
||||
|
||||
/**手机号*/
|
||||
@Excel(name = "手机号", width = 15)
|
||||
@ApiModelProperty(value = "手机号")
|
||||
@NotEmpty(message = "手机号不能为空")
|
||||
@Pattern(regexp = ConstantUtils.TEL_PHONE,message = "手机号格式错误")
|
||||
private String phone;
|
||||
|
||||
/**邮箱*/
|
||||
@Excel(name = "邮箱", width = 15)
|
||||
@ApiModelProperty(value = "邮箱")
|
||||
@Pattern(regexp = "^\\w[-\\w.+]*@([A-Za-z0-9][-A-Za-z0-9]+\\.)+[A-Za-z]{2,14}$",message = "邮箱格式错误")
|
||||
@NotEmpty(message = "邮箱不能为空")
|
||||
private String email;
|
||||
|
||||
/**邮箱授权码*/
|
||||
@Excel(name = "邮箱授权码", width = 15)
|
||||
@ApiModelProperty(value = "邮箱授权码")
|
||||
private String emailPassword;
|
||||
|
||||
/**通讯地址*/
|
||||
@Excel(name = "通讯地址", width = 15)
|
||||
@ApiModelProperty(value = "通讯地址")
|
||||
@Size(max = 50, message = "通讯地址长度不能大于50个字符")
|
||||
@NotEmpty(message = "通讯地址不能为空")
|
||||
private String contactAddress;
|
||||
|
||||
/**邮政编码*/
|
||||
@Excel(name = "邮政编码", width = 15)
|
||||
@ApiModelProperty(value = "邮政编码")
|
||||
@Size(min=6,max = 6,message = "邮政编码长度必须为6个字符")
|
||||
@Pattern(regexp = "^[0-9]\\d{5}$",message = "邮政编码格式错误")
|
||||
@NotEmpty(message = "邮政编码不能为空")
|
||||
private String postalCode;
|
||||
|
||||
/**密码*/
|
||||
@Excel(name = "密码", width = 15)
|
||||
@ApiModelProperty(value = "密码")
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String password;
|
||||
|
||||
/**盐值*/
|
||||
@Excel(name = "盐值", width = 15)
|
||||
@ApiModelProperty(value = "盐值")
|
||||
/**
|
||||
* md5密码盐
|
||||
*/
|
||||
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
|
||||
private String salt;
|
||||
|
||||
/**微信openId*/
|
||||
@Excel(name = "微信openId", width = 15)
|
||||
@ApiModelProperty(value = "微信openId")
|
||||
/**
|
||||
* openId
|
||||
*/
|
||||
private String openId;
|
||||
|
||||
/**备注*/
|
||||
@Excel(name = "备注", width = 15)
|
||||
@ApiModelProperty(value = "备注")
|
||||
@Size(max = 200, message = "备注长度不能大于200个字符")
|
||||
private String remarks;
|
||||
|
||||
/**创建人*/
|
||||
@@ -128,27 +149,25 @@ public class PayManagerManagement implements Serializable {
|
||||
private Date updateTime;
|
||||
|
||||
/**删除状态 0:通过 1:未通过(会员系统审核状态)*/
|
||||
@Excel(name = "删除状态 0:通过 1:未通过(会员系统审核状态)", width = 15)
|
||||
@ApiModelProperty(value = "删除状态 0:通过 1:未通过(会员系统审核状态)")
|
||||
@Excel(name = "删除状态 ", width = 15)
|
||||
@ApiModelProperty(value = "删除状态 ")
|
||||
private Integer delFlag;
|
||||
|
||||
/**用户名用于会员系统使用*/
|
||||
@Excel(name = "用户名用于会员系统使用", width = 15)
|
||||
@ApiModelProperty(value = "用户名用于会员系统使用")
|
||||
private String username;
|
||||
|
||||
/**企业角色1:普通企业、2:会员企业*/
|
||||
@Excel(name = "企业角色1:普通企业、2:会员企业", width = 15)
|
||||
@ApiModelProperty(value = "企业角色1:普通企业、2:会员企业")
|
||||
@Excel(name = "企业角色", width = 15)
|
||||
@ApiModelProperty(value = "企业角色")
|
||||
@Dict(dicCode = "company_role")
|
||||
private Integer roleCode;
|
||||
|
||||
/**会员性质字段*/
|
||||
@Excel(name = "会员性质字段", width = 15)
|
||||
@ApiModelProperty(value = "会员性质字段")
|
||||
private Integer memberNature;
|
||||
|
||||
/**会员企业id*/
|
||||
@Excel(name = "会员企业id", width = 15)
|
||||
@ApiModelProperty(value = "会员企业id")
|
||||
private String memberId;
|
||||
|
||||
@@ -157,4 +176,8 @@ public class PayManagerManagement implements Serializable {
|
||||
@ApiModelProperty(value = "企业角色1:普通企业、2:会员企业")
|
||||
private String companyRole;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "RSA公钥")
|
||||
private String rsaPublicKey;
|
||||
|
||||
}
|
||||
|
||||
+7
@@ -2,6 +2,7 @@ package com.jero.company.service;
|
||||
|
||||
import com.jero.company.entity.PayManagerManagement;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.company.vo.CompanyManagerLoginVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -42,4 +43,10 @@ public interface IPayManagerManagementService extends IService<PayManagerManagem
|
||||
* 列表查询
|
||||
*/
|
||||
List<PayManagerManagement> queryList();
|
||||
|
||||
void verificationChangePassword(CompanyManagerLoginVO companyManagerLoginVO);
|
||||
|
||||
void changePassword(CompanyManagerLoginVO companyManagerLoginVO);
|
||||
|
||||
void changePasswordWithToken(CompanyManagerLoginVO companyManagerLoginVO);
|
||||
}
|
||||
|
||||
+127
@@ -1,12 +1,25 @@
|
||||
package com.jero.company.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.common.system.api.ISysBaseAPI;
|
||||
import com.jero.common.system.util.JwtUtil;
|
||||
import com.jero.common.system.vo.LoginUser;
|
||||
import com.jero.common.util.*;
|
||||
import com.jero.company.entity.PayContactsManagement;
|
||||
import com.jero.company.entity.PayManagerManagement;
|
||||
import com.jero.company.mapper.PayManagerManagementMapper;
|
||||
import com.jero.company.service.IPayManagerManagementService;
|
||||
import com.jero.company.vo.CompanyManagerLoginVO;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @Description: 企业管理员管理
|
||||
@@ -17,6 +30,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@Service
|
||||
public class PayManagerManagementServiceImpl extends ServiceImpl<PayManagerManagementMapper, PayManagerManagement> implements IPayManagerManagementService {
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
/**
|
||||
* 保存
|
||||
*
|
||||
@@ -81,4 +98,114 @@ public class PayManagerManagementServiceImpl extends ServiceImpl<PayManagerManag
|
||||
public List<PayManagerManagement> queryList() {
|
||||
return list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verificationChangePassword(CompanyManagerLoginVO companyManagerLoginVO) {
|
||||
//前端传入密码解密
|
||||
String phone = companyManagerLoginVO.getPhone();
|
||||
String password = companyManagerLoginVO.getPassword();
|
||||
String verifyPassword = companyManagerLoginVO.getVerifyPassword();
|
||||
String RSAPublicKey = companyManagerLoginVO.getRsaPublicKey();
|
||||
String RSAPrivateKey = String.valueOf(redisUtil.get(RSAPublicKey));
|
||||
try {
|
||||
phone = CommonUtils.decryptBtRsaPriKey(phone, RSAPrivateKey);
|
||||
password = CommonUtils.decryptBtRsaPriKey(password, RSAPrivateKey);
|
||||
verifyPassword = CommonUtils.decryptBtRsaPriKey(verifyPassword, RSAPrivateKey);
|
||||
companyManagerLoginVO.setPhone(phone);
|
||||
ValidUtil.validate(companyManagerLoginVO);
|
||||
|
||||
companyManagerLoginVO.setPassword(password);
|
||||
companyManagerLoginVO.setVerifyPassword(verifyPassword);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//处理手机获取验证码的逻辑
|
||||
Object obj = redisUtil.get("_verification:_phone:" + phone);
|
||||
if (obj == null) {
|
||||
throw new JeroBootException("验证码失效,请重新发送");
|
||||
}
|
||||
String code = obj.toString();
|
||||
if (!companyManagerLoginVO.getVerifyCode().equals(code)) {
|
||||
throw new JeroBootException("验证码错误!");
|
||||
}
|
||||
|
||||
if (!password.equals(verifyPassword)) {
|
||||
throw new JeroBootException("新密码和确认密码不一致,请重新输入");
|
||||
}
|
||||
LambdaQueryWrapper<PayManagerManagement> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PayManagerManagement::getPhone, PasswordUtil.encrypt(phone));
|
||||
PayManagerManagement managerManagement = this.getOne(queryWrapper);
|
||||
if (ObjectUtils.isEmpty(managerManagement)) {
|
||||
throw new JeroBootException("用户不存在");
|
||||
}
|
||||
String salt = oConvertUtils.randomGen(8);
|
||||
String managementPhone = managerManagement.getPhone();
|
||||
String passwordEncode = PasswordUtil.encrypt(PasswordUtil.decrypt(managementPhone), password, salt);
|
||||
managerManagement.setPassword(passwordEncode);
|
||||
managerManagement.setSalt(salt);
|
||||
this.saveOrUpdate(managerManagement);
|
||||
redisUtil.del("_verification:_phone:" + phone);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changePassword(CompanyManagerLoginVO companyManagerLoginVO) {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String oldPassword = companyManagerLoginVO.getPassword();
|
||||
String newPassword = companyManagerLoginVO.getNewPassword();
|
||||
String verifyPassword = companyManagerLoginVO.getVerifyPassword();
|
||||
String RSAPublicKey = companyManagerLoginVO.getRsaPublicKey();
|
||||
String RSAPrivateKey = String.valueOf(redisUtil.get(RSAPublicKey));
|
||||
try {
|
||||
oldPassword = CommonUtils.decryptBtRsaPriKey(oldPassword, RSAPrivateKey);
|
||||
newPassword = CommonUtils.decryptBtRsaPriKey(newPassword, RSAPrivateKey);
|
||||
verifyPassword = CommonUtils.decryptBtRsaPriKey(verifyPassword, RSAPrivateKey);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
String phone = loginUser.getPhone();
|
||||
LambdaQueryWrapper<PayManagerManagement> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PayManagerManagement::getPhone, phone);
|
||||
PayManagerManagement managerManagement = this.getOne(queryWrapper);
|
||||
|
||||
String passwordEncode = PasswordUtil.encrypt(PasswordUtil.decrypt(phone), oldPassword, managerManagement.getSalt());
|
||||
if (!managerManagement.getPassword().equals(passwordEncode)) {
|
||||
throw new JeroBootException("旧密码输入错误!");
|
||||
}
|
||||
|
||||
updatePassword(newPassword,verifyPassword,phone);
|
||||
}
|
||||
|
||||
private void updatePassword(String newPassword,String verifyPassword,String phone) {
|
||||
if (oConvertUtils.isEmpty(newPassword)) {
|
||||
throw new JeroBootException("新密码不允许为空!");
|
||||
}
|
||||
if (!newPassword.equals(verifyPassword)) {
|
||||
throw new JeroBootException("两次输入密码不一致!");
|
||||
}
|
||||
String salt = oConvertUtils.randomGen(8);
|
||||
String password = PasswordUtil.encrypt(PasswordUtil.decrypt(phone), newPassword, salt);
|
||||
this.update(new PayManagerManagement().setPassword(password).setSalt(salt), new LambdaQueryWrapper<PayManagerManagement>().eq(PayManagerManagement::getPhone, phone));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changePasswordWithToken(CompanyManagerLoginVO companyManagerLoginVO) {
|
||||
String token = companyManagerLoginVO.getPassword();
|
||||
String username = JwtUtil.getUsername(token);
|
||||
//根据用户名或者手机号获取用户
|
||||
LoginUser loginUser = sysBaseAPI.getUserByName(username);
|
||||
String newPassword = companyManagerLoginVO.getNewPassword();
|
||||
String verifyPassword = companyManagerLoginVO.getVerifyPassword();
|
||||
String RSAPublicKey = companyManagerLoginVO.getRsaPublicKey();
|
||||
String RSAPrivateKey = String.valueOf(redisUtil.get(RSAPublicKey));
|
||||
try {
|
||||
newPassword = CommonUtils.decryptBtRsaPriKey(newPassword, RSAPrivateKey);
|
||||
verifyPassword = CommonUtils.decryptBtRsaPriKey(verifyPassword, RSAPrivateKey);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
String phone = loginUser.getPhone();
|
||||
|
||||
updatePassword(newPassword,verifyPassword,phone);
|
||||
}
|
||||
}
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
package com.jero.company.vo;
|
||||
|
||||
import com.jero.common.util.superSearch.ConstantUtils;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* @Description: 企业端管理员
|
||||
* @author: Kuang Kaixing
|
||||
* @date: 2022/07/26 14:18
|
||||
*/
|
||||
@Data
|
||||
public class CompanyManagerLoginVO {
|
||||
/**手机号*/
|
||||
@ApiModelProperty(value = "手机号")
|
||||
@NotEmpty(message = "手机号不能为空!")
|
||||
@Pattern(regexp = ConstantUtils.TEL_PHONE,message = "手机号码格式错误")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@ApiModelProperty(value = "密码")
|
||||
@NotEmpty(message = "密码不能为空!")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "新密码")
|
||||
private String newPassword;
|
||||
|
||||
/**
|
||||
* 确认密码
|
||||
*/
|
||||
@ApiModelProperty(value = "确认密码")
|
||||
@NotEmpty(message = "确认密码不能为空!")
|
||||
private String verifyPassword;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
@ApiModelProperty(value = "验证码")
|
||||
@NotEmpty(message = "验证码不能为空!")
|
||||
private String verifyCode;
|
||||
|
||||
@ApiModelProperty(value = "RSA公钥")
|
||||
@NotEmpty(message = "RSA公钥不能为空!")
|
||||
private String rsaPublicKey;
|
||||
}
|
||||
Reference in New Issue
Block a user