ResourceEntity 增加infoList json字段

This commit is contained in:
wangliwen 2022-06-20 10:23:37 +08:00
parent 5b66808e7c
commit 0063546e5e
4 changed files with 234 additions and 219 deletions

View File

@ -0,0 +1 @@
ALTER TABLE `share_platform`.`tb_data_resource` ADD COLUMN `info_list` json NULL COMMENT '属性信息';

View File

@ -1,11 +1,15 @@
package io.renren.modules.resource.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import io.renren.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
import java.util.List;
/**
* 资源表
@ -130,4 +134,7 @@ public class ResourceEntity extends BaseEntity {
* 提起下架人员
*/
private String undercarriageUserName;
@TableField(value = "info_list", typeHandler = FastjsonTypeHandler.class)
private List<AttrEntity> infoList;
}

View File

@ -0,0 +1 @@
ALTER TABLE `share_platform`.`tb_data_resource` ADD COLUMN `info_list` json NULL COMMENT '属性信息';

View File

@ -33,6 +33,8 @@
<result property="enclosure" column="enclosure"/>
<result property="undercarriageReason" column="undercarriage_reason"/>
<result property="undercarriageUserName" column="undercarriage_user_name"/>
<result property="infoList" column="info_list"
typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
</resultMap>
<resultMap id="resourceDTO" type="io.renren.modules.resource.dto.ResourceDTO">
@ -89,7 +91,7 @@
<result property="note5" column="note5"/>
</collection>
</resultMap>
<update id="deleteByIds">
UPDATE tb_data_resource
SET del_flag = 1,
@ -103,7 +105,7 @@
<select id="selectWithAttrs" resultMap="resourceDTO">
SELECT
tdr.*,
DISTINCT tdr.*,
IFNULL(taa2.approve_status, '未申请') AS "applyState",
IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount",
@ -180,7 +182,7 @@
WHERE 1 = 1
AND del_flag = 0
<if test="type != null and type != ''">
AND type = #{type}
AND type = #{type}
</if>
GROUP BY type
ORDER BY type
@ -215,34 +217,34 @@
</select>
<select id="selectDTOById" resultMap="resourceDTO">
<!-- SELECT-->
<!-- tdr.*,-->
<!--&lt;!&ndash; tda.*,&ndash;&gt;-->
<!-- IFNULL(trs.score, 0 ) AS "score",-->
<!-- IFNULL(taa.applyCount, 0 ) AS "applyCount",-->
<!-- IFNULL(trc.collectCount, 0) AS "collectCount",-->
<!-- sd.name as "deptName",-->
<!-- IFNULL(trc2.isCollect, 'false') AS "isCollect",-->
<!-- IFNULL(taa2.approve_status, '未申请') AS "applyState"-->
<!-- FROM-->
<!-- tb_data_resource tdr-->
<!--&lt;!&ndash; LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id&ndash;&gt;-->
<!-- LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP-->
<!-- BY resource_id ) trs ON tdr.id = trs.resource_id-->
<!-- LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =-->
<!-- 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id-->
<!-- LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag-->
<!-- = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id-->
<!-- LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"-->
<!-- FROM tb_resource_collection WHERE-->
<!-- 1 = 1 AND del_flag = 0 AND user_id = #{userId}-->
<!-- GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id-->
<!-- LEFT JOIN ( SELECT resource_id, approve_status FROM t_ability_application WHERE-->
<!-- 1 = 1 AND del_flag = 0 AND user_id = #{userId}-->
<!-- GROUP BY id LIMIT 1) taa2 ON tdr.id = taa2.resource_id-->
<!-- LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id-->
<!-- WHERE 1 = 1-->
<!-- AND tdr.id = #{id}-->
<!-- SELECT-->
<!-- tdr.*,-->
<!--&lt;!&ndash; tda.*,&ndash;&gt;-->
<!-- IFNULL(trs.score, 0 ) AS "score",-->
<!-- IFNULL(taa.applyCount, 0 ) AS "applyCount",-->
<!-- IFNULL(trc.collectCount, 0) AS "collectCount",-->
<!-- sd.name as "deptName",-->
<!-- IFNULL(trc2.isCollect, 'false') AS "isCollect",-->
<!-- IFNULL(taa2.approve_status, '未申请') AS "applyState"-->
<!-- FROM-->
<!-- tb_data_resource tdr-->
<!--&lt;!&ndash; LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id&ndash;&gt;-->
<!-- LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP-->
<!-- BY resource_id ) trs ON tdr.id = trs.resource_id-->
<!-- LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag =-->
<!-- 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id-->
<!-- LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag-->
<!-- = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id-->
<!-- LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect"-->
<!-- FROM tb_resource_collection WHERE-->
<!-- 1 = 1 AND del_flag = 0 AND user_id = #{userId}-->
<!-- GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id-->
<!-- LEFT JOIN ( SELECT resource_id, approve_status FROM t_ability_application WHERE-->
<!-- 1 = 1 AND del_flag = 0 AND user_id = #{userId}-->
<!-- GROUP BY id LIMIT 1) taa2 ON tdr.id = taa2.resource_id-->
<!-- LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id-->
<!-- WHERE 1 = 1-->
<!-- AND tdr.id = #{id}-->
SELECT
tdr.*,
@ -567,7 +569,8 @@
tdav.data_resource_id AS resourceId
FROM
tb_data_attr tdav
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value, ';', '' ) ) + 1 )
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
';', '' ) ) + 1 )
WHERE
1 = 1
AND tdav.attr_type = '应用领域'
@ -594,230 +597,230 @@
<select id="selectMaxDeptIds" resultType="java.lang.Long">
SELECT
dept_id
dept_id
FROM
(
SELECT
COUNT( id ) AS "count",
dept_id
FROM
tb_data_resource
WHERE
1 = 1
AND del_flag = 0
AND dept_id IS NOT NULL
GROUP BY
dept_id
) temp1
(
SELECT
COUNT( id ) AS "count",
dept_id
FROM
tb_data_resource
WHERE
temp1.count = (
SELECT
MAX( count ) AS "total"
FROM
(
SELECT
COUNT( id ) AS "count"
FROM
tb_data_resource
WHERE
1 = 1
AND del_flag = 0
AND dept_id IS NOT NULL
GROUP BY
dept_id
) temp2
)
1 = 1
AND del_flag = 0
AND dept_id IS NOT NULL
GROUP BY
dept_id
) temp1
WHERE
temp1.count = (
SELECT
MAX( count ) AS "total"
FROM
(
SELECT
COUNT( id ) AS "count"
FROM
tb_data_resource
WHERE
1 = 1
AND del_flag = 0
AND dept_id IS NOT NULL
GROUP BY
dept_id
) temp2
)
</select>
<select id="selectByDeptId" resultType="java.util.Map">
SELECT id,
name
name
FROM tb_data_resource
WHERE 1 = 1
AND del_flag = 0
AND dept_id = #{deptId}
AND del_flag = 0
AND dept_id = #{deptId}
</select>
<select id="selectDeptCountList" resultType="java.util.Map">
SELECT
sd.id AS "deptId",
sd.NAME AS "deptName",
COUNT( tdr.id ) AS "total"
sd.id AS "deptId",
sd.NAME AS "deptName",
COUNT( tdr.id ) AS "total"
FROM
tb_data_resource tdr,
sys_dept sd
tb_data_resource tdr,
sys_dept sd
WHERE
1 = 1
AND tdr.del_flag = 0
AND tdr.dept_id = sd.id
1 = 1
AND tdr.del_flag = 0
AND tdr.dept_id = sd.id
GROUP BY tdr.dept_id
ORDER BY total DESC
</select>
<select id="selectMaxApplyDeptIds" resultType="java.lang.Long">
SELECT
dept_id
dept_id
FROM
(
SELECT
COUNT( taa.id ) AS "count",
su.dept_id
FROM
t_ability_application taa,
sys_user su
WHERE
1 = 1
AND taa.user_id = su.id
AND taa.user_id IS NOT NULL
GROUP BY
su.dept_id
) temp1
(
SELECT
COUNT( taa.id ) AS "count",
su.dept_id
FROM
t_ability_application taa,
sys_user su
WHERE
temp1.count = (
SELECT
MAX( count ) AS "total"
FROM
(
SELECT
COUNT( taa.id ) AS "count"
FROM
t_ability_application taa,
sys_user su
WHERE
1 = 1
AND taa.user_id = su.id
AND taa.user_id IS NOT NULL
GROUP BY
su.dept_id
) temp2
)
1 = 1
AND taa.user_id = su.id
AND taa.user_id IS NOT NULL
GROUP BY
su.dept_id
) temp1
WHERE
temp1.count = (
SELECT
MAX( count ) AS "total"
FROM
(
SELECT
COUNT( taa.id ) AS "count"
FROM
t_ability_application taa,
sys_user su
WHERE
1 = 1
AND taa.user_id = su.id
AND taa.user_id IS NOT NULL
GROUP BY
su.dept_id
) temp2
)
</select>
<select id="selectByApplyDeptId" resultType="java.util.Map">
SELECT tdr.id,
tdr.name
tdr.name
FROM t_ability_application taa, tb_data_resource tdr, sys_user su
WHERE 1 = 1
AND tdr.del_flag = 0
AND su.id = taa.user_id
AND taa.resource_id = tdr.id
AND su.dept_id = #{deptId}
AND tdr.del_flag = 0
AND su.id = taa.user_id
AND taa.resource_id = tdr.id
AND su.dept_id = #{deptId}
</select>
<select id="selectApplyDeptCountList" resultType="java.util.Map">
SELECT
sd.id AS "deptId",
sd.NAME AS "deptName",
COUNT( taa.resource_id ) AS "total"
sd.id AS "deptId",
sd.NAME AS "deptName",
COUNT( taa.resource_id ) AS "total"
FROM
t_ability_application taa,
sys_user su,
sys_dept sd
t_ability_application taa,
sys_user su,
sys_dept sd
WHERE
1 = 1
AND su.id = taa.user_id
AND su.dept_id = sd.id
1 = 1
AND su.id = taa.user_id
AND su.dept_id = sd.id
GROUP BY
sd.id
sd.id
ORDER BY
total DESC
total DESC
</select>
<select id="selectDeptTypeCountList" resultType="java.util.Map">
SELECT
COUNT( tdr.id ) AS "count",
sd.NAME AS "deptName",
(CASE tdr.type
WHEN '应用资源' THEN 'yyzy'
WHEN '组件服务' THEN 'zjfw'
WHEN '基础设施' THEN 'jcss'
WHEN '知识库' THEN 'zsk'
WHEN '数据资源' THEN 'sjzy'
ELSE 'yyzy' END)AS "type"
COUNT( tdr.id ) AS "count",
sd.NAME AS "deptName",
(CASE tdr.type
WHEN '应用资源' THEN 'yyzy'
WHEN '组件服务' THEN 'zjfw'
WHEN '基础设施' THEN 'jcss'
WHEN '知识库' THEN 'zsk'
WHEN '数据资源' THEN 'sjzy'
ELSE 'yyzy' END)AS "type"
FROM
tb_data_resource tdr,
sys_dept sd
tb_data_resource tdr,
sys_dept sd
WHERE
1 = 1
AND tdr.del_flag = 0
AND tdr.dept_id = sd.id
1 = 1
AND tdr.del_flag = 0
AND tdr.dept_id = sd.id
GROUP BY
tdr.dept_id,
tdr.type
tdr.dept_id,
tdr.type
</select>
<select id="selectApplyDeptTypeCountList" resultType="java.util.Map">
SELECT
COUNT( taa.resource_id ) AS "count",
sd.NAME AS "deptName",
(
CASE
tdr.type
WHEN '应用资源' THEN
'yyzy'
WHEN '组件服务' THEN
'zjfw'
WHEN '基础设施' THEN
'jcss'
WHEN '知识库' THEN
'zsk'
WHEN '数据资源' THEN
'sjzy' ELSE 'yyzy'
END
) AS "type"
COUNT( taa.resource_id ) AS "count",
sd.NAME AS "deptName",
(
CASE
tdr.type
WHEN '应用资源' THEN
'yyzy'
WHEN '组件服务' THEN
'zjfw'
WHEN '基础设施' THEN
'jcss'
WHEN '知识库' THEN
'zsk'
WHEN '数据资源' THEN
'sjzy' ELSE 'yyzy'
END
) AS "type"
FROM
tb_data_resource tdr,
sys_dept sd,
sys_user su,
t_ability_application taa
tb_data_resource tdr,
sys_dept sd,
sys_user su,
t_ability_application taa
WHERE
1 = 1
AND tdr.del_flag = 0
AND taa.user_id = su.id
AND su.dept_id = sd.id
AND taa.resource_id = tdr.id
1 = 1
AND tdr.del_flag = 0
AND taa.user_id = su.id
AND su.dept_id = sd.id
AND taa.resource_id = tdr.id
GROUP BY
sd.id,
tdr.type
sd.id,
tdr.type
</select>
<select id="selectMaxType" resultType="java.lang.String">
SELECT
type
type
FROM
( SELECT COUNT( id ) AS "count", type FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 GROUP BY type ) temp1
( SELECT COUNT( id ) AS "count", type FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 GROUP BY type ) temp1
WHERE
temp1.count = (
SELECT
MAX( count ) AS "total"
FROM
( SELECT COUNT( id ) AS "count" FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 GROUP BY type ) temp2
)
temp1.count = (
SELECT
MAX( count ) AS "total"
FROM
( SELECT COUNT( id ) AS "count" FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 GROUP BY type ) temp2
)
</select>
<select id="selectByType" resultType="java.util.Map">
SELECT id,
name
name
FROM tb_data_resource
WHERE 1 = 1
AND del_flag = 0
AND type = #{type}
AND del_flag = 0
AND type = #{type}
</select>
<select id="selectTypeCountList" resultType="java.util.Map">
SELECT
tdr.type,
COUNT( tdr.id ) AS "total"
tdr.type,
COUNT( tdr.id ) AS "total"
FROM
tb_data_resource tdr
tb_data_resource tdr
WHERE
1 = 1
AND tdr.del_flag = 0
1 = 1
AND tdr.del_flag = 0
GROUP BY
tdr.type
tdr.type
ORDER BY
total DESC
total DESC
</select>
<select id="selectMaxAppArea" resultType="java.lang.String">
@ -830,7 +833,8 @@
COUNT( tdav.data_resource_id ) AS "count"
FROM
tb_data_attr tdav
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value, ';', '' ) ) + 1 )
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
';', '' ) ) + 1 )
WHERE
1 = 1
AND tdav.attr_type = '应用领域'
@ -850,7 +854,8 @@
COUNT( tdav.data_resource_id ) AS "count"
FROM
tb_data_attr tdav
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value, ';', '' ) ) + 1 )
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
';', '' ) ) + 1 )
WHERE
1 = 1
AND tdav.attr_type = '应用领域'
@ -864,17 +869,17 @@
<select id="selectByAppArea" resultType="java.util.Map">
SELECT
tdr.id,
tdr.name
tdr.id,
tdr.name
FROM
tb_data_resource tdr,
tb_data_attr tda
tb_data_resource tdr,
tb_data_attr tda
WHERE
1 = 1
AND tdr.del_flag = 0
AND tda.del_flag = 0
AND tdr.id = tda.data_resource_id
AND attr_value LIKE CONCAT('%', #{type}, '%')
1 = 1
AND tdr.del_flag = 0
AND tda.del_flag = 0
AND tdr.id = tda.data_resource_id
AND attr_value LIKE CONCAT('%', #{type}, '%')
</select>
<select id="selectAppAreaCountList" resultType="java.util.Map">
@ -883,7 +888,8 @@
COUNT( tdav.data_resource_id ) AS "total"
FROM
tb_data_attr tdav
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value, ';', '' ) ) + 1 )
JOIN mysql.help_topic b ON b.help_topic_id &lt; ( LENGTH( tdav.attr_value ) - LENGTH( REPLACE ( tdav.attr_value,
';', '' ) ) + 1 )
WHERE
1 = 1
AND tdav.attr_type = '应用领域'
@ -895,40 +901,40 @@
<select id="selectTopFiveComponentServiceApplications" resultType="java.util.Map">
SELECT
tdr.id AS "resourceId",
tdr.NAME AS "name",
IFNULL(COUNT( taa.id ), 0) AS "count"
tdr.id AS "resourceId",
tdr.NAME AS "name",
IFNULL(COUNT( taa.id ), 0) AS "count"
FROM
tb_data_resource tdr
LEFT JOIN t_ability_application taa ON tdr.id = taa.resource_id AND taa.del_flag = 0
tb_data_resource tdr
LEFT JOIN t_ability_application taa ON tdr.id = taa.resource_id AND taa.del_flag = 0
WHERE
1 = 1
AND tdr.del_flag = 0
AND tdr.type = '组件服务'
1 = 1
AND tdr.del_flag = 0
AND tdr.type = '组件服务'
GROUP BY
tdr.id
tdr.id
ORDER BY
count DESC
count DESC
LIMIT 5
</select>
<select id="selectTopFiveComponentServiceScore" resultType="java.util.Map">
SELECT
tdr.id AS "resourceId",
tdr.NAME AS "name",
IFNULL( SUM( trs.score ), 0 ) AS "score"
tdr.id AS "resourceId",
tdr.NAME AS "name",
IFNULL( SUM( trs.score ), 0 ) AS "score"
FROM
tb_data_resource tdr
LEFT JOIN tb_resource_score trs ON tdr.id = trs.resource_id
AND trs.del_flag = 0
tb_data_resource tdr
LEFT JOIN tb_resource_score trs ON tdr.id = trs.resource_id
AND trs.del_flag = 0
WHERE
1 = 1
AND tdr.del_flag = 0
AND tdr.type = '组件服务'
1 = 1
AND tdr.del_flag = 0
AND tdr.type = '组件服务'
GROUP BY
tdr.id
tdr.id
ORDER BY
score DESC
score DESC
LIMIT 5
</select>