New file |
| | |
| | | package com.hx.phip.entity; |
| | | |
| | | |
| | | public class AccountToken { |
| | | |
| | | /**企业id*/ |
| | | private String corpId; |
| | | /**小程序appid*/ |
| | | private String mpId; |
| | | |
| | | public String getCorpId() { |
| | | return corpId; |
| | | } |
| | | |
| | | public void setCorpId(String corpId) { |
| | | this.corpId = corpId; |
| | | } |
| | | |
| | | public String getMpId() { |
| | | return mpId; |
| | | } |
| | | |
| | | public void setMpId(String mpId) { |
| | | this.mpId = mpId; |
| | | } |
| | | } |
New file |
| | |
| | | package com.hx.phip.reques.entity; |
| | | |
| | | |
| | | public class CorpGetToken { |
| | | |
| | | /**企业id*/ |
| | | private String corpId; |
| | | /**小程序appid*/ |
| | | private String mpId; |
| | | |
| | | public String getCorpId() { |
| | | return corpId; |
| | | } |
| | | |
| | | public void setCorpId(String corpId) { |
| | | this.corpId = corpId; |
| | | } |
| | | |
| | | public String getMpId() { |
| | | return mpId; |
| | | } |
| | | |
| | | public void setMpId(String mpId) { |
| | | this.mpId = mpId; |
| | | } |
| | | } |
| | |
| | | /**获取应用数据参数*/ |
| | | public class ApplyParameterTool { |
| | | |
| | | /**企业小程序 |
| | | * @param corpId |
| | | * @param mpAppId |
| | | * @param commonService |
| | | * @return |
| | | */ |
| | | public static ApplyParameter getApplyParameter(String corpId, String mpAppId, CommonService commonService){ |
| | | SqlSentence sqlSentence = new SqlSentence(); |
| | | Map<String,Object> values = new HashMap<>(); |
| | |
| | | values.put("isDel",ApplyParameter.NO); |
| | | values.put("corpId",corpId); |
| | | values.put("mpAppId",mpAppId); |
| | | sqlSentence.sqlSentence("SELECT * FROM pla_apply_parameter WHERE isDel = #{m.isDel} AND corpId = #{m.corpId} AND mpAppId = #{m.mpAppId} ",values); |
| | | values.put("type",ApplyParameter.TYPE_CORP_MP); |
| | | sqlSentence.sqlSentence("SELECT * FROM pla_apply_parameter WHERE isDel = #{m.isDel} AND type = #{m.type} AND corpId = #{m.corpId} AND mpAppId = #{m.mpAppId} ",values); |
| | | ApplyParameter spplyParameter = commonService.selectOne(ApplyParameterMapper.class,sqlSentence); |
| | | return spplyParameter; |
| | | } |
| | | |
| | | /**企业通讯录 |
| | | * @param corpId |
| | | * @param commonService |
| | | * @return |
| | | */ |
| | | public static ApplyParameter getCommunition(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_COMMUNICATION); |
| | | 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; |
| | | } |
| | |
| | | |
| | | @Column(comment = "企业微信id", length = 64, type = MySqlTypeConstant.VARCHAR) |
| | | private String corpId; |
| | | @Column(comment = "数据类型", length = 5, type = MySqlTypeConstant.INT,isNull = false) |
| | | private int type; |
| | | |
| | | @Column(comment = "企业微信通讯录秘钥(AES加密)", length = 255, type = MySqlTypeConstant.VARCHAR) |
| | | private String communiSecretKey; |
| | | |
| | | @Column(comment = "企业微信应用秘钥(AES加密)", length = 255, type = MySqlTypeConstant.VARCHAR) |
| | | private String applySecretKey; |
| | | |
| | | @Column(comment = "小程序appId", length = 64, type = MySqlTypeConstant.VARCHAR) |
| | | private String mpAppId; |
| | | @Column(comment = "小程序秘钥(AES加密)", length = 255, type = MySqlTypeConstant.VARCHAR) |
| | | private String mpSecretKey; |
| | | |
| | | |
| | | |
| | | public ApplyParameter() { |
| | | } |
| | | |
| | | /////////////////////////////////////////////////// |
| | | /**企业小程序*/ |
| | | public static final int TYPE_CORP_MP = 0; |
| | | /**通讯录*/ |
| | | public static final int TYPE_CORP_COMMUNICATION = 1; |
| | | |
| | | |
| | | |
| | | public String getCorpId() { |
| | | return corpId; |
| | |
| | | public void setMpSecretKey(String mpSecretKey) { |
| | | this.mpSecretKey = mpSecretKey; |
| | | } |
| | | |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getCommuniSecretKey() { |
| | | return communiSecretKey; |
| | | } |
| | | |
| | | public void setCommuniSecretKey(String communiSecretKey) { |
| | | this.communiSecretKey = communiSecretKey; |
| | | } |
| | | } |
| | |
| | | public class Rsa { |
| | | public static void main(String[] args) { |
| | | |
| | | System.out.println("AES:"+AesUtil.aesEncryp("8d6899f042059a83531c6cfed9a6b38f")); |
| | | |
| | | System.out.println("AES:"+AesUtil.aesEncryp("uwr3G0y_IaB0MtrOqFYdROxf457-Gvp9s9rXexyutho")); |
| | | |
| | | //配置文件数据加密 |
| | | BasicTextEncryptor encryptor = new BasicTextEncryptor(); |
| | |
| | | //String decrypt = encryptor.decrypt("uFESkQwpAXSxg0SUR6BOlTujZqFC3pfIi3eTfuP0Lmrd0fqxG5XC4X0ho0Sp2FEV"); |
| | | //System.out.println("decrypt:"+decrypt); |
| | | |
| | | RSAUtil.main(null); |
| | | //RSAUtil.main(null); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.hx.phip.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.hx.common.BaseController; |
| | | import com.hx.mp.util.CorpMpUtil; |
| | | import com.hx.mybatisTool.SqlSentence; |
| | | import com.hx.phiappt.model.*; |
| | | import com.hx.phip.common.corp.mp.WeiXinCorpMpUtil; |
| | | import com.hx.phip.dao.mapper.*; |
| | | import com.hx.phip.entity.AccountToken; |
| | | import com.hx.phip.entity.EmployeeQrLogin; |
| | | import com.hx.phip.entity.EmployeeRoleLogin; |
| | | import com.hx.phip.model.ApplyParameter; |
| | | import com.hx.phip.tool.ApplyParameterTool; |
| | | import com.hx.redis.RedisUtil; |
| | | import com.hx.util.AesUtil; |
| | | import com.hx.util.HttpServletRequestUtil; |
| | | import com.hx.util.JwtTool; |
| | | import com.hx.util.StringUtils; |
| | | import com.hx.util.corp.entity.WeiXinInfo; |
| | | import com.platform.exception.PlatTipsException; |
| | | import com.platform.resultTool.PlatformCode; |
| | | import com.platform.resultTool.PlatformResult; |
| | | import com.platform.resultTool.SystemCode; |
| | | import com.platform.util.corp.PersonnelTool; |
| | | import com.platform.util.corp.entity.PersonnelQr; |
| | | import org.apache.catalina.servlet4preview.http.HttpServletRequest; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | 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; |
| | | |
| | | /** |
| | | * 公共平台获取账号token |
| | | * |
| | | * @USER: chenjiahe |
| | | * @DATE: 2021/11/01 |
| | | **/ |
| | | @RestController |
| | | @RequestMapping("/account_token") |
| | | public class AccountTokenController extends BaseController { |
| | | |
| | | /**企业员工-扫码登录*/ |
| | | @RequestMapping(value = "/communi/get_token",method = RequestMethod.POST) |
| | | public PlatformResult loginQr(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"); |
| | | } |
| | | |
| | | //获取应用数据 |
| | | ApplyParameter applyParameter = ApplyParameterTool.getCommunition(accountToken.getCorpId(),commonService); |
| | | if(applyParameter == null){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS,"corpId is error"); |
| | | } |
| | | |
| | | net.sf.json.JSONObject reObj = CorpMpUtil.getApplicationAccessToken(applyParameter.getCorpId(), AesUtil.aesDecryp(applyParameter.getCommuniSecretKey())); |
| | | |
| | | Map<String,Object> data = new HashMap<>(); |
| | | data.put("data",reObj); |
| | | |
| | | return PlatformResult.success(data); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | values.clear(); |
| | | values.put("employeeId",employee.getId()); |
| | | values.put("isDel",EmployeeRole.NO); |
| | | sqlSentence.setSqlSentence(" select ert.id,ert.name,ert.uniqueStr,s.name AS shopName from employee_role o JOIN employee_role_type ert ON ert.isDel = 0" + |
| | | sqlSentence.setSqlSentence(" select o.id,ert.id AS roleTypeId,ert.name,ert.uniqueStr,s.id AS shopId,s.name AS shopName from employee_role o JOIN employee_role_type ert ON ert.isDel = 0" + |
| | | " AND ert.id = o.roleTypeId LEFT JOIN shop s ON s.id = o.shopId WHERE o.employeeId = #{m.employeeId} AND o.isDel = #{m.isDel}"); |
| | | List<Map<String,Object>> roleList = commonService.selectListMap(EmployeeRoleTypeMapper.class,sqlSentence); |
| | | |
| | |
| | | values.clear(); |
| | | values.put("employeeId",employee.getId()); |
| | | values.put("isDel",EmployeeRole.NO); |
| | | sqlSentence.setSqlSentence(" select ert.id,ert.name,ert.uniqueStr,s.name AS shopName from employee_role o JOIN employee_role_type ert ON ert.isDel = 0" + |
| | | sqlSentence.setSqlSentence(" select o.id,ert.id AS roleTypeId,ert.name,ert.uniqueStr,s.id AS shopId,s.name AS shopName from employee_role o JOIN employee_role_type ert ON ert.isDel = 0" + |
| | | " AND ert.id = o.roleTypeId LEFT JOIN shop s ON s.id = o.shopId WHERE o.employeeId = #{m.employeeId} AND o.isDel = #{m.isDel}"); |
| | | List<Map<String,Object>> roleList = commonService.selectListMap(EmployeeRoleTypeMapper.class,sqlSentence); |
| | | |
| | |
| | | |
| | | values.put("roleId", employeeRoleLogin.getRoleId()); |
| | | values.put("employeeId", employeeRoleLogin.getPreId()); |
| | | sqlSentence.sqlSentence(" select er.*,o.name AS roleName from employee_role_type o JOIN employee_role er ON er.isDel = 0" + |
| | | " AND er.roleTypeId = o.id AND er.employeeId = #{m.employeeId} where o.id = #{m.roleId} AND o.isDel = 0",values); |
| | | sqlSentence.sqlSentence(" SELECT o.*,ert.name AS roleName FROM employee_role o JOIN employee_role_type ert ON ert.isDel = 0" + |
| | | " AND ert.id = o.roleTypeId WHERE o.id = #{m.roleId} AND o.isDel = 0 AND o.employeeId = #{m.employeeId}",values); |
| | | EmployeeRole employeeRole = commonService.selectOne(EmployeeRoleMapper.class,sqlSentence); |
| | | if(employeeRole == null){ |
| | | throw new PlatTipsException(PlatformCode.ERROR_TIPS,"角色不存在"); |
| | |
| | | data.put("authList", arrAuth); |
| | | |
| | | JSONObject redisObj = new JSONObject(); |
| | | redisObj.put("id",employeeRole.getRoleTypeId()); |
| | | redisObj.put("id",employeeRole.getId()); |
| | | redisObj.put("roleTypeId",employeeRole.getRoleTypeId()); |
| | | redisObj.put("roleName",employeeRole.getRoleName()); |
| | | redisObj.put("uniqueStr",employeeRole.getRoleUniqueStr()); |
| | | redisObj.put("preId",employeeRole.getEmployeeId()); |
| | |
| | | redisObj.put("shopName", shop.getName()); |
| | | } |
| | | |
| | | redisUtil.set(employeeRole.getRoleTypeId(),redisObj,ttlMillis); |
| | | redisUtil.set(employeeRole.getId(),redisObj,ttlMillis); |
| | | return PlatformResult.success(data); |
| | | } |
| | | |
| | |
| | | spring.redis.password = ENC(P/vIymIjtc5h7kd6rhqPZApE99RK9jwlU2L0M8yQ2UI=) |
| | | #spring.redis.password= |
| | | # \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 |