门户首页及二级搜索页面排序实现
This commit is contained in:
parent
4638a6ad94
commit
a519811d4c
|
@ -20,9 +20,19 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
|
||||||
|
|
||||||
Integer deleteByIds(@Param("ids") List<Long> idList);
|
Integer deleteByIds(@Param("ids") List<Long> idList);
|
||||||
|
|
||||||
List<ResourceDTO> selectWithAttrs(@Param("dto") ResourceDTO resourceDTO);
|
List<ResourceDTO> selectWithAttrs(@Param("dto") ResourceDTO resourceDTO,
|
||||||
|
@Param("orderField") String orderField,
|
||||||
|
@Param("orderType") String orderType);
|
||||||
|
|
||||||
List<Map> selectTypeCount(Long deptId);
|
List<Map> selectTypeCount(Long deptId);
|
||||||
|
|
||||||
List<ResourceDTO> selectMostPopular(Map<String, Object> selectMap);
|
List<ResourceDTO> selectMostPopular(Map<String, Object> selectMap);
|
||||||
|
|
||||||
|
ResourceDTO selectDTOById(Long id);
|
||||||
|
|
||||||
|
List<ResourceDTO> selectDTOPage(@Param("dto")ResourceDTO resourceDTO,
|
||||||
|
@Param("pageNum") Integer pageNum,
|
||||||
|
@Param("pageSize") Integer pageSize,
|
||||||
|
@Param("orderField")String orderField,
|
||||||
|
@Param("orderType") String orderType);
|
||||||
}
|
}
|
|
@ -77,10 +77,14 @@ public class ResourceDTO implements Serializable {
|
||||||
private String deptName;
|
private String deptName;
|
||||||
@ApiModelProperty(value = "收藏标志")
|
@ApiModelProperty(value = "收藏标志")
|
||||||
private String isCollect;
|
private String isCollect;
|
||||||
|
@ApiModelProperty(value = "收藏量")
|
||||||
|
private Integer collectCount;
|
||||||
@ApiModelProperty(value = "评分")
|
@ApiModelProperty(value = "评分")
|
||||||
private Long score;
|
private Long score;
|
||||||
@ApiModelProperty(value = "申请结果")
|
@ApiModelProperty(value = "申请结果")
|
||||||
private String applyState;
|
private String applyState;
|
||||||
|
@ApiModelProperty(value = "申请量")
|
||||||
|
private String applyCount;
|
||||||
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "属性信息")
|
@ApiModelProperty(value = "属性信息")
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package io.renren.modules.resource.service.impl;
|
package io.renren.modules.resource.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
@ -17,10 +16,11 @@ import io.renren.modules.resource.dto.ResourceDTO;
|
||||||
import io.renren.modules.resource.entity.AttrEntity;
|
import io.renren.modules.resource.entity.AttrEntity;
|
||||||
import io.renren.modules.resource.entity.ResourceEntity;
|
import io.renren.modules.resource.entity.ResourceEntity;
|
||||||
import io.renren.modules.resource.service.ResourceService;
|
import io.renren.modules.resource.service.ResourceService;
|
||||||
|
import io.renren.modules.resourceCar.dao.ResourceCarDao;
|
||||||
|
import io.renren.modules.resourceCollection.dao.ResourceCollectionDao;
|
||||||
|
import io.renren.modules.resourceScore.dao.ResourceScoreDao;
|
||||||
import io.renren.modules.security.user.SecurityUser;
|
import io.renren.modules.security.user.SecurityUser;
|
||||||
import io.renren.modules.security.user.UserDetail;
|
import io.renren.modules.security.user.UserDetail;
|
||||||
import io.renren.modules.sys.dto.SysDeptDTO;
|
|
||||||
import io.renren.modules.sys.service.SysDeptService;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -41,10 +41,16 @@ import java.util.Map;
|
||||||
public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEntity, ResourceDTO> implements ResourceService {
|
public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEntity, ResourceDTO> implements ResourceService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysDeptService sysDeptService;
|
private ResourceDao resourceDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ResourceDao resourceDao;
|
private ResourceScoreDao resourceScoreDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ResourceCollectionDao resourceCollectionDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ResourceCarDao resourceCarDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AttrDao attrDao;
|
private AttrDao attrDao;
|
||||||
|
@ -91,7 +97,11 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
JSONArray jsonArray = jsonObject.getJSONArray("ids");
|
JSONArray jsonArray = jsonObject.getJSONArray("ids");
|
||||||
List<Long> idList = jsonArray.toJavaList(Long.class);
|
List<Long> idList = jsonArray.toJavaList(Long.class);
|
||||||
resourceDao.deleteByIds(idList);
|
resourceDao.deleteByIds(idList);
|
||||||
|
//将所有能力相关表的删除标志都置为1
|
||||||
attrDao.delete4Resource(idList);
|
attrDao.delete4Resource(idList);
|
||||||
|
resourceCarDao.delete4Resource(idList);
|
||||||
|
resourceScoreDao.delete4Resource(idList);
|
||||||
|
resourceCollectionDao.delete4Resource(idList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -112,16 +122,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceDTO selectWithAttrs(Long id) {
|
public ResourceDTO selectWithAttrs(Long id) {
|
||||||
ResourceDTO resourceDTO = new ResourceDTO();
|
ResourceDTO resourceDTO = resourceDao.selectDTOById(id);
|
||||||
ResourceEntity resourceEntity = resourceDao.selectById(id);
|
|
||||||
BeanUtils.copyProperties(resourceEntity, resourceDTO);
|
|
||||||
SysDeptDTO data = sysDeptService.get(resourceDTO.getDeptId());
|
|
||||||
if (ObjectUtil.isNotNull(data)) {
|
|
||||||
resourceDTO.setNote1(data.getName());
|
|
||||||
}
|
|
||||||
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<>();
|
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<>();
|
||||||
wrapper.eq("data_resource_id", resourceEntity.getId())
|
wrapper.eq("data_resource_id", id)
|
||||||
.eq("del_flag", 0);
|
.eq("del_f lag", 0);
|
||||||
List<AttrEntity> attrEntities = attrDao.selectList(wrapper);
|
List<AttrEntity> attrEntities = attrDao.selectList(wrapper);
|
||||||
resourceDTO.setInfoList(attrEntities);
|
resourceDTO.setInfoList(attrEntities);
|
||||||
return resourceDTO;
|
return resourceDTO;
|
||||||
|
@ -134,32 +138,18 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
Integer pageNum = jsonObject.getInteger("pageNum");
|
Integer pageNum = jsonObject.getInteger("pageNum");
|
||||||
Integer pageSize = jsonObject.getInteger("pageSize");
|
Integer pageSize = jsonObject.getInteger("pageSize");
|
||||||
//默认按上架时间降序排列
|
//默认按上架时间降序排列
|
||||||
String orderField = StringUtils.isNotBlank(jsonObject.getString("orderField")) ? "create_time" : jsonObject.getString("orderField");
|
String orderField = StringUtils.isBlank(jsonObject.getString("orderField")) ? "total" : jsonObject.getString("orderField");
|
||||||
String orderType = StringUtils.isNotBlank(jsonObject.getString("orderType")) ? "DESC" : jsonObject.getString("orderType");
|
String orderType = StringUtils.isBlank(jsonObject.getString("orderType")) ? "DESC" : jsonObject.getString("orderType");
|
||||||
boolean orderASC = /*orderType.equals("ASC") ? true : */false;
|
|
||||||
Page<ResourceDTO> resultPage = new Page<>(pageNum, pageSize);
|
Page<ResourceDTO> resultPage = new Page<>(pageNum, pageSize);
|
||||||
if (resourceDTO.getInfoList().isEmpty()) {
|
if (resourceDTO.getInfoList().isEmpty()) {
|
||||||
Page<ResourceEntity> page = new Page(pageNum, pageSize);
|
List<ResourceDTO> resourceDTOS = resourceDao.selectDTOPage(resourceDTO, (pageNum - 1)* pageSize, pageSize, orderField, orderType);
|
||||||
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
|
resourceDTOS.forEach(item -> {
|
||||||
queryWrapper.eq("del_flag", 0)
|
item.setInfoList(this.selectAttrsByResourceId(item.getId()));
|
||||||
.like(StringUtils.isNotBlank(resourceDTO.getName()), "name", resourceDTO.getName())
|
|
||||||
.eq(ObjectUtil.isNotNull(resourceDTO.getDistrictId()), "district_id", resourceDTO.getDistrictId())
|
|
||||||
.eq(ObjectUtil.isNotNull(resourceDTO.getDeptId()), "dept_id", resourceDTO.getDeptId())
|
|
||||||
.eq("type", resourceDTO.getType())
|
|
||||||
.orderBy(true, orderASC, orderField);
|
|
||||||
Page<ResourceEntity> entityPage = resourceDao.selectPage(page, queryWrapper);
|
|
||||||
ArrayList<ResourceDTO> list = new ArrayList<>();
|
|
||||||
entityPage.getRecords().forEach(item -> {
|
|
||||||
ResourceDTO dto = new ResourceDTO();
|
|
||||||
BeanUtils.copyProperties(item, dto);
|
|
||||||
dto.setInfoList(this.selectAttrsByResourceId(dto.getId()));
|
|
||||||
list.add(dto);
|
|
||||||
});
|
});
|
||||||
resultPage.setRecords(list);
|
resultPage.setRecords(resourceDTOS);
|
||||||
resultPage.setTotal(page.getTotal());
|
resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 1, 100000, orderField, orderType).size());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO);
|
List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO , orderField, orderType);
|
||||||
int j = Math.min(pageNum * pageSize, resourceDTOS.size());
|
int j = Math.min(pageNum * pageSize, resourceDTOS.size());
|
||||||
if (resourceDTOS.isEmpty()) {
|
if (resourceDTOS.isEmpty()) {
|
||||||
resultPage.setRecords(null);
|
resultPage.setRecords(null);
|
||||||
|
|
|
@ -23,4 +23,6 @@ public interface ResourceCarDao extends BaseDao<ResourceCarEntity> {
|
||||||
List<ResourceCarDTO> selectPageWithResource(@Param("params") Map<String, Object> params,
|
List<ResourceCarDTO> selectPageWithResource(@Param("params") Map<String, Object> params,
|
||||||
@Param("pageNum") Integer pageNum,
|
@Param("pageNum") Integer pageNum,
|
||||||
@Param("pageSize") Integer pageSize);
|
@Param("pageSize") Integer pageSize);
|
||||||
|
|
||||||
|
Integer delete4Resource(@Param("resourceIds") List<Long> idList);
|
||||||
}
|
}
|
|
@ -23,4 +23,6 @@ public interface ResourceCollectionDao extends BaseDao<ResourceCollectionEntity>
|
||||||
List<ResourceCollectionDTO> selectPageWithResource(@Param("params") Map<String, Object> params,
|
List<ResourceCollectionDTO> selectPageWithResource(@Param("params") Map<String, Object> params,
|
||||||
@Param("pageNum") Integer pageNum,
|
@Param("pageNum") Integer pageNum,
|
||||||
@Param("pageSize") Integer pageSize);
|
@Param("pageSize") Integer pageSize);
|
||||||
|
|
||||||
|
Integer delete4Resource(@Param("resourceIds") List<Long> idList);
|
||||||
}
|
}
|
|
@ -5,6 +5,8 @@ import io.renren.modules.resourceScore.entity.ResourceScoreEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 能力评分表
|
* 能力评分表
|
||||||
*
|
*
|
||||||
|
@ -15,4 +17,6 @@ import org.apache.ibatis.annotations.Param;
|
||||||
public interface ResourceScoreDao extends BaseDao<ResourceScoreEntity> {
|
public interface ResourceScoreDao extends BaseDao<ResourceScoreEntity> {
|
||||||
|
|
||||||
Integer deleteByIds(@Param("ids") Long[] ids);
|
Integer deleteByIds(@Param("ids") Long[] ids);
|
||||||
|
|
||||||
|
Integer delete4Resource(@Param("resourceIds") List<Long> idList);
|
||||||
}
|
}
|
|
@ -60,9 +60,12 @@
|
||||||
<result property="note4" column="note4"/>
|
<result property="note4" column="note4"/>
|
||||||
<result property="note5" column="note5"/>
|
<result property="note5" column="note5"/>
|
||||||
<!-- 自定义字段 -->
|
<!-- 自定义字段 -->
|
||||||
<result property="deptName" column="dept_name"/>
|
<result property="deptName" column="deptName"/>
|
||||||
<result property="isCollect" column="is_collect"/>
|
<result property="isCollect" column="isCollect"/>
|
||||||
|
<result property="collectCount" column="collectCount"/>
|
||||||
<result property="score" column="score"/>
|
<result property="score" column="score"/>
|
||||||
|
<result property="applyState" column="applyState"/>
|
||||||
|
<result property="applyCount" column="applyCount"/>
|
||||||
<collection property="infoList" javaType="List" ofType="attrEntity">
|
<collection property="infoList" javaType="List" ofType="attrEntity">
|
||||||
<result property="id" column="id"/>
|
<result property="id" column="id"/>
|
||||||
<result property="dataResourceId" column="data_resource_id"/>
|
<result property="dataResourceId" column="data_resource_id"/>
|
||||||
|
@ -82,11 +85,11 @@
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<update id="deleteByIds">
|
<update id="deleteByIds">
|
||||||
update tb_data_resource
|
UPDATE tb_data_resource
|
||||||
set del_flag = 1,
|
SET del_flag = 1,
|
||||||
update_date = now()
|
update_date = NOW()
|
||||||
where 1 = 1
|
WHERE 1 = 1
|
||||||
and id in
|
AND id IN
|
||||||
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
||||||
#{item}
|
#{item}
|
||||||
</foreach>
|
</foreach>
|
||||||
|
@ -94,27 +97,42 @@
|
||||||
|
|
||||||
<select id="selectWithAttrs" resultMap="resourceDTO">
|
<select id="selectWithAttrs" resultMap="resourceDTO">
|
||||||
SELECT
|
SELECT
|
||||||
r.*,
|
tdr.*,
|
||||||
a.*
|
tda.*,
|
||||||
|
IFNULL(trs.score, 0 ) AS "score",
|
||||||
|
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
||||||
|
IFNULL(trc.collectCount, 0) AS "collectCount",
|
||||||
|
IFNULL(sd.name, '暂无部门信息') AS "deptName",
|
||||||
|
IFNULL(trc2.isCollect, 'false') AS "isCollect",
|
||||||
|
(IFNULL(tdr.visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(taa.applyCount, 0)+ IFNULL(trc.collectCount, 0)) AS total
|
||||||
FROM
|
FROM
|
||||||
tb_data_resource r,
|
tb_data_resource tdr
|
||||||
tb_data_attr a
|
LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id
|
||||||
|
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 = #{dto.creator}
|
||||||
|
GROUP BY resource_id
|
||||||
|
) trc2 ON tdr.id = trc2.resource_id
|
||||||
|
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
||||||
WHERE 1 = 1
|
WHERE 1 = 1
|
||||||
AND r.id = a.data_resource_id
|
AND tdr.type = #{dto.type}
|
||||||
AND r.type = #{dto.type}
|
AND tdr.del_flag = 0
|
||||||
AND r.del_flag = 0
|
|
||||||
<if test="dto.name != null and dto.name != ''" >
|
<if test="dto.name != null and dto.name != ''" >
|
||||||
AND r.name like CONCAT('%',#{dto.name},'%')
|
AND tdr.name like CONCAT('%',#{dto.name},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="dto.districtId != null and dto.districtId != ''" >
|
<if test="dto.districtId != null and dto.districtId != ''" >
|
||||||
AND r.district_id = #{dto.districtId}
|
AND tdr.district_id = #{dto.districtId}
|
||||||
</if>
|
</if>
|
||||||
<if test="dto.deptId != null and dto.deptId != ''" >
|
<if test="dto.deptId != null and dto.deptId != ''" >
|
||||||
AND r.dept_id = #{deptId}
|
AND tdr.dept_id = #{dto.deptId}
|
||||||
</if>
|
</if>
|
||||||
<if test="dto.infoList.size > 0">
|
<if test="dto.infoList.size > 0">
|
||||||
AND
|
AND
|
||||||
a.data_resource_id IN (
|
tda.data_resource_id IN (
|
||||||
SELECT data_resource_id
|
SELECT data_resource_id
|
||||||
FROM (
|
FROM (
|
||||||
SELECT tb.data_resource_id
|
SELECT tb.data_resource_id
|
||||||
|
@ -127,36 +145,38 @@
|
||||||
</foreach>) tb
|
</foreach>) tb
|
||||||
GROUP BY tb.data_resource_id
|
GROUP BY tb.data_resource_id
|
||||||
HAVING COUNT( tb.data_resource_id ) = ${dto.infoList.size}
|
HAVING COUNT( tb.data_resource_id ) = ${dto.infoList.size}
|
||||||
ORDER BY tb.data_resource_id ASC
|
|
||||||
) tmp
|
) tmp
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
|
ORDER BY ${orderField} ${orderType}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectTypeCount" resultType="java.util.Map">
|
<select id="selectTypeCount" resultType="java.util.Map">
|
||||||
select type, count(id) as "count"
|
SELECT
|
||||||
from tb_data_resource
|
type,
|
||||||
where 1 = 1
|
count(id) AS "count"
|
||||||
and del_flag = 0
|
FROM tb_data_resource
|
||||||
|
WHERE 1 = 1
|
||||||
|
AND del_flag = 0
|
||||||
<if test="deptId != null and deptId != ''">
|
<if test="deptId != null and deptId != ''">
|
||||||
and dept_id = #{deptId}
|
AND dept_id = #{deptId}
|
||||||
</if>
|
</if>
|
||||||
group by type
|
GROUP BY type
|
||||||
order by type
|
ORDER BY type
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectMostPopular" resultType="io.renren.modules.resource.dto.ResourceDTO">
|
<select id="selectMostPopular" resultType="io.renren.modules.resource.dto.ResourceDTO">
|
||||||
SELECT
|
SELECT
|
||||||
tdr.*,
|
tdr.*,
|
||||||
trs.score,
|
IFNULL(trs.score, 0 ) AS "score",
|
||||||
taa.applyCount,
|
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
||||||
trc.collectCount,
|
IFNULL(trc.collectCount, 0) AS "collectCount",
|
||||||
(IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) as total
|
(IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total
|
||||||
FROM
|
FROM
|
||||||
tb_data_resource tdr
|
tb_data_resource tdr
|
||||||
LEFT JOIN ( SELECT resource_id, SUM(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, SUM(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 "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, 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
|
||||||
WHERE
|
WHERE
|
||||||
1 = 1
|
1 = 1
|
||||||
AND tdr.del_flag = 0
|
AND tdr.del_flag = 0
|
||||||
|
@ -169,4 +189,69 @@
|
||||||
ORDER BY ${orderFiled} ${orderType}
|
ORDER BY ${orderFiled} ${orderType}
|
||||||
LIMIT ${pageNum}, ${pageSize}
|
LIMIT ${pageNum}, ${pageSize}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectDTOById" resultType="io.renren.modules.resource.dto.ResourceDTO">
|
||||||
|
SELECT
|
||||||
|
tdr.*,
|
||||||
|
tda.*,
|
||||||
|
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.applyState, 'false') AS "applyState"
|
||||||
|
FROM
|
||||||
|
tb_data_resource tdr
|
||||||
|
LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id
|
||||||
|
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 = #{dto.creator}
|
||||||
|
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id
|
||||||
|
LEFT JOIN ( SELECT resource_id, user_id, ( CASE approve_status WHEN '通过' THEN 'true' ELSE 'false' END ) AS "applyState" FROM t_ability_application WHERE
|
||||||
|
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
|
||||||
|
GROUP BY resource_id) taa2 ON tdr.id = taa2.resource_id
|
||||||
|
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
||||||
|
WHERE 1 = 1
|
||||||
|
AND tdr.del_flag = 0
|
||||||
|
AND tdr.id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectDTOPage" resultType="io.renren.modules.resource.dto.ResourceDTO">
|
||||||
|
SELECT
|
||||||
|
tdr.*,
|
||||||
|
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.applyState, 'false') AS "applyState",
|
||||||
|
(IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total
|
||||||
|
FROM
|
||||||
|
tb_data_resource tdr
|
||||||
|
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 = #{dto.creator}
|
||||||
|
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id
|
||||||
|
LEFT JOIN ( SELECT resource_id, user_id, ( CASE approve_status WHEN '通过' THEN 'true' ELSE 'false' END ) AS "applyState" FROM t_ability_application WHERE
|
||||||
|
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
|
||||||
|
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
|
||||||
|
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
||||||
|
WHERE 1 = 1
|
||||||
|
AND tdr.del_flag = 0
|
||||||
|
<if test="dto.name != null and dto.name != ''" >
|
||||||
|
AND tdr.name LIKE CONCAT('%',#{dto.name},'%')
|
||||||
|
</if>
|
||||||
|
<if test="dto.type != null and dto.type != ''" >
|
||||||
|
AND tdr.type = #{dto.type}
|
||||||
|
</if>
|
||||||
|
<if test="dto.districtId != null and dto.districtId != ''" >
|
||||||
|
AND tdr.district_id = #{dto.districtId}
|
||||||
|
</if>
|
||||||
|
ORDER BY ${orderField} ${orderType}
|
||||||
|
LIMIT ${pageNum}, ${pageSize}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -30,6 +30,17 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="delete4Resource">
|
||||||
|
update tb_resource_car
|
||||||
|
set del_flag = 1,
|
||||||
|
update_date = now()
|
||||||
|
where 1 = 1
|
||||||
|
and resource_id in
|
||||||
|
<foreach collection="resourceIds" item="item" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
|
|
||||||
<select id="selectPageWithResource" resultType="io.renren.modules.resourceCar.dto.ResourceCarDTO">
|
<select id="selectPageWithResource" resultType="io.renren.modules.resourceCar.dto.ResourceCarDTO">
|
||||||
select trc.*
|
select trc.*
|
||||||
from tb_resource_car trc
|
from tb_resource_car trc
|
||||||
|
|
|
@ -30,6 +30,17 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="delete4Resource">
|
||||||
|
update tb_resource_collection
|
||||||
|
set del_flag = 1,
|
||||||
|
update_date = now()
|
||||||
|
where 1 = 1
|
||||||
|
and resource_id in
|
||||||
|
<foreach collection="resourceIds" item="item" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
|
|
||||||
<select id="selectPageWithResource" resultType="io.renren.modules.resourceCollection.dto.ResourceCollectionDTO">
|
<select id="selectPageWithResource" resultType="io.renren.modules.resourceCollection.dto.ResourceCollectionDTO">
|
||||||
select trc.*
|
select trc.*
|
||||||
from tb_resource_collection trc
|
from tb_resource_collection trc
|
||||||
|
|
|
@ -32,4 +32,15 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="delete4Resource">
|
||||||
|
update tb_resource_score
|
||||||
|
set del_flag = 1,
|
||||||
|
update_date = now()
|
||||||
|
where 1 = 1
|
||||||
|
and resource_id in
|
||||||
|
<foreach collection="resourceIds" item="item" open="(" separator="," close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue