chenjiahe
2021-11-30 e544dac4bddeb7c523beda5df20eedf0aa50f7f6
更改校验方式
1 文件已重命名
5个文件已添加
3个文件已修改
385 ■■■■■ 已修改文件
phi_platform_common/src/main/java/com/hx/phip/dao/mapper/PlatformApplicationMapper.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/resources/mapper/PlatformApplicationMapper.xml 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/common/InitController.java 98 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/controller/login/EmployeeLoginController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/interceptor/UserInterceptor.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/PlatformApplicationService.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/service/impl/PlatformApplicationServiceImpl.java 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/resources/application-local.properties 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/resources/application-prod.properties 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/java/com/hx/phip/dao/mapper/PlatformApplicationMapper.java
New file
@@ -0,0 +1,35 @@
package com.hx.phip.dao.mapper;
import java.util.List;
import java.util.Map;
import com.hx.mybatisTool.SqlSentence;
import com.hx.phiappt.model.PlatformApplication;
public interface PlatformApplicationMapper {
    /**新增,返回主键*/
    int insert(PlatformApplication platformApplication);
    /**查询条数*/
    int selectCount(SqlSentence sqlSentence);
    /**查询条数*/
    int selectCountSql(SqlSentence sqlSentence);
    /**查询列表,返回实体类的List*/
    List<PlatformApplication> selectList(SqlSentence sqlSentence);
    /**查询列表,返回Map的List*/
    List<Map<String,Object>> selectListMap(SqlSentence sqlSentence);
    /**查询,返回单个实体*/
    PlatformApplication selectOne(SqlSentence sqlSentence);
    /**查询,返回单个map*/
    Map<String,Object> selectOneMap(SqlSentence sqlSentence);
    /**查询,返回实体类没有大数据的*/
    PlatformApplication selectOneByKey(Object object);
    /**查询,返回实体类有大数据的*/
    PlatformApplication selectOneByKeyBlob(Object object);
    /**更新,返回更新数量*/
    int updateWhere(SqlSentence sqlSentence);
    /**更新,返回更新数量*/
    int updateAll(PlatformApplication platformApplication);
    /**删除,返回删除数量*/
    int deleteWhere(SqlSentence sqlSentence);
    /**删除,返回删除数量*/
    int deleteById(Object object);
}
phi_platform_common/src/main/resources/mapper/PlatformApplicationMapper.xml
New file
@@ -0,0 +1,86 @@
<?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">
<!-- namespace:该mapper.xml映射文件的 唯一标识 -->
<mapper namespace="com.hx.phip.dao.mapper.PlatformApplicationMapper">
    <!-- 整个实体类修改,表字段=实体类字段-->
    <sql id="Update_Column_All">
        <trim prefixOverrides=",">
            ,name = #{name},appId = #{appId},secreKey = #{secreKey},rsaPublicKey = #{rsaPublicKey},rsaPrivateKey = #{rsaPrivateKey},remarks = #{remarks},isDel = #{isDel},createTime = #{createTime}
        </trim>
    </sql>
    <!--  后续通过  namespace.id-->
    <!--parameterType:输入参数的类型
    resultType:查询返回结果值的类型  ,返回类型  -->
    <insert id="insert" parameterType="com.hx.phiappt.model.PlatformApplication">
        <selectKey keyProperty="id" resultType="String" order="BEFORE">
               select replace(uuid(),'-','') from dual
        </selectKey>
        insert into platform_application (id,name,appId,secreKey,rsaPublicKey,rsaPrivateKey,remarks,isDel,createTime)  values (#{id},#{name},#{appId},#{secreKey},#{rsaPublicKey},#{rsaPrivateKey},#{remarks},#{isDel},#{createTime})
    </insert>
    <select id="selectList" resultType="com.hx.phiappt.model.PlatformApplication" parameterType="com.hx.mybatisTool.SqlSentence" >
        ${sqlSentence}
    </select>
    <select id="selectListMap" resultType="java.util.Map" parameterType="com.hx.mybatisTool.SqlSentence" >
            ${sqlSentence}
    </select>
    <select id="selectOne" resultType="com.hx.phiappt.model.PlatformApplication" parameterType="com.hx.mybatisTool.SqlSentence" >
        ${sqlSentence}
    </select>
    <select id="selectOneMap" resultType="java.util.Map" parameterType="com.hx.mybatisTool.SqlSentence" >
            ${sqlSentence}
    </select>
    <select id="selectCount" resultType="int" parameterType="com.hx.mybatisTool.SqlSentence" >
            select
                COUNT(*)
            from platform_application
                WHERE ${sqlSentence}
    </select>
    <select id="selectCountSql" resultType="int" parameterType="com.hx.mybatisTool.SqlSentence" >
            ${sqlSentence}
     </select>
    <select id="selectOneByKey" resultType="com.hx.phiappt.model.PlatformApplication" parameterType="java.lang.Object" >
        select
            id,name,appId,secreKey,rsaPublicKey,rsaPrivateKey,remarks,isDel,createTime
        from platform_application
        WHERE id = #{value}
    </select>
    <select id="selectOneByKeyBlob" resultType="com.hx.phiappt.model.PlatformApplication" parameterType="java.lang.Object" >
        select
            id,name,appId,secreKey,rsaPublicKey,rsaPrivateKey,remarks,isDel,createTime
        from platform_application
        WHERE id = #{value}
    </select>
    <update id="updateWhere" parameterType="com.hx.mybatisTool.SqlSentence">
        update
            platform_application
        SET ${sqlSentence}
    </update>
    <update id="updateAll" parameterType="com.hx.phiappt.model.PlatformApplication">
        update platform_application
            SET <include refid="Update_Column_All"/>
        WHERE id = #{id}
    </update>
    <delete id="deleteWhere"  parameterType="com.hx.mybatisTool.SqlSentence">
        delete from platform_application WHERE ${sqlSentence}
    </delete>
    <delete id="deleteById"  parameterType="java.lang.Object">
        delete from platform_application WHERE id = #{value}
    </delete>
</mapper>
phi_platform_user/src/main/java/com/hx/phip/common/InitController.java
New file
@@ -0,0 +1,98 @@
package com.hx.phip.common;
import com.alibaba.fastjson.JSONObject;
import com.hx.common.BaseController;
import com.hx.mybatisTool.SqlSentence;
import com.hx.phiappt.model.PlatformApplication;
import com.hx.phip.service.PlatformApplicationService;
import com.hx.redis.RedisUtil;
import com.hx.util.HttpMethodUtil;
import com.hx.util.rsa.RSAUtil;
import com.platform.entity.ThirtApplication;
import com.platform.resultTool.PlatformResult;
import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 初始化
 *
 * @USER: chenjiahe
 * @DATE: 2021/10/29
 **/
@RestController
@RequestMapping("/init")
public class InitController extends BaseController {
    @Resource
    private RedisUtil redisUtil;
    @Resource
    private PlatformApplicationService platformApplicationService;
    /**初始化应用的redis
     */
    @RequestMapping(value = "/application/redis",method = RequestMethod.POST)
    public PlatformResult typeList(HttpServletRequest request) {
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values = new HashMap<>();
        values.put("isDel", PlatformApplication.NO);
        sqlSentence.sqlSentence("SELECT * FROM platform_application",values);
        List<PlatformApplication> applicationList = platformApplicationService.selectList(sqlSentence);
        for(PlatformApplication application:applicationList){
            if(!PlatformApplication.NO.equals(application.getIsDel())){
                redisUtil.delete(application.getAppId());
                continue;
            }
            if(!PlatformApplication.YES.equals(application.getIsUp())){
                redisUtil.delete(application.getAppId());
                continue;
            }
            JSONObject object = new JSONObject();
            object.put("appId",application.getAppId());
            object.put("privateKey",application.getRsaPrivateKey());
            object.put("name",application.getName());
            redisUtil.set(application.getAppId(),object);
        }
        Map<String,Object> data = new HashMap<>();
        data.put("data","is ok");
        return PlatformResult.success(data);
    }
    public static void main(String[] args) {
        String publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAgR8YuvjPRVTjlGwzzIfqsHXZzQ/mCJS3" +
                "0Xg3D8v+VnPqrsM2iPSbB1ztu6VKC3SAffwyDQ2NXWxKwNuYFNakbAHZ9EaK+YXdGfajFsaiAHuK" +
                "5GZuJeGGkbxN3WrRkXSDjYfuhnn+8aXc7dlGIigTPenEGhKn+5MlPOT/pBVH+EHnJENtLj37UmUR" +
                "evUR1QD7QplG6tzzlO789auLwBsvcxjx9ZF9gPZGMngX/k0Bw8f+/HBIZBdbmUtMCefGAvqwkgjL" +
                "ZWpBScQW/PY87gtvxBe0Q9xCEyOdwBcT8k/UZr2vIRwrJlNSeW4Lx4V6+AaPDawABKU30c1uQmxz" +
                "bOr5aQIDAQAB";
        String sign = RSAUtil.publicEncrypt("123456789_"+System.currentTimeMillis()+"_1234534",publicKey);
        sign = sign.replaceAll("\n|\r","");
        Map<String,String> header = new HashMap<>();
        header.put("appId","1234567890");
        header.put("sign", sign);
        System.out.println("header:"+header.toString());
        String data = HttpMethodUtil.HttpURLUtilJson("http://test3.phiskin.com/phip/employee/list",null,null,header,"POST");
        System.out.println("data:"+data);
    }
}
phi_platform_user/src/main/java/com/hx/phip/controller/login/EmployeeLoginController.java
File was renamed from phi_platform_user/src/main/java/com/hx/phip/controller/EmployeeLoginController.java
@@ -1,4 +1,4 @@
package com.hx.phip.controller;
package com.hx.phip.controller.login;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
phi_platform_user/src/main/java/com/hx/phip/interceptor/UserInterceptor.java
@@ -2,8 +2,13 @@
import com.hx.common.BaseController;
import com.hx.phip.config.CustomParameter;
import com.hx.redis.RedisUtil;
import com.hx.util.StringUtils;
import com.platform.constants.LoginConstant;
import com.platform.entity.ThirtApplication;
import com.platform.resultTool.PlatformCode;
import com.platform.resultTool.PlatformResult;
import com.platform.verification.ApplicationTool;
import com.platform.verification.VerificationTool;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
@@ -30,6 +35,11 @@
    @Resource
    private CustomParameter rsaParameter;
    @Resource
    private RedisUtil redisUtil;
    /**有效时间(秒)*/
    private static final long ttlMillis = 42300;
    /**设置拦截的位置
     * 拦截要校验的包
@@ -52,10 +62,14 @@
        HttpServletRequest request = sra.getRequest();
        Map<String, String> header = HttpServletRequestUtil.getHeader(request);*/
        String sign = request.getHeader("sign");
        String appId = request.getHeader("appid");
        String appId = request.getHeader("appId");
        if(StringUtils.isEmpty(appId)){
            appId = request.getHeader("appid");
        }
        ThirtApplication thirtApplication =  ApplicationTool.jsonToEntity(appId,redisUtil);
        //校验
        PlatformResult platformResult = VerificationTool.verification(appId,sign,rsaParameter.getAppId(),rsaParameter.getPrivatekey());
        PlatformResult platformResult = VerificationTool.verification(appId,sign,thirtApplication,request);
        if(!PlatformCode.SUCCESS.equals(platformResult.getCode())){
            return platformResult;
        }
phi_platform_user/src/main/java/com/hx/phip/service/PlatformApplicationService.java
New file
@@ -0,0 +1,33 @@
package com.hx.phip.service;
import com.hx.phiappt.model.PlatformApplication;
import com.hx.mybatisTool.SqlSentence;
import java.util.List;
import java.util.Map;
public interface PlatformApplicationService {
    int selectCount(SqlSentence sqlSentence);
    void insert(PlatformApplication platformApplication);
    List<PlatformApplication> selectList(SqlSentence sqlSentence);
    List<Map<String,Object>> selectListMap(SqlSentence sqlSentence);
    PlatformApplication selectOne(SqlSentence sqlSentence);
    Map<String,Object> selectOneMap(SqlSentence sqlSentence);
    PlatformApplication selectOneByKey(Object object);
    PlatformApplication selectOneByKeyBlob(Object object);
    void updateAll(PlatformApplication platformApplication);
    void updateWhere(SqlSentence sqlSentence);
    void deleteOne(String delId);
}
phi_platform_user/src/main/java/com/hx/phip/service/impl/PlatformApplicationServiceImpl.java
New file
@@ -0,0 +1,101 @@
package com.hx.phip.service.impl;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.hx.exception.TipsException;
import com.hx.phip.dao.mapper.PlatformApplicationMapper;
import com.hx.phiappt.model.PlatformApplication;
import com.hx.phip.service.PlatformApplicationService;
import com.hx.mybatisTool.SqlSentence;
import java.util.List;
import java.util.Map;
@Transactional
@Service
public class PlatformApplicationServiceImpl implements PlatformApplicationService {
    @Resource
    private PlatformApplicationMapper platformApplicationMapper;
    /**查询列表*/
    @Override
    public List<PlatformApplication> selectList(SqlSentence sqlSentence) {
        return platformApplicationMapper.selectList(sqlSentence);
    }
    /**查询列表*/
    @Override
    public List<Map<String,Object>> selectListMap(SqlSentence sqlSentence) {
        return platformApplicationMapper.selectListMap(sqlSentence);
    }
    /**查询单个*/
    @Override
    public PlatformApplication selectOne(SqlSentence sqlSentence) {
        return platformApplicationMapper.selectOne(sqlSentence);
    }
    /**查询单个*/
    @Override
    public Map<String,Object> selectOneMap(SqlSentence sqlSentence) {
        return platformApplicationMapper.selectOneMap(sqlSentence);
    }
    /**查询单个,大数据不拿取*/
    @Override
    public PlatformApplication selectOneByKey(Object object) {
        return platformApplicationMapper.selectOneByKey(object);
    }
    /**查询单个,大数据拿取*/
    @Override
    public PlatformApplication selectOneByKeyBlob(Object object) {
        return platformApplicationMapper.selectOneByKeyBlob(object);
    }
    /**新增*/
    @Override
    public void insert(PlatformApplication platformApplication) {
        int count = platformApplicationMapper.insert(platformApplication);
        if(count != 1) {
            throw new TipsException("新增失败!");
        }
    }
    /**修改*/
    @Override
    public void updateAll(PlatformApplication platformApplication) {
        int count = platformApplicationMapper.updateAll(platformApplication);
        if(count!=1) {
            throw new TipsException("保存失败!");
        }
    }
    /**修改*/
    @Override
    public void updateWhere(SqlSentence sqlSentence) {
        int count = platformApplicationMapper.updateWhere(sqlSentence);
        if(count!=1) {
            throw new TipsException("保存失败!");
        }
    }
    /**删除一个*/
    @Override
    public void deleteOne(String delId) {
        int count = platformApplicationMapper.deleteById(delId);
        if(count!=1) {
            throw new TipsException("删除失败!");
        }
    }
    /**查询条数*/
    @Override
    public int selectCount(SqlSentence sqlSentence) {
        int count = platformApplicationMapper.selectCount(sqlSentence);
        return count;
    }
}
phi_platform_user/src/main/resources/application-local.properties
@@ -66,15 +66,13 @@
#redis\uFFFD\uFFFD\uFFFD\uFFFD
# Redis\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u05B7
spring.redis.host=r-bp16fgy4t2giny01ovpd.redis.rds.aliyuncs.com
#spring.redis.host=127.0.0.1
spring.redis.host= 101.200.173.220
# Redis\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u04F6\u02FF\uFFFD
spring.redis.port=6379
# Redis\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uB8E8\u012C\uFFFD\uFFFD\u03AA\uFFFD\u0563\uFFFD
spring.redis.password = ENC(P/vIymIjtc5h7kd6rhqPZApE99RK9jwlU2L0M8yQ2UI=)
#spring.redis.password=
spring.redis.password=cjh8899
# \uFFFD\uFFFD\uFFFD\u04F3\uFFFD\u02B1\u02B1\uFFFD\u48E8\uFFFD\uFFFD\uFFFD\uB8E9
spring.redis.timeout=5000
spring.redis.timeout=1000
# set database
spring.redis.database= 9
phi_platform_user/src/main/resources/application-prod.properties
@@ -71,7 +71,9 @@
# Redis\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uB8E8\u012C\uFFFD\uFFFD\u03AA\uFFFD\u0563\uFFFD
spring.redis.password=ENC(1rHggH3Vt6IgY2rAuHyBZb4aabOCAoOroQM5eYoT6so=)
# \uFFFD\uFFFD\uFFFD\u04F3\uFFFD\u02B1\u02B1\uFFFD\u48E8\uFFFD\uFFFD\uFFFD\uB8E9
spring.redis.timeout=1000
spring.redis.timeout=5000
# set database
spring.redis.database= 9
platform.pattern = prod