houzhongjian
2024-07-23 a6de490948278991e47952e90671ddba4555e9a2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?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.iailab.module.data.gateway.dao.ApiAuthorizedDao">
    <resultMap id="ApiAuthorizedEntity" type="com.iailab.module.data.gateway.entity.ApiAuthorizedEntity">
        <result property="id" column="id"/>
        <result property="appId" column="app_id"/>
        <result property="appKey" column="app_key"/>
        <result property="serverName" column="server_name"/>
        <result property="apiId" column="api_id"/>
        <result property="apiName" column="api_name"/>
        <result property="limitMin" column="limit_min"/>
        <result property="limitHour" column="limit_hour"/>
        <result property="limitDay" column="limit_day"/>
        <result property="createTime" column="create_time"/>
    </resultMap>
 
    <resultMap id="SysGatewayApi" type="com.iailab.module.data.gateway.vo.SysGatewayApi">
        <result property="appKey" column="app_key"/>
        <result property="apiStatus" column="api_status"/>
        <result property="apiAddress" column="api_address"/>
        <result property="serverName" column="server_name"/>
    </resultMap>
 
    <select id="queryList" parameterType="map" resultMap="ApiAuthorizedEntity">
      SELECT t1.*,
        t2.api_name,
        t2.api_address,
        t3.server_name
      FROM t_api_authorized t1
      LEFT JOIN t_api_info t2 ON t2.id = t1.api_id
      LEFT JOIN t_api_server t3 ON t3.id = t2.api_server_id
      <where>
          <if test="params.appId != null and params.appId != ''">
            AND t1.app_id = #{params.appId}
          </if>
      </where>
      ORDER BY t1.create_time DESC
    </select>
 
    <select id="queryListGatewayApi" parameterType="map" resultMap="SysGatewayApi">
      SELECT
        t1.app_key,
        t2.api_address,
        t3.server_name,
        t2.status as api_status
      FROM
          t_api_authorized t1
      LEFT JOIN t_api_info t2 ON t2.id = t1.api_id
      LEFT JOIN t_api_server t3 ON t3.id = t2.api_server_id
        <where>
            <if test="apiStatus != null and apiStatus != ''">
                AND t2.status = #{apiStatus}
            </if>
            <if test="serverStatus != null and serverStatus != ''">
                AND t3.status = #{serverStatus}
            </if>
        </where>
    </select>
 
</mapper>