| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475 |
- <?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.takai.ai.mapper.TakaiApplicationMapper">
- <resultMap type="com.takai.ai.domain.entity.TakaiApplication" id="BmApplicationResult">
- <id property="appId" column="appId" />
- <result property="name" column="name" />
- <result property="desc" column="description" />
- <result property="prompt" column="prompt" />
- <result property="topP" column="top_p" />
- <result property="temperature" column="temperature" />
- <result property="knowledgeIds" column="knowledge_ids" />
- <result property="sliceCount" column="slice_count" />
- <result property="model" column="model" />
- <result property="isDeepThink" column="is_deep_think" />
- <result property="iconColor" column="icon_color" />
- <result property="iconType" column="icon_type" />
- <result property="maxToken" column="max_token" />
- <result property="paramDesc" column="param_desc"/>
- <result property="knowledgeInfo" column="knowledge_info" />
- <result property="typeId" column="type_id" />
- <result property="visible" column="visible" />
- <result property="sort" column="sort" />
- <result property="status" column="status" />
- <result property="approver" column="approver" />
- <result property="nodeOrder" column="node_order" />
- <result property="comment" column="comment" />
- <result property="remark" column="remark" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="updateBy" column="update_by" />
- <result property="updateTime" column="update_time" />
- </resultMap>
- <resultMap type="com.takai.ai.domain.entity.TakaiApplicationResult" id="BmApplicationListResult">
- <id property="appId" column="appId" />
- <result property="name" column="name" />
- <result property="desc" column="description" />
- <result property="prompt" column="prompt" />
- <result property="typeId" column="type_id" />
- <result property="visible" column="visible" />
- <result property="sort" column="sort" />
- <result property="status" column="status" />
- <result property="approver" column="approver" />
- <result property="comment" column="comment" />
- <result property="userName" column="user_name" />
- <result property="createBy" column="create_by" />
- <result property="createTime" column="create_time" />
- <result property="typeName" column="typeName" />
- <result property="chatMode" column="chatMode" />
- <result property="isIsCollect" column="isIsCollect" />
- <result property="auditStatus" column="auditStatus" />
- <result property="projectName" column="projectName" />
- <result property="updateTime" column="update_time" />
- </resultMap>
- <sql id="selectSql">
- select appId, name, description, prompt, top_p, temperature, knowledge_ids, slice_count,model,icon_color,icon_type,max_token, param_desc, knowledge_info, type_id,
- status, approver, node_order, comment,remark, create_by, create_time, update_by, update_time, is_deep_think,visible,sort
- from bm_application
- </sql>
- <select id="selectApplicationList" parameterType="com.takai.ai.domain.entity.TakaiApplication" resultMap="BmApplicationListResult">
- <!-- 管理员管理所有应用 -->
- <if test="params != null and params.isAdmin">
- SELECT DISTINCT
- bm.appId,
- bm.name,
- bm.description,
- bm.type_id,
- bm.create_by,
- bm.create_time,
- bm.status,
- bm.comment,
- (SELECT dai.STATUS
- FROM document_audit_info dai
- WHERE dai.app_id = bm.appId
- ORDER BY dai.create_time DESC
- LIMIT 1) AS auditStatus,
- sp.project_name as projectName,
- bm.update_time,
- bm.sort
- FROM
- bm_application bm
- LEFT JOIN sys_project_app pa ON pa.app_id = bm.appId
- LEFT JOIN sys_project sp ON pa.project_id = sp.project_id
- <where>
- <if test="flag != null and flag != ''">
- AND (
- <choose>
- <when test="flag == 1">
- bm.status = '1' OR bm.status = '2' or bm.status = '3' OR bm.status = '4' OR bm.status = '5' OR bm.status = '' OR bm.status IS NULL
- </when>
- <otherwise>
- bm.status = '3' OR bm.status = '' OR bm.status IS NULL
- </otherwise>
- </choose>
- )
- </if>
- <if test="typeId != null and typeId != ''">
- AND bm.type_id = #{typeId}
- </if>
- <if test="projectId != null and projectId != ''">
- AND sp.project_id = #{projectId}
- </if>
- </where>
- ORDER BY sort IS NULL, sort ASC, bm.update_time DESC, bm.create_time DESC
- </if>
- <if test="params == null or !params.isAdmin">
- SELECT DISTINCT
- bm.appId,
- bm.name,
- bm.description,
- bm.type_id,
- bm.create_by,
- bm.create_time,
- bm.status,
- bm.comment,
- bm.visible,
- (SELECT dai.STATUS
- FROM document_audit_info dai
- WHERE dai.app_id = bm.appId
- ORDER BY dai.create_time DESC
- LIMIT 1) AS auditStatus,
- sp.project_name as projectName,
- bm.update_time,
- bm.sort
- FROM
- bm_application bm
- LEFT JOIN sys_project_app pa ON pa.app_id = bm.appId
- LEFT JOIN sys_project sp ON pa.project_id = sp.project_id
- LEFT JOIN sys_project_staff spa ON spa.project_pid = sp.project_pid
- LEFT JOIN sys_dict_data sdd ON sdd.dict_code = bm.type_id
- where
- (bm.visible is null or bm.visible='0')
- <if test="flag != null and flag != ''">
- AND (
- <choose>
- <when test="flag == 1">
- bm.status = '1' OR bm.status = '2' or bm.status = '3' OR bm.status = '4' OR bm.status = '5' OR bm.status = '' OR bm.status IS NULL
- </when>
- <otherwise>
- bm.status = '3' OR bm.status = '' OR bm.status IS NULL
- </otherwise>
- </choose>
- )
- </if>
- <if test="approver != null and approver != ''">
- AND spa.user_id = #{approver}
- </if>
- <if test="typeId != null and typeId != ''">
- AND bm.type_id = #{typeId}
- </if>
- <if test="projectId != null and projectId != ''">
- AND sp.project_id = #{projectId}
- </if>
- <if test="projectId == null or projectId == ''">
- <!-- 用户所属项目下以外的应用 -->
- UNION
- SELECT
- ba.appId,
- ba.name,
- ba.description,
- ba.type_id,
- ba.create_by,
- ba.create_time,
- ba.status,
- ba.comment,
- ba.visible,
- (SELECT dai.STATUS
- FROM document_audit_info dai
- WHERE dai.app_id = ba.appId
- ORDER BY dai.create_time DESC
- LIMIT 1) AS auditStatus,
- '' AS projectName,
- ba.update_time,
- ba.sort
- FROM
- bm_application ba
- LEFT JOIN sys_dict_data sdd on sdd.dict_code = ba.type_id
- WHERE
- (ba.visible is null or ba.visible='0')
- AND ba.appId NOT IN (
- SELECT
- app_id
- FROM
- sys_project_app
- )
- AND (
- ba.STATUS = '3'
- OR ba.STATUS = ''
- OR ba.STATUS IS NULL
- )
- <if test="typeId != null and typeId != ''">
- AND ba.type_id = #{typeId}
- </if>
- <!-- 待审核的应用 -->
- UNION
- SELECT DISTINCT
- bl.appId,
- bl.name,
- bl.description,
- bl.type_id,
- bl.create_by,
- bl.create_time,
- bl.status,
- bl.comment,
- bl.visible,
- (SELECT dai.STATUS
- FROM document_audit_info dai
- WHERE dai.app_id = bl.appId
- ORDER BY dai.create_time DESC
- LIMIT 1) AS auditStatus,
- '' AS projectName,
- bl.update_time,
- bl.sort
- FROM
- bm_application bl
- WHERE
- (bl.visible is null or bl.visible='0')
- <if test="flag != null and flag != ''">
- AND (
- <choose>
- <when test="flag == 1">
- (bl.status = '1' OR bl.status = '2' OR bl.status = '3' OR bl.status = '4' OR bl.status = '5') AND (bl.create_by = #{approver} OR bl.update_by = #{approver})
- </when>
- <otherwise>
- bl.status = '3' OR bl.status = '' OR bl.status IS NULL
- </otherwise>
- </choose>
- )
- </if>
- AND bl.appId NOT IN (
- SELECT
- app_id
- FROM
- sys_project_app
- )
- <if test="typeId != null and typeId != ''">
- AND bl.type_id = #{typeId}
- </if>
- </if>
- <!-- 私有应用 -->
- UNION
- SELECT
- ba.appId,
- ba.name,
- ba.description,
- ba.type_id,
- ba.create_by,
- ba.create_time,
- ba.status,
- ba.comment,
- ba.visible,
- (SELECT dai.STATUS
- FROM document_audit_info dai
- WHERE dai.app_id = ba.appId
- ORDER BY dai.create_time DESC
- LIMIT 1) AS auditStatus,
- '' AS projectName,
- ba.update_time,
- ba.sort
- FROM
- bm_application ba
- LEFT JOIN sys_dict_data sdd on sdd.dict_code = ba.type_id
- WHERE
- ba.visible='1'
- and ba.create_by= #{params.userId}
- <if test="typeId != null and typeId != ''">
- AND ba.type_id = #{typeId}
- </if>
- <if test="addOrderBy == null or addOrderBy == 'Y'">
- ORDER BY sort IS NULL, sort ASC, update_time DESC, create_time DESC
- </if>
- </if>
- </select>
- <select id="selectTargetApplication" parameterType="BmApplication" resultMap="BmApplicationResult">
- <include refid="selectSql"/>
- where appId = #{appId}
- </select>
- <insert id="insertApplication" parameterType="TakaiApplication">
- insert into bm_application(
- <if test="appId != null">appId,</if>
- <if test="name != null and name != ''">name,</if>
- <if test="desc != null and desc != ''">description,</if>
- <if test="prompt != null and prompt != ''">prompt,</if>
- <if test="topP != null and topP != ''">top_p,</if>
- <if test="temperature != null and temperature != ''">temperature,</if>
- <if test="knowledgeIds != null and knowledgeIds != ''">knowledge_ids,</if>
- <if test="sliceCount != null">slice_count,</if>
- <if test="model != null and model != ''">model,</if>
- <if test="iconColor != null and iconColor != ''">icon_color,</if>
- <if test="iconType != null and iconType != ''">icon_type,</if>
- <if test="remark != null and remark != ''">remark,</if>
- <if test="createBy != null and createBy != ''">create_by,</if>
- <if test="knowledgeInfo != null and knowledgeInfo != ''">knowledge_info,</if>
- <if test="maxToken != null and maxToken != ''">max_token,</if>
- <if test="typeId != null and typeId != ''">type_id,</if>
- <if test="status != null and status != ''">status,</if>
- <if test="nodeOrder != null and nodeOrder != ''">node_order,</if>
- <if test="approver != null and approver != ''">approver,</if>
- <if test="comment != null and comment != ''">comment,</if>
- <if test="isDeepThink != null and isDeepThink != ''">is_deep_think,</if>
- <if test="visible != null and visible != ''">visible,</if>
- <if test="sort != null">sort,</if>
- create_time,
- update_time
- )values(
- <if test="appId != null">#{appId},</if>
- <if test="name != null and name != ''">#{name},</if>
- <if test="desc != null and desc != ''">#{desc},</if>
- <if test="prompt != null and prompt != ''">#{prompt},</if>
- <if test="topP != null and topP != ''">#{topP},</if>
- <if test="temperature != null and temperature != ''">#{temperature},</if>
- <if test="knowledgeIds != null and knowledgeIds != ''">#{knowledgeIds},</if>
- <if test="sliceCount != null">#{sliceCount},</if>
- <if test="model != null and model != ''">#{model},</if>
- <if test="iconColor != null and iconColor != ''">#{iconColor},</if>
- <if test="iconType != null and iconType != ''">#{iconType},</if>
- <if test="remark != null and remark != ''">#{remark},</if>
- <if test="createBy != null and createBy != ''">#{createBy},</if>
- <if test="knowledgeInfo != null and knowledgeInfo != ''">#{knowledgeInfo},</if>
- <if test="maxToken != null and maxToken != ''">#{maxToken},</if>
- <if test="typeId != null and typeId != ''">#{typeId},</if>
- <if test="status != null and status != ''">#{status},</if>
- <if test="nodeOrder != null and nodeOrder != ''">#{nodeOrder},</if>
- <if test="approver != null and approver != ''">#{approver},</if>
- <if test="comment != null and comment != ''">#{comment},</if>
- <if test="isDeepThink != null and isDeepThink != ''">#{isDeepThink},</if>
- <if test="visible != null and visible != ''">#{visible},</if>
- <if test="sort != null">#{sort},</if>
- sysdate(),
- sysdate()
- )
- </insert>
- <update id="updateApplication" parameterType="BmApplication">
- update bm_application
- <set>
- <if test="name != null and name != ''">name = #{name},</if>
- <if test="desc != null and desc != ''">description = #{desc},</if>
- <if test="prompt != null and prompt != ''">prompt = #{prompt},</if>
- <if test="topP != null and topP != ''">top_p = #{topP},</if>
- <if test="temperature != null and temperature != ''">temperature = #{temperature},</if>
- <if test="knowledgeIds != null and knowledgeIds != ''">knowledge_ids = #{knowledgeIds},</if>
- <if test="sliceCount != null">slice_count = #{sliceCount},</if>
- <if test="model != null and model != ''">model = #{model},</if>
- <if test="iconColor != null and iconColor != ''">icon_color = #{iconColor},</if>
- <if test="iconType != null and iconType != ''">icon_type = #{iconType},</if>
- <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
- <if test="remark != null">remark = #{remark},</if>
- <if test="knowledgeInfo != null and knowledgeInfo != ''">knowledge_info = #{knowledgeInfo},</if>
- <if test="maxToken != null and maxToken != ''">max_token = #{maxToken},</if>
- <if test="isDeepThink != null and isDeepThink != ''">is_deep_think = #{isDeepThink},</if>
- <if test="visible != null and visible != ''">visible = #{visible},</if>
- <if test="sort != null">sort = #{sort},</if>
- type_id = #{typeId},
- <if test="status != null and status != ''">status = #{status},</if>
- node_order = #{nodeOrder},
- comment = #{comment},
- <if test="approver != null and approver != ''">approver = #{approver},</if>
- update_time = sysdate()
- </set>
- where appId = #{appId}
- </update>
- <delete id="delApplication" parameterType="String">
- delete from bm_application where appId = #{appId}
- </delete>
- <select id="selectAppListByApprover" parameterType="BmApplication" resultMap="BmApplicationListResult">
- select bm.appId, bm.name, bm.description, bm.prompt, bm.type_id,
- bm.status, bm.approver, bm.comment, bm.create_time, su.user_name, bm.is_deep_think, bm.visible
- from bm_application bm
- left join sys_user su on bm.approver = su.user_id
- <where>
- (bm.status = '4' OR bm.status = '1' OR bm.status = '2')
- <if test="appId != null and appId != ''">
- AND bm.appId = #{appId}
- </if>
- <if test="approver != null and approver != ''">
- AND bm.approver = #{approver}
- </if>
- </where>
- order by bm.create_time desc
- </select>
- <select id="selectAppByUserId" resultMap="BmApplicationListResult">
- SELECT DISTINCT
- bm.appId,
- bm. NAME,
- bm.description,
- bm.type_id,
- bm.visible,
- bm.create_time,
- sdd.dict_label AS typeName,
- 'LOCAL' AS chatMode,
- CASE
- WHEN ac.app_id IS NOT NULL THEN
- true
- ELSE
- false
- END AS isIsCollect
- FROM
- sys_project sp
- LEFT JOIN sys_project_staff spa ON sp.project_pid = spa.project_pid
- LEFT JOIN sys_project_app pa ON pa.project_id = sp.project_id
- LEFT JOIN bm_application bm ON pa.app_id = bm.appId
- LEFT JOIN sys_dict_data sdd ON sdd.dict_code = bm.type_id
- LEFT JOIN app_collect ac ON ac.app_id = bm.appId
- AND ac.user_id = #{userId}
- where
- spa.user_id = #{userId}
- AND (
- bm. STATUS = '3'
- OR bm. STATUS = ''
- OR bm. STATUS IS NULL
- )
- </select>
- <select id="selectApplicationListByProjectType" parameterType="String" resultMap="BmApplicationListResult">
- select
- distinct bm.appId,
- bm.name,
- bm.description,
- bm.create_time,
- bm.status,
- bm.comment,
- bm.type_id,
- bm.visible
- from
- bm_application bm
- LEFT JOIN sys_project_app pa ON bm.appId = pa.app_id
- LEFT JOIN sys_project sp on pa.project_id = sp.project_id
- where bm.appId = #{appId}
- and (bm.type_id = 42 or bm.type_id = 43)
- </select>
- <select id="selectRoleApp" resultMap="BmApplicationListResult">
- SELECT DISTINCT
- bm.appId,
- bm. NAME,
- bm.description,
- bm.type_id,
- bm.visible,
- bm.create_time
- FROM
- bm_application bm
- where
- bm. STATUS = '3'
- OR bm. STATUS = ''
- OR bm. STATUS IS NULL
- </select>
- <insert id="insertVipApp" parameterType="VipApplication">
- insert into vip_application
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="appId != null">appId,</if>
- <if test="userId != null">user_id,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="appId != null">#{appId},</if>
- <if test="userId != null">#{userId},</if>
- </trim>
- </insert>
- <delete id="deleteVipByAppId" parameterType="String">
- delete from vip_application where appId = #{appId}
- </delete>
- </mapper>
|