chenjiahe
2021-11-05 457890d43a4d42eb6d3ab5112bb5266e9909d1e2
新增优化
2个文件已添加
5个文件已修改
202 ■■■■■ 已修改文件
phi_platform_common/src/main/java/com/hx/phip/dao/mapper/SysParameterMapper.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/java/com/hx/phip/tool/ApplyParameterTool.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/resources/mapper/SysParameterMapper.xml 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_model/src/main/java/com/hx/phip/model/ApplyParameter.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/Rsa.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/controller/AccountTokenController.java 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/controller/EmployeeController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_common/src/main/java/com/hx/phip/dao/mapper/SysParameterMapper.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.phip.model.SysParameter;
public interface SysParameterMapper {
    /**新增,返回主键*/
    int insert(SysParameter sysParameter);
    /**查询条数*/
    int selectCount(SqlSentence sqlSentence);
    /**查询条数*/
    int selectCountSql(SqlSentence sqlSentence);
    /**查询列表,返回实体类的List*/
    List<SysParameter> selectList(SqlSentence sqlSentence);
    /**查询列表,返回Map的List*/
    List<Map<String,Object>> selectListMap(SqlSentence sqlSentence);
    /**查询,返回单个实体*/
    SysParameter selectOne(SqlSentence sqlSentence);
    /**查询,返回单个map*/
    Map<String,Object> selectOneMap(SqlSentence sqlSentence);
    /**查询,返回实体类没有大数据的*/
    SysParameter selectOneByKey(Object object);
    /**查询,返回实体类有大数据的*/
    SysParameter selectOneByKeyBlob(Object object);
    /**更新,返回更新数量*/
    int updateWhere(SqlSentence sqlSentence);
    /**更新,返回更新数量*/
    int updateAll(SysParameter sysParameter);
    /**删除,返回删除数量*/
    int deleteWhere(SqlSentence sqlSentence);
    /**删除,返回删除数量*/
    int deleteById(Object object);
}
phi_platform_common/src/main/java/com/hx/phip/tool/ApplyParameterTool.java
@@ -47,5 +47,22 @@
        return spplyParameter;
    }
    /**企业联系我
     * @param corpId
     * @param commonService
     * @return
     */
    public static ApplyParameter getContact(String corpId, CommonService commonService){
        SqlSentence sqlSentence = new SqlSentence();
        Map<String,Object> values = new HashMap<>();
        values.put("isDel",ApplyParameter.NO);
        values.put("corpId",corpId);
        values.put("type",ApplyParameter.TYPE_CORP_CONTACT);
        sqlSentence.sqlSentence("SELECT * FROM pla_apply_parameter WHERE isDel = #{m.isDel} AND corpId = #{m.corpId} AND type = #{m.type}",values);
        ApplyParameter spplyParameter = commonService.selectOne(ApplyParameterMapper.class,sqlSentence);
        return spplyParameter;
    }
}
phi_platform_common/src/main/resources/mapper/SysParameterMapper.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.SysParameterMapper">
    <!-- 整个实体类修改,表字段=实体类字段-->
    <sql id="Update_Column_All">
        <trim prefixOverrides=",">
            ,paramName = #{paramName},paramValue = #{paramValue},paramValue1 = #{paramValue1},isDel = #{isDel},createTime = #{createTime}
        </trim>
    </sql>
    <!--  后续通过  namespace.id-->
    <!--parameterType:输入参数的类型
    resultType:查询返回结果值的类型  ,返回类型  -->
    <insert id="insert" parameterType="com.hx.phip.model.SysParameter">
        <selectKey keyProperty="id" resultType="String" order="BEFORE">
               select replace(uuid(),'-','') from dual
        </selectKey>
        insert into pla_sys_parameter (id,paramName,paramValue,paramValue1,isDel,createTime)  values (#{id},#{paramName},#{paramValue},#{paramValue1},#{isDel},#{createTime})
    </insert>
    <select id="selectList" resultType="com.hx.phip.model.SysParameter" 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.phip.model.SysParameter" 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 pla_sys_parameter
                WHERE ${sqlSentence}
    </select>
    <select id="selectCountSql" resultType="int" parameterType="com.hx.mybatisTool.SqlSentence" >
            ${sqlSentence}
     </select>
    <select id="selectOneByKey" resultType="com.hx.phip.model.SysParameter" parameterType="java.lang.Object" >
        select
            id,paramName,paramValue,paramValue1,isDel,createTime
        from pla_sys_parameter
        WHERE id = #{value}
    </select>
    <select id="selectOneByKeyBlob" resultType="com.hx.phip.model.SysParameter" parameterType="java.lang.Object" >
        select
            id,paramName,paramValue,paramValue1,isDel,createTime
        from pla_sys_parameter
        WHERE id = #{value}
    </select>
    <update id="updateWhere" parameterType="com.hx.mybatisTool.SqlSentence">
        update
            pla_sys_parameter
        SET ${sqlSentence}
    </update>
    <update id="updateAll" parameterType="com.hx.phip.model.SysParameter">
        update pla_sys_parameter
            SET <include refid="Update_Column_All"/>
        WHERE id = #{id}
    </update>
    <delete id="deleteWhere"  parameterType="com.hx.mybatisTool.SqlSentence">
        delete from pla_sys_parameter WHERE ${sqlSentence}
    </delete>
    <delete id="deleteById"  parameterType="java.lang.Object">
        delete from pla_sys_parameter WHERE id = #{value}
    </delete>
</mapper>
phi_platform_model/src/main/java/com/hx/phip/model/ApplyParameter.java
@@ -19,6 +19,8 @@
    @Column(comment = "企业微信通讯录秘钥(AES加密)", length = 255, type = MySqlTypeConstant.VARCHAR)
    private String communiSecretKey;
    @Column(comment = "企业微信联系我秘钥(AES加密)", length = 255, type = MySqlTypeConstant.VARCHAR)
    private String contactSecretKey;
    @Column(comment = "企业微信应用秘钥(AES加密)", length = 255, type = MySqlTypeConstant.VARCHAR)
    private String applySecretKey;
@@ -33,10 +35,12 @@
    }
    ///////////////////////////////////////////////////
    /**企业小程序*/
    /**企业小程序应用*/
    public static final int TYPE_CORP_MP = 0;
    /**通讯录*/
    public static final int TYPE_CORP_COMMUNICATION = 1;
    /**联系我*/
    public static final int TYPE_CORP_CONTACT = 2;
@@ -87,4 +91,12 @@
    public void setCommuniSecretKey(String communiSecretKey) {
        this.communiSecretKey = communiSecretKey;
    }
    public String getContactSecretKey() {
        return contactSecretKey;
    }
    public void setContactSecretKey(String contactSecretKey) {
        this.contactSecretKey = contactSecretKey;
    }
}
phi_platform_user/src/main/java/com/hx/phip/Rsa.java
@@ -7,7 +7,7 @@
public class Rsa {
    public static void main(String[] args) {
       System.out.println("AES:"+AesUtil.aesEncryp("dfa4acbdea008099231db51ed49ff454"));
       System.out.println("AES:"+AesUtil.aesEncryp("uhWNSciQeVGDQEh0lSJlVp5dUNMunVCi6yjLKbvxZF8"));
        //配置文件数据加密
phi_platform_user/src/main/java/com/hx/phip/controller/AccountTokenController.java
@@ -13,6 +13,7 @@
import com.hx.util.HttpServletRequestUtil;
import com.hx.util.StringUtils;
import com.hx.util.corp.entity.WeiXinInfo;
import com.hx.util.rsa.RSAUtil;
import com.platform.exception.PlatTipsException;
import com.platform.resultTool.PlatformCode;
import com.platform.resultTool.PlatformResult;
@@ -105,6 +106,50 @@
        if (StringUtils.isEmpty(accountToken.getCorpId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"corpId is required");
        }
        //获取应用数据
        ApplyParameter applyParameter = ApplyParameterTool.getContact(accountToken.getCorpId(),commonService);
        if(applyParameter == null){
            throw new PlatTipsException(PlatformCode.ERROR_TIPS,"corpId is error");
        }
        SysParameter sysParameter = WeiXinCorpMpUtil.getApplicationAccessToken(commonService,applyParameter.getCorpId(),AesUtil.aesDecryp(applyParameter.getContactSecretKey()));
        if(sysParameter == null){
            throw new PlatTipsException(PlatformCode.ERROR_SYSTEM,"服务错误"+ SystemCode.ERROR_GET_CORP_TOKEN);
        }
        Map<String,Object> data = new HashMap<>();
        data.put("access_token",sysParameter.getParamValue());
        data.put("create_time",DateUtil.formatDate(sysParameter.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
        data.put("expires_in",Integer.parseInt(sysParameter.getParamValue1()));
        data.put("expires_surplus",secondNum(sysParameter.getCreateTime(),Integer.parseInt(sysParameter.getParamValue1())));
        return PlatformResult.success(data);
    }
    /**获取企业应用token*/
    @RequestMapping(value = "/apply/get_token",method = RequestMethod.POST)
    public PlatformResult applyToken(HttpServletRequest request) {
        //获取返回参数
        String bodydata = HttpServletRequestUtil.getBody(request);
        if(StringUtils.isEmpty(bodydata)){
            throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA,"数据格式错误");
        }
        AccountToken accountToken = null;
        try{
            accountToken = JSONObject.parseObject(bodydata,AccountToken.class);
        }catch (Exception e){
            throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA,"数据格式错误");
        }
        if(accountToken == null){
            throw new PlatTipsException(PlatformCode.ERROR_BODY_DATA,"数据格式错误");
        }
        if (StringUtils.isEmpty(accountToken.getCorpId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"corpId is required");
        }
        if (StringUtils.isEmpty(accountToken.getMpId())) {
            throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL,"mpId is required");
        }
@@ -129,6 +174,7 @@
    }
    /**
     * token剩余时间
     * @param createTime 获取时间
phi_platform_user/src/main/java/com/hx/phip/controller/EmployeeController.java
@@ -14,6 +14,7 @@
import com.hx.redis.RedisUtil;
import com.hx.util.HttpServletRequestUtil;
import com.hx.util.StringUtils;
import com.hx.util.rsa.RSAUtil;
import com.platform.exception.PlatTipsException;
import com.platform.resultTool.PlatformCode;
import com.platform.resultTool.PlatformResult;
@@ -38,7 +39,6 @@
@RestController
@RequestMapping("/employee")
public class EmployeeController extends BaseController {
    //log4j日志
    private static Logger logger = LoggerFactory.getLogger(EmployeeController.class.getName());