update 企业管理员登录

This commit is contained in:
lijiarao
2022-08-15 11:37:02 +08:00
parent ad95d6fe68
commit b8341a84dd
9 changed files with 288 additions and 49 deletions
@@ -0,0 +1,181 @@
package com.jero.modules.pay.company.entity;
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.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.jero.common.aspect.annotation.Dict;
import com.jero.common.util.superSearch.ConstantUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: 企业管理员管理
* @Author: jero-boot
* @Date: 2022-07-26
* @Version: V1.0
*/
@Data
@TableName("pay_manager_management")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="pay_manager_management对象", description="企业管理员管理")
public class PayManagerManagement implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
/**企业id*/
@ApiModelProperty(value = "企业id")
@Size(max = 32, message = "企业id长度不能大于32个字符")
private String companyId;
/**企业名称(未审核状态下会多出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 = "性别", width = 15)
//@ApiModelProperty(value = "性别")
//@Dict(dicCode = "sex")
//private String 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;
/**邮箱授权码*/
//@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;
/**
* 密码
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String password;
/**
* md5密码盐
*/
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private String salt;
/**
* openId
*/
private String openId;
/**备注*/
//@Excel(name = "备注", width = 15)
//@ApiModelProperty(value = "备注")
//@Size(max = 200, message = "备注长度不能大于200个字符")
//private String remarks;
/**创建人*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**创建时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**更新人*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**更新时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
/**删除状态 0:通过 1:未通过(会员系统审核状态)*/
@Excel(name = "删除状态 ", width = 15)
@ApiModelProperty(value = "删除状态 ")
private String delFlag;
/**用户名用于会员系统使用*/
@ApiModelProperty(value = "用户名用于会员系统使用")
private String username;
/**企业角色1:普通企业、2:会员企业*/
@Excel(name = "企业角色", width = 15)
@ApiModelProperty(value = "企业角色")
@Dict(dicCode = "company_role")
private String roleCode;
/**会员性质字段*/
@ApiModelProperty(value = "会员性质字段")
private String memberNature;
/**会员企业id*/
@ApiModelProperty(value = "会员企业id")
private String memberId;
/**企业角色1:普通企业、2:会员企业*/
@TableField(exist = false)
@ApiModelProperty(value = "企业角色1:普通企业、2:会员企业")
private String companyRole;
@TableField(exist = false)
@ApiModelProperty(value = "RSA公钥")
private String rsaPublicKey;
}
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jero.modules.pay.company.entity.PayContactsManagement;
import com.jero.modules.pay.company.entity.PayManagerManagement;
import com.jero.modules.system.entity.SysRole;
import com.jero.modules.system.vo.SysUserVo;
import org.apache.ibatis.annotations.Param;
@@ -166,6 +167,8 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
PayContactsManagement getPayContactsManagementByPhone(@Param("username") String username);
PayManagerManagement getCompanyManagementByPhone(@Param("username") String username);
void forgetPassword(@Param("user") SysUser user);
}
@@ -212,4 +212,9 @@
update sys_user set password = #{user.password}
where username = #{user.username}
</update>
<select id="getCompanyManagementByPhone" resultType="com.jero.modules.pay.company.entity.PayManagerManagement">
select *
from pay_manager_management where phone = #{username} and del_flag = 0;
</select>
</mapper>
@@ -9,9 +9,11 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.base.Joiner;
import com.jero.common.constant.enums.LoginUserTypeEnum;
import com.jero.common.util.HuaWeiSmsUtil;
import com.jero.modules.oss.mapper.OSSFileMapper;
import com.jero.modules.pay.company.entity.PayContactsManagement;
import com.jero.modules.pay.company.entity.PayManagerManagement;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
@@ -115,24 +117,42 @@ public class SysBaseApiImpl implements ISysBaseAPI {
return null;
}
LoginUser loginUser = new LoginUser();
SysUser sysUser = userMapper.getUserByName(username);
if(sysUser==null) {
PayContactsManagement contactsManagement = userMapper.getPayContactsManagementByPhone(username);
if (contactsManagement == null){
if (username.startsWith(LoginUserTypeEnum.company_management_.toString())){
username = username.substring(LoginUserTypeEnum.company_management_.toString().length());
PayManagerManagement companyManagementByPhone = userMapper.getCompanyManagementByPhone(username);
if (companyManagementByPhone == null){
return null;
}else {
BeanUtils.copyProperties(contactsManagement, loginUser);
loginUser.setIsCompanyUser(true);
loginUser.setUsername(contactsManagement.getPhone());
loginUser.setRealname(contactsManagement.getName());
loginUser.setRoleCode("企业用户");
BeanUtils.copyProperties(companyManagementByPhone, loginUser);
loginUser.setIsCompanyUser(false);
loginUser.setIsCompanyManager(true);
loginUser.setUsername(companyManagementByPhone.getPhone());
loginUser.setRealname(companyManagementByPhone.getName());
loginUser.setRoleCode("企业管理员");
}
}else{
SysUser sysUser = userMapper.getUserByName(username);
if(sysUser==null) {
PayContactsManagement contactsManagement = userMapper.getPayContactsManagementByPhone(username);
if (contactsManagement == null){
return null;
}else {
BeanUtils.copyProperties(contactsManagement, loginUser);
loginUser.setIsCompanyUser(true);
loginUser.setIsCompanyManager(false);
loginUser.setUsername(contactsManagement.getPhone());
loginUser.setRealname(contactsManagement.getName());
loginUser.setRoleCode("企业用户");
}
}else {
BeanUtils.copyProperties(sysUser, loginUser);
List<String> roleByUserName = sysUserRoleMapper.getRoleByUserName(username);
loginUser.setRoleCode(StringUtils.join(roleByUserName, ","));
loginUser.setIsCompanyUser(false);
loginUser.setIsCompanyManager(false);
}
}else {
BeanUtils.copyProperties(sysUser, loginUser);
List<String> roleByUserName = sysUserRoleMapper.getRoleByUserName(username);
loginUser.setRoleCode(StringUtils.join(roleByUserName, ","));
loginUser.setIsCompanyUser(false);
}
return loginUser;
}