New file |
| | |
| | | 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); |
| | | } |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | <?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> |
| | |
| | | |
| | | @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; |
| | |
| | | } |
| | | |
| | | /////////////////////////////////////////////////// |
| | | /**企业小程序*/ |
| | | /**企业小程序应用*/ |
| | | public static final int TYPE_CORP_MP = 0; |
| | | /**通讯录*/ |
| | | public static final int TYPE_CORP_COMMUNICATION = 1; |
| | | /**联系我*/ |
| | | public static final int TYPE_CORP_CONTACT = 2; |
| | | |
| | | |
| | | |
| | |
| | | public void setCommuniSecretKey(String communiSecretKey) { |
| | | this.communiSecretKey = communiSecretKey; |
| | | } |
| | | |
| | | public String getContactSecretKey() { |
| | | return contactSecretKey; |
| | | } |
| | | |
| | | public void setContactSecretKey(String contactSecretKey) { |
| | | this.contactSecretKey = contactSecretKey; |
| | | } |
| | | } |
| | |
| | | public class Rsa { |
| | | public static void main(String[] args) { |
| | | |
| | | System.out.println("AES:"+AesUtil.aesEncryp("dfa4acbdea008099231db51ed49ff454")); |
| | | System.out.println("AES:"+AesUtil.aesEncryp("uhWNSciQeVGDQEh0lSJlVp5dUNMunVCi6yjLKbvxZF8")); |
| | | |
| | | |
| | | //配置文件数据加密 |
| | |
| | | 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; |
| | |
| | | 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"); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * token剩余时间 |
| | | * @param createTime 获取时间 |
| | |
| | | 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; |
| | |
| | | @RestController |
| | | @RequestMapping("/employee") |
| | | public class EmployeeController extends BaseController { |
| | | |
| | | //log4j日志 |
| | | private static Logger logger = LoggerFactory.getLogger(EmployeeController.class.getName()); |
| | | |