1.增加授权表对应实体类,第三方系统表增加授权码和秘钥字段

2.第三方系统查询和更新接口同步对本系统授权码和秘钥字段值回显和更新

授权表sql
DROP TABLE IF EXISTS `auth_license`;
CREATE TABLE `auth_license`  (
  `id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `appid` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `apikey` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `secretkey` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `createDate` datetime(0) NULL DEFAULT NULL,
  `customerId` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  `companyName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;

第三方系统表增加字段sql
ALTER TABLE `basic_third_sys`
ADD COLUMN `apikey` varchar(255) NULL COMMENT '第三方系统接口授权码' AFTER `thirdName`,
ADD COLUMN `secretkey` varchar(255) NULL COMMENT '第三方系统接口秘钥' AFTER `apikey`;
master
MrZhai 3 years ago
parent bab023da04
commit da7dfbcb50

@ -0,0 +1,36 @@
package com.glxp.api.admin.dao.auth;
import com.glxp.api.admin.entity.auth.AuthLicense;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface AuthLicenseDao {
AuthLicense get(String id);
int save(AuthLicense authLicense);
int update(AuthLicense authLicense);
int remove(String appid);
int romveByCustomerId(String customerId);
/**
*
*
* @param name
* @return
*/
AuthLicense selectLicenseByName(@Param("name") String name);
/**
*
*
* @param licenseApikey
* @param secretkey
* @param name
*/
void updateLicenseByName(@Param("apikey") String licenseApikey, @Param("secretkey") String secretkey, @Param("name") String name);
}

@ -12,4 +12,18 @@ public class BasicThirdSysEntity {
private String guideUrl;
private String thridUrl;
private Boolean mainSys;
//第三方系统授权码
private String apikey;
//第三方系统接口秘钥
private String secretkey;
//业务字段
//本系统授权码
private String licenseApikey;
//本系统秘钥
private String licenseSecretkey;
}

@ -1,25 +1,41 @@
package com.glxp.api.admin.service.basic.impl;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageHelper;
import com.glxp.api.admin.dao.auth.AuthLicenseDao;
import com.glxp.api.admin.dao.basic.BasicThirdSysDao;
import com.glxp.api.admin.entity.auth.AuthLicense;
import com.glxp.api.admin.entity.basic.BasicThirdSysEntity;
import com.glxp.api.admin.req.basic.FilterBasicThirdSysRequest;
import com.glxp.api.admin.service.basic.BasicThirdSysService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
@Slf4j
@Service
public class BasicThirdSysServiceImpl implements BasicThirdSysService {
@Resource
BasicThirdSysDao basicThirdSysDao;
@Resource
private AuthLicenseDao authLicenseDao;
@Override
public boolean updateBasicThiSys(BasicThirdSysEntity basicThirdSysEntity) {
return basicThirdSysDao.updateBasicThiSys(basicThirdSysEntity);
try {
//同步更新本系统的授权码和秘钥
if (StrUtil.isNotBlank(basicThirdSysEntity.getLicenseApikey()) || StrUtil.isNotBlank(basicThirdSysEntity.getLicenseSecretkey())) {
authLicenseDao.updateLicenseByName(basicThirdSysEntity.getLicenseApikey(), basicThirdSysEntity.getLicenseSecretkey(), "UDI管理系统");
}
basicThirdSysDao.updateBasicThiSys(basicThirdSysEntity);
} catch (Exception e) {
log.error("更新第三方系统信息异常", e);
}
return true;
}
@Override
@ -38,6 +54,14 @@ public class BasicThirdSysServiceImpl implements BasicThirdSysService {
PageHelper.offsetPage(offset, filterBasicThirdSysRequest.getLimit());
}
List<BasicThirdSysEntity> data = basicThirdSysDao.filterBasicThiSys(filterBasicThirdSysRequest);
//查询本系统的授权码
AuthLicense license = authLicenseDao.selectLicenseByName("UDI管理系统");
if (null != license) {
data.forEach(basicThirdSysEntity -> {
basicThirdSysEntity.setLicenseApikey(license.getApiKey());
basicThirdSysEntity.setLicenseSecretkey(license.getSecretKey());
});
}
return data;
}

@ -0,0 +1,54 @@
<?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.glxp.api.admin.dao.auth.AuthLicenseDao">
<select id="get" resultType="com.glxp.api.admin.entity.auth.AuthLicense">
SELECT *
FROM auth_license
where id = #{id}
</select>
<insert id="save" keyProperty="id" parameterType="com.glxp.api.admin.entity.auth.AuthLicense">
INSERT INTO auth_license(id, appid, name, apiKey, secretKey, createDate, customerId, companyName)
values (#{id}, #{appid}, #{name,jdbcType=VARCHAR}, #{apiKey,jdbcType=VARCHAR},
#{secretKey,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, #{customerId}, #{companyName})
</insert>
<update id="update" parameterType="com.glxp.api.admin.entity.auth.AuthLicense">
UPDATE auth_license
<set>
<if test="appid != null">appid=#{appid},</if>
<if test="name != null">name=#{name},</if>
<if test="apiKey != null">apiKey=#{apiKey},</if>
<if test="secretKey != null">secretKey=#{secretKey},</if>
<if test="createDate != null">createDate=#{createDate}</if>
<if test="customerId != null">customerId=#{customerId}</if>
<if test="companyName != null">companyName=#{companyName}</if>
</set>
WHERE id=#{id}
</update>
<delete id="remove">
delete
from auth_license
where id = #{id}
</delete>
<delete id="romveByCustomerId">
delete
from auth_license
where customerId = #{customerId}
</delete>
<select id="selectLicenseByName" resultType="com.glxp.api.admin.entity.auth.AuthLicense">
select apikey, secretkey from auth_license where name = #{name}
</select>
<update id="updateLicenseByName">
update auth_license
<set>
<if test="apikey != null">apikey=#{apikey},</if>
<if test="secretkey != null">secretkey=#{secretkey},</if>
</set>
where name = #{name}
</update>
</mapper>

@ -13,6 +13,8 @@
<if test="thridUrl != null">thridUrl=#{thridUrl},</if>
<if test="enabled != null">enabled=#{enabled},</if>
<if test="mainSys != null">mainSys=#{mainSys},</if>
<if test="apikey != null">apikey=#{apikey},</if>
<if test="secretkey != null">secretkey=#{secretkey}</if>
</trim>
WHERE id=#{id}
</update>

Loading…
Cancel
Save