forked from Gitlink/microservices
326 lines
18 KiB
XML
326 lines
18 KiB
XML
<?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.microservices.dms.achievementLibrary.mapper.AchievementsMapper">
|
|
|
|
<resultMap type="Achievements" id="AchievementsResult">
|
|
<result property="id" column="id" />
|
|
<result property="achievementName" column="achievement_name" />
|
|
<result property="field1" column="field_1" />
|
|
<result property="field2" column="field_2" />
|
|
<result property="field3" column="field_3" />
|
|
<result property="achievementType" column="achievement_type" />
|
|
<result property="source" column="source" />
|
|
<result property="sourceId" column="source_id" />
|
|
<result property="sourceLink" column="source_link" />
|
|
<result property="tags" column="tags" />
|
|
<result property="summary" column="summary" />
|
|
<result property="publishingUnit" column="publishing_unit" />
|
|
<result property="address" column="address" />
|
|
<result property="isFeatured" column="is_featured" />
|
|
<result property="contactPerson" column="contact_person" />
|
|
<result property="contactNumber" column="contact_number" />
|
|
<result property="ownerId" column="owner_id" />
|
|
<result property="ownerName" column="owner_name" />
|
|
<result property="status" column="status" />
|
|
<result property="details" column="details" />
|
|
<result property="reviewer" column="reviewer" />
|
|
<result property="reviewDate" column="review_date" />
|
|
<result property="reviewComments" column="review_comments" />
|
|
<result property="images" column="images" />
|
|
<result property="attachments" column="attachments" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="attachmentCount" column="attachment_count" />
|
|
<result property="isExpertAudit" column="is_expert_audit" />
|
|
</resultMap>
|
|
|
|
<sql id="selectAchievementsVo">
|
|
select id, achievement_name, field_1, field_2, field_3, attachment_count,is_expert_audit,achievement_type, source, source_id, source_link, tags, summary, publishing_unit, address, is_featured, contact_person, contact_number, owner_id, owner_name, status, details, reviewer, review_date, review_comments, images, attachments, create_by, create_time, update_by, update_time from achievements
|
|
</sql>
|
|
|
|
<select id="selectAchievementsList" parameterType="Achievements" resultMap="AchievementsResult">
|
|
<include refid="selectAchievementsVo"/>
|
|
<where>
|
|
<if test="achievementName != null and achievementName != ''"> and achievement_name like concat('%', #{achievementName}, '%')</if>
|
|
<if test="field1 != null and field1 != ''"> and field_1 = #{field1}</if>
|
|
<if test="field2 != null and field2 != ''"> and field_2 = #{field2}</if>
|
|
<if test="field3 != null and field3 != ''"> and field_3 = #{field3}</if>
|
|
<if test="achievementType != null and achievementType != ''"> and achievement_type = #{achievementType}</if>
|
|
<if test="source != null and source != ''"> and source = #{source}</if>
|
|
<if test="sourceId != null and sourceId != ''"> and source_id = #{sourceId}</if>
|
|
<if test="sourceLink != null and sourceLink != ''"> and source_link = #{sourceLink}</if>
|
|
<if test="tags != null and tags != ''"> and tags = #{tags}</if>
|
|
<if test="summary != null and summary != ''"> and summary = #{summary}</if>
|
|
<if test="publishingUnit != null and publishingUnit != ''"> and publishing_unit = #{publishingUnit}</if>
|
|
<if test="address != null and address != ''"> and address = #{address}</if>
|
|
<if test="isFeatured != null "> and is_featured = #{isFeatured}</if>
|
|
<if test="contactPerson != null and contactPerson != ''"> and contact_person = #{contactPerson}</if>
|
|
<if test="contactNumber != null and contactNumber != ''"> and contact_number = #{contactNumber}</if>
|
|
<if test="ownerId != null and ownerId != ''"> and owner_id = #{ownerId}</if>
|
|
<if test="ownerName != null and ownerName != ''"> and owner_name like concat('%', #{ownerName}, '%')</if>
|
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
|
<if test="details != null and details != ''"> and details = #{details}</if>
|
|
<if test="reviewer != null and reviewer != ''"> and reviewer = #{reviewer}</if>
|
|
<if test="reviewDate != null "> and review_date = #{reviewDate}</if>
|
|
<if test="reviewComments != null and reviewComments != ''"> and review_comments = #{reviewComments}</if>
|
|
<if test="images != null and images != ''"> and images = #{images}</if>
|
|
<if test="attachments != null and attachments != ''"> and attachments = #{attachments}</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="selectAchievementsById" parameterType="Long" resultMap="AchievementsResult">
|
|
<include refid="selectAchievementsVo"/>
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<select id="getFileInfoByIdents" resultType="java.util.Map">
|
|
select file_identifier as k ,file_origin_name as v from sys_file_info
|
|
where file_identifier in
|
|
<foreach collection="idents" close=")" index="idx" item="item" open="(" separator=",">
|
|
#{item}
|
|
</foreach>
|
|
</select>
|
|
|
|
<insert id="insertAchievements" parameterType="Achievements" useGeneratedKeys="true" keyProperty="id">
|
|
insert into achievements
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="achievementName != null">achievement_name,</if>
|
|
<if test="field1 != null">field_1,</if>
|
|
<if test="field2 != null">field_2,</if>
|
|
<if test="field3 != null">field_3,</if>
|
|
<if test="achievementType != null">achievement_type,</if>
|
|
<if test="source != null">source,</if>
|
|
<if test="sourceId != null">source_id,</if>
|
|
<if test="sourceLink != null">source_link,</if>
|
|
<if test="tags != null">tags,</if>
|
|
<if test="summary != null">summary,</if>
|
|
<if test="publishingUnit != null">publishing_unit,</if>
|
|
<if test="address != null">address,</if>
|
|
<if test="isFeatured != null">is_featured,</if>
|
|
<if test="contactPerson != null">contact_person,</if>
|
|
<if test="contactNumber != null">contact_number,</if>
|
|
<if test="ownerId != null">owner_id,</if>
|
|
<if test="ownerName != null">owner_name,</if>
|
|
<if test="status != null">status,</if>
|
|
<if test="details != null">details,</if>
|
|
<if test="reviewer != null">reviewer,</if>
|
|
<if test="reviewDate != null">review_date,</if>
|
|
<if test="reviewComments != null">review_comments,</if>
|
|
<if test="images != null">images,</if>
|
|
<if test="attachments != null">attachments,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="attachmentCount != null">attachment_count,</if>
|
|
<if test="isExpertAudit != null">is_expert_audit,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="achievementName != null">#{achievementName},</if>
|
|
<if test="field1 != null">#{field1},</if>
|
|
<if test="field2 != null">#{field2},</if>
|
|
<if test="field3 != null">#{field3},</if>
|
|
<if test="achievementType != null">#{achievementType},</if>
|
|
<if test="source != null">#{source},</if>
|
|
<if test="sourceId != null">#{sourceId},</if>
|
|
<if test="sourceLink != null">#{sourceLink},</if>
|
|
<if test="tags != null">#{tags},</if>
|
|
<if test="summary != null">#{summary},</if>
|
|
<if test="publishingUnit != null">#{publishingUnit},</if>
|
|
<if test="address != null">#{address},</if>
|
|
<if test="isFeatured != null">#{isFeatured},</if>
|
|
<if test="contactPerson != null">#{contactPerson},</if>
|
|
<if test="contactNumber != null">#{contactNumber},</if>
|
|
<if test="ownerId != null">#{ownerId},</if>
|
|
<if test="ownerName != null">#{ownerName},</if>
|
|
<if test="status != null">#{status},</if>
|
|
<if test="details != null">#{details},</if>
|
|
<if test="reviewer != null">#{reviewer},</if>
|
|
<if test="reviewDate != null">#{reviewDate},</if>
|
|
<if test="reviewComments != null">#{reviewComments},</if>
|
|
<if test="images != null">#{images},</if>
|
|
<if test="attachments != null">#{attachments},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="attachmentCount != null">#{attachmentCount},</if>
|
|
<if test="isExpertAudit != null">#{isExpertAudit},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateAchievements" parameterType="Achievements">
|
|
update achievements
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="achievementName != null">achievement_name = #{achievementName},</if>
|
|
<if test="field1 != null">field_1 = #{field1},</if>
|
|
<if test="field2 != null">field_2 = #{field2},</if>
|
|
<if test="field3 != null">field_3 = #{field3},</if>
|
|
<if test="achievementType != null">achievement_type = #{achievementType},</if>
|
|
<if test="source != null">source = #{source},</if>
|
|
<if test="sourceId != null">source_id = #{sourceId},</if>
|
|
<if test="sourceLink != null">source_link = #{sourceLink},</if>
|
|
<if test="tags != null">tags = #{tags},</if>
|
|
<if test="summary != null">summary = #{summary},</if>
|
|
<if test="publishingUnit != null">publishing_unit = #{publishingUnit},</if>
|
|
<if test="address != null">address = #{address},</if>
|
|
<if test="isFeatured != null">is_featured = #{isFeatured},</if>
|
|
<if test="contactPerson != null">contact_person = #{contactPerson},</if>
|
|
<if test="contactNumber != null">contact_number = #{contactNumber},</if>
|
|
<if test="ownerId != null">owner_id = #{ownerId},</if>
|
|
<if test="ownerName != null">owner_name = #{ownerName},</if>
|
|
<if test="status != null">status = #{status},</if>
|
|
<if test="details != null">details = #{details},</if>
|
|
<if test="reviewer != null">reviewer = #{reviewer},</if>
|
|
<if test="reviewDate != null">review_date = #{reviewDate},</if>
|
|
<if test="reviewComments != null">review_comments = #{reviewComments},</if>
|
|
<if test="images != null">images = #{images},</if>
|
|
<if test="attachments != null">attachments = #{attachments},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="attachmentCount != null">attachment_count = #{attachmentCount},</if>
|
|
<if test="isExpertAudit != null">is_expert_audit = #{isExpertAudit},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteAchievementsById" parameterType="Long">
|
|
delete from achievements where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteAchievementsByIds" parameterType="String">
|
|
delete from achievements where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="getChoiceImport" resultType="com.microservices.dms.achievementLibrary.domain.Achievements">
|
|
select id, achievement_name
|
|
from achievements
|
|
where is_featured ='1'
|
|
order by create_time desc
|
|
limit 0,4
|
|
</select>
|
|
|
|
<select id="getTjBySources" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
|
|
select sum(1) as "value",source as "key"
|
|
from achievements
|
|
group by source
|
|
</select>
|
|
|
|
<select id="getTjByAreas" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
|
|
select a.domain_value as "name", a.countResult as "value" from (
|
|
select 'field_1' as domain_type,field_1 as domain_value,count(field_1) as countResult
|
|
from achievements
|
|
group by field_1
|
|
union all
|
|
select 'field_2' as domain_type,field_2 as domain_value,count(field_2) as countResult
|
|
from achievements
|
|
group by field_2
|
|
union all
|
|
select 'field_3' as domain_type,field_3 as domain_value,count(field_3) as countResult
|
|
from achievements
|
|
group by field_3) a
|
|
order by a.countResult desc
|
|
limit 0,5
|
|
</select>
|
|
|
|
<select id="selectAchievementsByParam" parameterType="com.microservices.dms.achievementLibrary.domain.AchQueryVo" resultType="com.microservices.dms.achievementLibrary.domain.Achievements">
|
|
select id, achievement_name,summary,create_time,owner_name,tags
|
|
from achievements
|
|
<where>
|
|
<if test="achievementName != null and achievementName != ''"> and achievement_name like concat('%', #{achievementName}, '%')</if>
|
|
<if test="source != null and source != ''"> and source = #{source}</if>
|
|
<if test="areaQuery != null and areaQuery != ''">
|
|
and (field_1 = #{areaQuery} or field_2 = #{areaQuery} or field_3 = #{areaQuery})
|
|
</if>
|
|
</where>
|
|
order by create_time desc
|
|
</select>
|
|
|
|
<select id="getAchievementClickSum" resultType="long">
|
|
select count(1) from clickers
|
|
where click_type='Achievements'
|
|
</select>
|
|
|
|
<select id="getaWatcher" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
|
|
select DATE_FORMAT(created_at, '%Y-%m-%d') as 'k', count(*) as 'v'
|
|
from watchers
|
|
where created_at >= #{s}
|
|
and created_at <= #{e}
|
|
and watchable_type = #{t}
|
|
group by DATE_FORMAT(created_at, '%Y-%m-%d')
|
|
order by DATE_FORMAT(created_at, '%Y-%m-%d')
|
|
</select>
|
|
|
|
<select id="getFavorite" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
|
|
select DATE_FORMAT(created_at, '%Y-%m-%d') as 'k', count(*) as 'v'
|
|
from favorites
|
|
where created_at >= #{s}
|
|
and created_at <= #{e}
|
|
and favorite_type = #{t}
|
|
group by DATE_FORMAT(created_at, '%Y-%m-%d')
|
|
order by DATE_FORMAT(created_at, '%Y-%m-%d')
|
|
</select>
|
|
|
|
<select id="getHotAchievement" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
|
|
select t.achievement_name as name, t.w as value, t.f as value1, (t.w + t.f) as result, t.id as `key`
|
|
from (select a.achievement_name,
|
|
a.id,
|
|
(select IFNULL(count(*), 0) from favorites where favorite_type = '' and favorite_id = a.id) as f,
|
|
(select IFNULL(count(*), 0) from watchers where watchable_type = '' and watchable_id = a.id) as w
|
|
from achievements a) as t
|
|
order by result
|
|
limit 0,3
|
|
</select>
|
|
|
|
<select id="getAchievement" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
|
|
select DATE_FORMAT(create_time, '%Y-%m-%d') as 'k', count(*) as 'v'
|
|
from achievements
|
|
where create_time >= #{s}
|
|
and create_time <= #{e}
|
|
and source = #{t}
|
|
group by DATE_FORMAT(create_time, '%Y-%m-%d')
|
|
order by DATE_FORMAT(create_time, '%Y-%m-%d')
|
|
</select>
|
|
|
|
<select id="indexProjectStatistic" resultType="java.util.Map">
|
|
select COUNT(*) as projectCount,
|
|
IFNULL(SUM(attachment_count), 0) as attachmentCount,
|
|
(select COUNT(*) from clickers where click_type = 'Project') as clickCount,
|
|
(select COUNT(distinct project_id) from project_resource_library) as projectAchievementCount
|
|
from achievements
|
|
where source = '1';
|
|
</select>
|
|
|
|
<select id="indexTaskStatistic" resultType="java.util.Map">
|
|
select COUNT(*) as taskCount,
|
|
(select COUNT(*) from clickers where click_type = 'makerSpaceTask') as clickCount,
|
|
IFNULL(SUM(is_expert_audit), 0) as expertAuditCount
|
|
from achievements
|
|
where source = '2';
|
|
</select>
|
|
<select id="indexCompetitionStatistic" resultType="java.util.Map">
|
|
select COUNT(*) as CompetitionCount,
|
|
IFNULL(SUM(is_expert_audit), 0) as expertAuditCount,
|
|
(select COUNT(*) from clickers where click_type = 'CompetitionInfo') as clickCount,
|
|
(select COUNT(distinct open_competition_id) from competition_resource_library) as CompetitionCountAchievementCount
|
|
from achievements
|
|
where source = '3';
|
|
</select>
|
|
|
|
<select id="indexSchoolEnterpriseStatistic" resultType="java.lang.Long">
|
|
select COUNT(*)
|
|
from achievements a
|
|
where source = #{s}
|
|
and tags = #{t};
|
|
</select>
|
|
|
|
</mapper> |