feat: admin login userlogin config
This commit is contained in:
parent
d3ce851dd9
commit
d966e615a4
|
@ -0,0 +1,20 @@
|
|||
package com.afe.g3fo.admin.dto.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Author:fengjianhuang
|
||||
* @Package:com.afe.g3fo.admin.dto.req
|
||||
* @Project:g3fo-admin
|
||||
* @name:AdminLoginRequest
|
||||
* @Date:2023/5/26 15:02
|
||||
* @Filename:AdminLoginRequest
|
||||
*/
|
||||
@Data
|
||||
public class AdminLoginRequest implements Serializable {
|
||||
private String userName;
|
||||
private String loginPassword;
|
||||
private String loginChannel;
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.afe.g3fo.admin.dto.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @Author:jim.feng
|
||||
* @name:CreateUserRequest
|
||||
* @Date:2023/6/2 16:15
|
||||
*/
|
||||
@Data
|
||||
public class CreateUserRequest {
|
||||
@Schema(description = "user ID")
|
||||
@NotBlank
|
||||
private String userName;
|
||||
@Schema(description = "chinese name")
|
||||
@NotBlank
|
||||
private String localName;
|
||||
@Schema(description = "english name")
|
||||
@NotBlank
|
||||
private String engName;
|
||||
|
||||
private Integer userType;
|
||||
@Schema(description = "参考用户配置接口")
|
||||
@NotNull
|
||||
private Integer userStatus;
|
||||
|
||||
private String title;
|
||||
@Schema(description = "参考用户配置接口")
|
||||
private Integer branch;
|
||||
@Schema(description = "参考用户配置接口")
|
||||
private Integer department;
|
||||
|
||||
private String mobileNo;
|
||||
|
||||
private String email;
|
||||
|
||||
private LocalDateTime expiryDate;
|
||||
|
||||
|
||||
private Integer tradeOddlotFlg;
|
||||
|
||||
private BigDecimal maxClientPct;
|
||||
|
||||
private BigDecimal maxDeductPct;
|
||||
|
||||
private BigDecimal cnySingleOrderLimit;
|
||||
|
||||
private BigDecimal cnySingleOverrideLimit;
|
||||
@Schema(description = "参考用户配置接口")
|
||||
private Integer otpLogon;
|
||||
@Schema(description = "参考用户配置接口")
|
||||
private Integer otpChgpwd;
|
||||
@Schema(description = "参考用户配置接口")
|
||||
private Integer otpMethod;
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.afe.g3fo.admin.dto.resp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author:jim.feng
|
||||
* @name:AdminLoginRespond
|
||||
* @Date:2023/5/26 16:38
|
||||
*/
|
||||
@Data
|
||||
public class AdminLoginRespond implements Serializable {
|
||||
private String userName;
|
||||
|
||||
private String loginChannel;
|
||||
|
||||
private Long userId;
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.afe.g3fo.admin.enums;
|
||||
|
||||
import com.afe.g3fo.framework.exception.IException;
|
||||
|
||||
/**
|
||||
* @Author:jim.feng
|
||||
* @name:AdminEnum
|
||||
* @Date:2023/5/30 9:36
|
||||
*/
|
||||
public enum AdminEnum implements IException {
|
||||
|
||||
USERORPASSWORDERROR(15000,"");
|
||||
|
||||
|
||||
|
||||
private Integer errorId;
|
||||
|
||||
/** 错误消息 */
|
||||
private String message;
|
||||
AdminEnum(Integer errorId, String message) {
|
||||
this.errorId = errorId;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getErrorId() {
|
||||
return errorId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.afe.g3fo.admin.facade;
|
||||
|
||||
import com.afe.g3fo.admin.dto.req.AdminLoginRequest;
|
||||
import com.afe.g3fo.admin.dto.resp.AdminLoginRespond;
|
||||
import com.afe.g3fo.framework.common.Result;
|
||||
|
||||
/**
|
||||
* @Author:fengjianhuang
|
||||
* @Package:com.afe.g3fo.admin.facade
|
||||
* @Project:g3fo-admin
|
||||
* @name:AdminLoginFacade
|
||||
* @Date:2023/5/26 15:01
|
||||
* @Filename:AdminLoginFacade
|
||||
*/
|
||||
public interface AdminLoginFacade {
|
||||
|
||||
/** admin登录
|
||||
* @param adminLoginRequest
|
||||
* @return
|
||||
*/
|
||||
Result<AdminLoginRespond> adminLogin(AdminLoginRequest adminLoginRequest) ;
|
||||
|
||||
}
|
|
@ -48,11 +48,7 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.afe.g3fo</groupId>
|
||||
<artifactId>g3fo-framework-service</artifactId>
|
||||
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package com.afe.g3fo.admin.biz;
|
||||
|
||||
import com.afe.g3fo.base.dto.response.SystemCodeResponse;
|
||||
import com.afe.g3fo.base.facade.SystemCodeFacade;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author:jim.feng
|
||||
* @name:UserBiz
|
||||
* @Date:2023/6/1 17:55
|
||||
*/
|
||||
@Component
|
||||
public class UserBiz {
|
||||
|
||||
static List<String> userType= List.of("USST","DEPT","CARO","OTPL","OTPP","OTPM");
|
||||
@DubboReference
|
||||
SystemCodeFacade systemCodeFacade;
|
||||
|
||||
public Map<String,List<SystemCodeResponse>> getCreateUserConfig(){
|
||||
// List<SystemCodeResponse> systemCodeResponses=new ArrayList<>();
|
||||
// userType.stream().forEach( tye->{
|
||||
// systemCodeResponses.addAll(systemCodeFacade.getByCodeType(tye)) ;
|
||||
// });
|
||||
List<SystemCodeResponse> byCodeByTypes = systemCodeFacade.getByCodeByTypes(userType);
|
||||
Map<String, List<SystemCodeResponse>> collect = byCodeByTypes.stream()
|
||||
.collect(Collectors.groupingBy(SystemCodeResponse::getCodeType));
|
||||
return collect;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package com.afe.g3fo.admin.config;
|
||||
|
||||
import com.afe.g3fo.admin.exception.AdminBizException;
|
||||
import com.afe.g3fo.framework.common.Result;
|
||||
import com.afe.g3fo.framework.service.exception.GlobalExceptionHandler;
|
||||
import com.afe.g3fo.plugin.dubbo.exception.DubboException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
/**
|
||||
* @Author:fengjianhuang
|
||||
* @Package:com.afe.g3fo.user.exception
|
||||
* @Project:g3fo-user
|
||||
* @name:UserGlobalExceptionHandler
|
||||
* @Date:2023/5/15 14:00
|
||||
* @Filename:UserGlobalExceptionHandler
|
||||
*/
|
||||
@ControllerAdvice
|
||||
@Slf4j
|
||||
public class UserGlobalExceptionHandler extends GlobalExceptionHandler {
|
||||
@ResponseBody
|
||||
@ExceptionHandler(DubboException.class)
|
||||
public Result<?> handleRpcException(DubboException e, HttpServletRequest request) {
|
||||
log.error(e.getMessage(), e);
|
||||
String code = String.valueOf(e.getCode());
|
||||
return StringUtils.isNotBlank(code) ? Result.error(code, e.getMessage()) : Result.error(e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*/
|
||||
@ResponseBody
|
||||
@ExceptionHandler(AdminBizException.class)
|
||||
public Result<?> handleServiceException(AdminBizException e, HttpServletRequest request) {
|
||||
log.error(e.getMessage(), e);
|
||||
String code = e.getCode();
|
||||
return StringUtils.isNotBlank(code) ? Result.error(code, e.getMessage()) : Result.error(e.getMessage());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.afe.g3fo.admin.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* (MAdminLoginInfo)表实体类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-05-26 14:54:10
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
@TableName("m_admin_login_info")
|
||||
public class AdminLoginInfo extends Model<AdminLoginInfo> {
|
||||
|
||||
private Long loginInfoId;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String userName;
|
||||
|
||||
private String loginChannel;
|
||||
|
||||
private Integer loginStatus;
|
||||
|
||||
private String loginPassword;
|
||||
|
||||
private Integer retryCount;
|
||||
|
||||
private Date pwdExpiryDate;
|
||||
|
||||
private Date lastLoginDate;
|
||||
|
||||
private String createBy;
|
||||
|
||||
private Date createOn;
|
||||
|
||||
private String updateBy;
|
||||
|
||||
private Date updateOn;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.afe.g3fo.admin.facade.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
|
||||
import com.afe.g3fo.admin.dto.req.AdminLoginRequest;
|
||||
import com.afe.g3fo.admin.dto.resp.AdminLoginRespond;
|
||||
import com.afe.g3fo.admin.entity.AdminLoginInfo;
|
||||
import com.afe.g3fo.admin.enums.AdminEnum;
|
||||
import com.afe.g3fo.admin.facade.AdminLoginFacade;
|
||||
import com.afe.g3fo.admin.service.AdminLoginInfoService;
|
||||
import com.afe.g3fo.admin.util.PasswordEncryptionUtils;
|
||||
import com.afe.g3fo.framework.common.Result;
|
||||
|
||||
import com.afe.g3fo.plugin.dubbo.exception.AssertsDubo;
|
||||
|
||||
import com.afe.g3fo.plugin.dubbo.exception.DubboException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @Author:fengjianhuang
|
||||
* @Package:com.afe.g3fo.admin.facade
|
||||
* @Project:g3fo-admin
|
||||
* @name:AdminLoginFacade
|
||||
* @Date:2023/5/26 15:01
|
||||
* @Filename:AdminLoginFacade
|
||||
*/
|
||||
@DubboService
|
||||
@AllArgsConstructor
|
||||
public class AdminLoginFacadeImpl implements AdminLoginFacade {
|
||||
|
||||
private final AdminLoginInfoService adminLoginInfoService;
|
||||
|
||||
@Override
|
||||
public Result<AdminLoginRespond> adminLogin(AdminLoginRequest adminLoginRequest) {
|
||||
|
||||
QueryWrapper<AdminLoginInfo> queryWrapper=new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(AdminLoginInfo::getUserName,adminLoginRequest.getUserName());
|
||||
queryWrapper.lambda().eq(AdminLoginInfo::getLoginChannel,adminLoginRequest.getLoginChannel());
|
||||
AdminLoginInfo userLoginInfo = adminLoginInfoService.getOne(queryWrapper);
|
||||
AssertsDubo.notNull(userLoginInfo, AdminEnum.USERORPASSWORDERROR);
|
||||
try {
|
||||
if(PasswordEncryptionUtils.encrypt(adminLoginRequest.getLoginPassword()).equals(userLoginInfo.getLoginPassword())){
|
||||
AdminLoginRespond adminLoginRespond = BeanUtil.copyProperties(userLoginInfo,AdminLoginRespond.class);
|
||||
|
||||
return Result.ok(adminLoginRespond);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new DubboException(e);
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.afe.g3fo.admin.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.afe.g3fo.admin.entity.AdminLoginInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* (MAdminLoginInfo)表数据库访问层
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-05-26 14:54:10
|
||||
*/
|
||||
@Mapper
|
||||
public interface AdminLoginInfoMapper extends BaseMapper<AdminLoginInfo> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.afe.g3fo.admin.service;
|
||||
|
||||
import com.afe.g3fo.admin.mapper.AdminLoginInfoMapper;
|
||||
import com.afe.g3fo.base.dto.response.SystemCodeResponse;
|
||||
import com.afe.g3fo.base.facade.SystemCodeFacade;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.afe.g3fo.admin.entity.AdminLoginInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (MAdminLoginInfo)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2023-05-26 14:54:10
|
||||
*/
|
||||
@Service
|
||||
public class AdminLoginInfoService extends ServiceImpl<AdminLoginInfoMapper, AdminLoginInfo> {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
//package com.afe.g3fo.admin.service.impl;
|
||||
//
|
||||
//import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
//import com.afe.g3fo.admin.mapper.AdminLoginInfoMapper;
|
||||
//import com.afe.g3fo.admin.entity.AdminLoginInfo;
|
||||
//import com.afe.g3fo.admin.service.AdminLoginInfoService;
|
||||
//import org.springframework.stereotype.Service;
|
||||
//
|
||||
///**
|
||||
// * (MAdminLoginInfo)表服务实现类
|
||||
// *
|
||||
// * @author makejava
|
||||
// * @since 2023-05-26 14:54:10
|
||||
// */
|
||||
//@Service
|
||||
//public class AdminLoginInfoServiceImpl extends ServiceImpl<AdminLoginInfoMapper, AdminLoginInfo> implements AdminLoginInfoService {
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
//
|
|
@ -0,0 +1,51 @@
|
|||
package com.afe.g3fo.admin.util;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.security.Key;
|
||||
|
||||
public class PasswordEncryptionUtils {
|
||||
|
||||
private static final String ALGORITHM = "AES";
|
||||
private static final byte[] KEY_VALUE = new byte[] { 'T', 'h', 'i', 's', 'I', 's', 'A', 'S',
|
||||
'e', 'c', 'r', 'e', 't', 'K', 'e', 'y' }; // 16字节
|
||||
|
||||
public static String encrypt(String password) throws Exception {
|
||||
Key key = generateKey();
|
||||
Cipher cipher = Cipher.getInstance(ALGORITHM);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key);
|
||||
byte[] encryptedByteValue = cipher.doFinal(password.getBytes("UTF-8"));
|
||||
return bytesToHex(encryptedByteValue);
|
||||
}
|
||||
|
||||
public static String decrypt(String password) throws Exception {
|
||||
Key key = generateKey();
|
||||
Cipher cipher = Cipher.getInstance(ALGORITHM);
|
||||
cipher.init(Cipher.DECRYPT_MODE, key);
|
||||
byte[] decryptedByteValue = cipher.doFinal(hexToBytes(password));
|
||||
return new String(decryptedByteValue,"UTF-8");
|
||||
}
|
||||
|
||||
private static Key generateKey() throws Exception {
|
||||
return new SecretKeySpec(KEY_VALUE, ALGORITHM);
|
||||
}
|
||||
|
||||
private static String bytesToHex(byte[] bytes) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (byte b : bytes) {
|
||||
result.append(String.format("%02x", b));
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private static byte[] hexToBytes(String hexString) {
|
||||
int length = hexString.length();
|
||||
byte[] data = new byte[length/2];
|
||||
|
||||
for (int i=0; i<length; i+=2) {
|
||||
data[i/2] = (byte) ((Character.digit(hexString.charAt(i), 16) << 4)
|
||||
+ Character.digit(hexString.charAt(i+1), 16));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
|
@ -20,4 +20,5 @@ spring:
|
|||
refresh: false
|
||||
- data-id: redis.yml
|
||||
- data-id: mysql.yml
|
||||
- data-id: common.yml
|
||||
- data-id: common.yml
|
||||
- data-id: rocketmq.yml
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.afe.g3fo.user.mapper.UserInfoMapper">
|
||||
|
||||
</mapper>
|
|
@ -1,166 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.afe.g3fo.user.mapper.UserLoginInfoMapper">
|
||||
|
||||
<!-- <resultMap type="com.afe.g3fo.user.entity.UserLoginInfo" id="UserLoginInfoMap">-->
|
||||
<!-- <result property="loginInfoId" column="login_info_id" jdbcType="INTEGER"/>-->
|
||||
<!-- <result property="userId" column="user_id" jdbcType="INTEGER"/>-->
|
||||
<!-- <result property="userName" column="user_name" jdbcType="VARCHAR"/>-->
|
||||
<!-- <result property="loginChannel" column="login_channel" jdbcType="VARCHAR"/>-->
|
||||
<!-- <result property="loginStatus" column="login_status" jdbcType="INTEGER"/>-->
|
||||
<!-- <result property="loginPassword" column="login_password" jdbcType="VARCHAR"/>-->
|
||||
<!-- <result property="retryCount" column="retry_count" jdbcType="INTEGER"/>-->
|
||||
<!-- <result property="pwdExpiryDate" column="pwd_expiry_date" jdbcType="TIMESTAMP"/>-->
|
||||
<!-- <result property="lastLoginDate" column="last_login_date" jdbcType="TIMESTAMP"/>-->
|
||||
<!-- </resultMap>-->
|
||||
|
||||
<!-- <!–查询单个–>-->
|
||||
<!-- <select id="queryById" resultMap="UserLoginInfoMap">-->
|
||||
<!-- select-->
|
||||
<!-- login_info_id, user_id, user_name, login_channel, login_status, login_password, retry_count, pwd_expiry_date, last_login_date-->
|
||||
<!-- from user_login_info-->
|
||||
<!-- where login_info_id = #{loginInfoId}-->
|
||||
<!-- </select>-->
|
||||
|
||||
<!-- <!–查询指定行数据–>-->
|
||||
<!-- <select id="queryAllByLimit" resultMap="UserLoginInfoMap">-->
|
||||
<!-- select-->
|
||||
<!-- login_info_id, user_id, user_name, login_channel, login_status, login_password, retry_count, pwd_expiry_date, last_login_date-->
|
||||
<!-- from user_login_info-->
|
||||
<!-- <where>-->
|
||||
<!-- <if test="loginInfoId != null">-->
|
||||
<!-- and login_info_id = #{loginInfoId}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="userId != null">-->
|
||||
<!-- and user_id = #{userId}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="userName != null and userName != ''">-->
|
||||
<!-- and user_name = #{userName}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="loginChannel != null and loginChannel != ''">-->
|
||||
<!-- and login_channel = #{loginChannel}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="loginStatus != null">-->
|
||||
<!-- and login_status = #{loginStatus}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="loginPassword != null and loginPassword != ''">-->
|
||||
<!-- and login_password = #{loginPassword}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="retryCount != null">-->
|
||||
<!-- and retry_count = #{retryCount}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="pwdExpiryDate != null">-->
|
||||
<!-- and pwd_expiry_date = #{pwdExpiryDate}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="lastLoginDate != null">-->
|
||||
<!-- and last_login_date = #{lastLoginDate}-->
|
||||
<!-- </if>-->
|
||||
<!-- </where>-->
|
||||
<!-- limit #{pageable.offset}, #{pageable.pageSize}-->
|
||||
<!-- </select>-->
|
||||
|
||||
<!-- <!–统计总行数–>-->
|
||||
<!-- <select id="count" resultType="java.lang.Long">-->
|
||||
<!-- select count(1)-->
|
||||
<!-- from user_login_info-->
|
||||
<!-- <where>-->
|
||||
<!-- <if test="loginInfoId != null">-->
|
||||
<!-- and login_info_id = #{loginInfoId}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="userId != null">-->
|
||||
<!-- and user_id = #{userId}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="userName != null and userName != ''">-->
|
||||
<!-- and user_name = #{userName}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="loginChannel != null and loginChannel != ''">-->
|
||||
<!-- and login_channel = #{loginChannel}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="loginStatus != null">-->
|
||||
<!-- and login_status = #{loginStatus}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="loginPassword != null and loginPassword != ''">-->
|
||||
<!-- and login_password = #{loginPassword}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="retryCount != null">-->
|
||||
<!-- and retry_count = #{retryCount}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="pwdExpiryDate != null">-->
|
||||
<!-- and pwd_expiry_date = #{pwdExpiryDate}-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="lastLoginDate != null">-->
|
||||
<!-- and last_login_date = #{lastLoginDate}-->
|
||||
<!-- </if>-->
|
||||
<!-- </where>-->
|
||||
<!-- </select>-->
|
||||
|
||||
<!-- <!–新增所有列–>-->
|
||||
<!-- <insert id="insert" keyProperty="loginInfoId" useGeneratedKeys="true">-->
|
||||
<!-- insert into user_login_info(user_id, user_name, login_channel, login_status, login_password, retry_count, pwd_expiry_date, last_login_date)-->
|
||||
<!-- values (#{userId}, #{userName}, #{loginChannel}, #{loginStatus}, #{loginPassword}, #{retryCount}, #{pwdExpiryDate}, #{lastLoginDate})-->
|
||||
<!-- </insert>-->
|
||||
|
||||
<!-- <insert id="insertBatch" keyProperty="loginInfoId" useGeneratedKeys="true">-->
|
||||
<!-- insert into user_login_info(user_id, user_name, login_channel, login_status, login_password, retry_count, pwd_expiry_date, last_login_date)-->
|
||||
<!-- values-->
|
||||
<!-- <foreach collection="entities" item="entity" separator=",">-->
|
||||
<!-- (#{entity.userId}, #{entity.userName}, #{entity.loginChannel}, #{entity.loginStatus}, #{entity.loginPassword}, #{entity.retryCount}, #{entity.pwdExpiryDate}, #{entity.lastLoginDate})-->
|
||||
<!-- </foreach>-->
|
||||
<!-- </insert>-->
|
||||
|
||||
<!-- <insert id="insertOrUpdateBatch" keyProperty="loginInfoId" useGeneratedKeys="true">-->
|
||||
<!-- insert into user_login_info(user_id, user_name, login_channel, login_status, login_password, retry_count, pwd_expiry_date, last_login_date)-->
|
||||
<!-- values-->
|
||||
<!-- <foreach collection="entities" item="entity" separator=",">-->
|
||||
<!-- (#{entity.userId}, #{entity.userName}, #{entity.loginChannel}, #{entity.loginStatus}, #{entity.loginPassword}, #{entity.retryCount}, #{entity.pwdExpiryDate}, #{entity.lastLoginDate})-->
|
||||
<!-- </foreach>-->
|
||||
<!-- on duplicate key update-->
|
||||
<!-- user_id = values(user_id),-->
|
||||
<!-- user_name = values(user_name),-->
|
||||
<!-- login_channel = values(login_channel),-->
|
||||
<!-- login_status = values(login_status),-->
|
||||
<!-- login_password = values(login_password),-->
|
||||
<!-- retry_count = values(retry_count),-->
|
||||
<!-- pwd_expiry_date = values(pwd_expiry_date),-->
|
||||
<!-- last_login_date = values(last_login_date)-->
|
||||
<!-- </insert>-->
|
||||
|
||||
<!-- <!–通过主键修改数据–>-->
|
||||
<!-- <update id="update">-->
|
||||
<!-- update user_login_info-->
|
||||
<!-- <set>-->
|
||||
<!-- <if test="userId != null">-->
|
||||
<!-- user_id = #{userId},-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="userName != null and userName != ''">-->
|
||||
<!-- user_name = #{userName},-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="loginChannel != null and loginChannel != ''">-->
|
||||
<!-- login_channel = #{loginChannel},-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="loginStatus != null">-->
|
||||
<!-- login_status = #{loginStatus},-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="loginPassword != null and loginPassword != ''">-->
|
||||
<!-- login_password = #{loginPassword},-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="retryCount != null">-->
|
||||
<!-- retry_count = #{retryCount},-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="pwdExpiryDate != null">-->
|
||||
<!-- pwd_expiry_date = #{pwdExpiryDate},-->
|
||||
<!-- </if>-->
|
||||
<!-- <if test="lastLoginDate != null">-->
|
||||
<!-- last_login_date = #{lastLoginDate},-->
|
||||
<!-- </if>-->
|
||||
<!-- </set>-->
|
||||
<!-- where login_info_id = #{loginInfoId}-->
|
||||
<!-- </update>-->
|
||||
|
||||
<!-- <!–通过主键删除–>-->
|
||||
<!-- <delete id="deleteById">-->
|
||||
<!-- delete from user_login_info where login_info_id = #{loginInfoId}-->
|
||||
<!-- </delete>-->
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
package com.afe.g3fo.user;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.afe.g3fo.admin.entity.AdminLoginInfo;
|
||||
import com.afe.g3fo.admin.service.AdminLoginInfoService;
|
||||
import com.afe.g3fo.framework.common.Result;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
|
@ -8,6 +10,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:fengjianhuang
|
||||
|
@ -21,46 +24,12 @@ import java.time.LocalDateTime;
|
|||
@SpringBootTest
|
||||
public class LoginTest {
|
||||
@Resource
|
||||
UserLoginInfoService userLoginInfoService;
|
||||
@Resource
|
||||
UserInfoService userInfoService;
|
||||
@Resource
|
||||
UserLoginInfoMapper userLoginInfoMapper;
|
||||
@Resource
|
||||
UserLoginFacade userLoginFacade;
|
||||
AdminLoginInfoService adminLoginInfoService;
|
||||
|
||||
@Test
|
||||
void insertData() throws Exception {
|
||||
UserLoginInfo userLoginInfo =new UserLoginInfo();
|
||||
userLoginInfo.setLoginChannel("PT");
|
||||
userLoginInfo.setUserName("jim");
|
||||
userLoginInfo.setLoginPassword(PasswordEncryptionUtils.encrypt("Afe12345"));
|
||||
userLoginInfo.setLoginStatus(1);
|
||||
userLoginInfo.setUserId(231313131133l);
|
||||
userLoginInfo.setLastLoginDate(LocalDateTime.now());
|
||||
userLoginInfo.setPwdExpiryDate(LocalDateTime.now());
|
||||
// int insert = userLoginInfoMapper.insert(userLoginInfo);
|
||||
userLoginInfoService.save(userLoginInfo);
|
||||
// List<UserInfoEntity> list = userInfoService.list();
|
||||
List<AdminLoginInfo> list = adminLoginInfoService.list();
|
||||
System.currentTimeMillis();
|
||||
}
|
||||
@Test
|
||||
void login(){
|
||||
UserLoginReq userLoginReq=new UserLoginReq();
|
||||
userLoginReq.setLoginPassword("Afe12345");
|
||||
userLoginReq.setUserName("jim");
|
||||
userLoginReq.setLoginChannel("PT");
|
||||
QueryWrapper<UserLoginInfo> queryWrapper=new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(UserLoginInfo::getUserName,userLoginReq.getUserName());
|
||||
queryWrapper.lambda().eq(UserLoginInfo::getLoginChannel,userLoginReq.getLoginChannel());
|
||||
UserLoginInfo userLoginInfo = userLoginInfoService.getOne(queryWrapper);
|
||||
try {
|
||||
if(PasswordEncryptionUtils.encrypt(userLoginReq.getLoginPassword()).equals(userLoginInfo.getLoginPassword())){
|
||||
UserLoginRsp userLoginRsp= BeanUtil.copyProperties(userLoginInfo,UserLoginRsp.class);
|
||||
return;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
package com.afe.g3fo.user;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @Author:fengjianhuang
|
||||
* @Package:com.afe.g3fo.user
|
||||
* @Project:g3fo-user
|
||||
* @name:UserTest
|
||||
* @Date:2023/5/9 16:32
|
||||
* @Filename:UserTest
|
||||
*/
|
||||
@SpringBootTest
|
||||
public class UserTest {
|
||||
@Resource
|
||||
UserInfoService userInfoService;
|
||||
|
||||
@Test
|
||||
void insertData() throws Exception {
|
||||
UserInfo userInfo =new UserInfo();
|
||||
userInfo.setCreateUser("sys");
|
||||
userInfo.setUserName("jim");
|
||||
userInfo.setLocalName("jim");
|
||||
userInfo.setEngName("jim");
|
||||
userInfo.setDepartment("");
|
||||
userInfo.setExpiryDate(LocalDateTime.now());
|
||||
userInfo.setCreatDate(LocalDateTime.now());
|
||||
userInfo.setUserStatus(1);
|
||||
userInfo.setUserType(1);
|
||||
userInfoService.save(userInfo);
|
||||
}
|
||||
}
|
||||
//package com.afe.g3fo.user;
|
||||
//
|
||||
//import jakarta.annotation.Resource;
|
||||
//import org.junit.jupiter.api.Test;
|
||||
//import org.springframework.boot.test.context.SpringBootTest;
|
||||
//
|
||||
//import java.time.LocalDateTime;
|
||||
//
|
||||
///**
|
||||
// * @Author:fengjianhuang
|
||||
// * @Package:com.afe.g3fo.user
|
||||
// * @Project:g3fo-user
|
||||
// * @name:UserTest
|
||||
// * @Date:2023/5/9 16:32
|
||||
// * @Filename:UserTest
|
||||
// */
|
||||
//@SpringBootTest
|
||||
//public class UserTest {
|
||||
// @Resource
|
||||
// UserInfoService userInfoService;
|
||||
//
|
||||
// @Test
|
||||
// void insertData() throws Exception {
|
||||
// UserInfo userInfo =new UserInfo();
|
||||
// userInfo.setCreateUser("sys");
|
||||
// userInfo.setUserName("jim");
|
||||
// userInfo.setLocalName("jim");
|
||||
// userInfo.setEngName("jim");
|
||||
// userInfo.setDepartment("");
|
||||
// userInfo.setExpiryDate(LocalDateTime.now());
|
||||
// userInfo.setCreatDate(LocalDateTime.now());
|
||||
// userInfo.setUserStatus(1);
|
||||
// userInfo.setUserType(1);
|
||||
// userInfoService.save(userInfo);
|
||||
// }
|
||||
//}
|
||||
|
|
Loading…
Reference in New Issue