@@ -0,0 +1,36 @@ | |||
package cn.com.taiji.core.entity.dict.basic; | |||
/** | |||
* @Author weicailin | |||
* @Date 2023/3/22 17:39 | |||
* @Email 13079168756@163.com | |||
*/ | |||
public enum AccountType { | |||
ENTERPRISE("企业会员", 2), | |||
PERSONAL("个人会员", 1), | |||
UNDEFINED("未知", 3), | |||
; | |||
private final String value; | |||
private final Integer code; | |||
AccountType(String value, Integer code) { | |||
this.value = value; | |||
this.code = code; | |||
} | |||
public String getValue() { | |||
return value; | |||
} | |||
public Integer getCode() { | |||
return code; | |||
} | |||
public static AccountType fromCode(Integer code) { | |||
AccountType[] values = AccountType.values(); | |||
for (AccountType value : values) { | |||
if (value.code == code) return value; | |||
} | |||
return null; | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
package cn.com.taiji.core.entity.dict.basic; | |||
/** | |||
* @Author weicailin | |||
* @Date 2023/3/22 17:38 | |||
* @Email 13079168756@163.com | |||
*/ | |||
public enum Gender { | |||
MALE("男") {}, | |||
FEMALE("女") {}, | |||
UNKOWN("未知") {}, | |||
; | |||
private final String value; | |||
Gender(String value) { | |||
this.value = value; | |||
} | |||
public static Gender getGender(String value){ | |||
for (Gender gender : Gender.values()){ | |||
if(value.equals(gender.getValue())){ | |||
return gender; | |||
} | |||
} | |||
return Gender.UNKOWN; | |||
} | |||
public String getValue() { | |||
return value; | |||
} | |||
} |
@@ -2,8 +2,7 @@ package cn.com.taiji.core.entity.user; | |||
import cn.com.taiji.core.entity.AbstractStringPropertyUUIDEntity; | |||
import cn.com.taiji.core.entity.dict.basic.IdType; | |||
import cn.com.taiji.core.entity.dict.basic.SourceType; | |||
import cn.com.taiji.core.entity.dict.basic.*; | |||
import javax.persistence.*; | |||
import java.time.LocalDateTime; | |||
@@ -62,11 +61,11 @@ public class AccountInfo extends AbstractStringPropertyUUIDEntity { | |||
private IdType idType; | |||
/** | |||
* 会员类型: | |||
* 会员类型:原来是USER_TYPE | |||
* 1、个人会员 | |||
* 2、企业会员 | |||
*/ | |||
private UserType userType; | |||
private AccountType accountType; | |||
/** | |||
* 登录方来源 | |||
@@ -188,9 +187,9 @@ public class AccountInfo extends AbstractStringPropertyUUIDEntity { | |||
} | |||
@Enumerated(EnumType.STRING) | |||
@Column(name = "USER_TYPE") | |||
public UserType getUserType() { | |||
return userType; | |||
@Column(name = "ACCOUNT_TYPE") | |||
public AccountType getAccountType() { | |||
return accountType; | |||
} | |||
@Enumerated(EnumType.STRING) | |||
@@ -276,8 +275,8 @@ public class AccountInfo extends AbstractStringPropertyUUIDEntity { | |||
this.idType = idType; | |||
} | |||
public void setUserType(UserType userType) { | |||
this.userType = userType; | |||
public void setAccountType(AccountType accountType) { | |||
this.accountType = accountType; | |||
} | |||
public void setLoginSource(SourceType loginSource) { |
@@ -1,16 +1,16 @@ | |||
package cn.com.taiji.core.repo.jpa.user; | |||
import cn.com.taiji.common.repo.jpa.AbstractJpaRepo; | |||
import cn.com.taiji.core.entity.dict.basic.AccountType; | |||
import cn.com.taiji.core.entity.user.AccountInfo; | |||
import org.springframework.data.jpa.repository.Query; | |||
import java.util.List; | |||
public interface AccountInfoRepo extends AbstractJpaRepo<AccountInfo, String> { | |||
@Query("FROM AccountInfo WHERE openId=?1") | |||
AccountInfo findByOpenId(String openId); | |||
AccountInfo findByIdNumAndUserType(String idNum, UserType userType); | |||
AccountInfo findByIdNumAndAccountType(String idNum, AccountType accountType); | |||
} |
@@ -4,8 +4,10 @@ package cn.com.taiji.iaw.tools; | |||
import cn.com.taiji.common.manager.AbstractManager; | |||
import cn.com.taiji.common.manager.ManagerException; | |||
import cn.com.taiji.core.entity.basic.QtkCustomerInfo; | |||
import cn.com.taiji.core.entity.dict.basic.UserType; | |||
import cn.com.taiji.core.entity.dict.basic.AccountType; | |||
import cn.com.taiji.core.entity.user.AccountInfo; | |||
import cn.com.taiji.core.repo.jpa.basic.QtkCustomerInfoRepo; | |||
import cn.com.taiji.core.repo.jpa.user.AccountInfoRepo; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.stereotype.Component; | |||
@@ -27,7 +29,7 @@ public class WxLoginUserUtil extends AbstractManager { | |||
throw new ManagerException("身份认证信息错误"); | |||
} | |||
return customerInfoRepo.findByCustomerIdNumAndCustomerIdTypeAndUserType(accountInfo.getIdNum(), | |||
accountInfo.getIdType().getCode(), accountInfo.getUserType().getCode()); | |||
accountInfo.getIdType().getCode(), accountInfo.getAccountType().getCode()); | |||
} | |||
/** | |||
@@ -59,19 +61,19 @@ public class WxLoginUserUtil extends AbstractManager { | |||
*/ | |||
public AccountInfo getAccountInfoFromCustomerId(String customerId) throws ManagerException { | |||
QtkCustomerInfo customer = customerInfoRepo.findByCustomerId(customerId); | |||
AccountInfo accountInfo = accountInfoRepo.findByIdNumAndUserType(customer.getCustomerIdNum(), UserType.fromCode(customer.getUserType())); | |||
AccountInfo accountInfo = accountInfoRepo.findByIdNumAndAccountType(customer.getCustomerIdNum(), AccountType.fromCode(customer.getUserType().getCode())); | |||
if (accountInfo == null) { | |||
throw new ManagerException("身份认证信息错误"); | |||
} | |||
return accountInfo; | |||
} | |||
/* | |||
/** | |||
* 通过AccountInfo获得QtkCustomerInfo信息 | |||
*/ | |||
public QtkCustomerInfo getCustomerInfoFromAccountInfo(AccountInfo accountInfo) throws ManagerException { | |||
QtkCustomerInfo customer = customerInfoRepo.findByCustomerIdNumAndCustomerIdTypeAndUserType(accountInfo.getIdNum(), | |||
accountInfo.getIdType().getCode(), accountInfo.getUserType().getCode()); | |||
accountInfo.getIdType().getCode(), accountInfo.getAccountType().getCode()); | |||
if (customer == null) { | |||
throw new ManagerException("身份认证信息错误"); | |||
} |