新增工作动态,门户搜索修改

This commit is contained in:
dinggang 2022-05-11 20:19:31 +08:00
parent 20d8ceb860
commit ba2cf96791
16 changed files with 237 additions and 113 deletions

View File

@ -111,6 +111,13 @@ public class ResourceController {
return new Result<>().ok(resourceService.selectRecommend()); return new Result<>().ok(resourceService.selectRecommend());
} }
@PostMapping("/selectDeptList")
@ApiOperation("查询部门企业列表及汇聚能力数量")
@LogOperation("查询部门企业列表及汇聚能力数量")
public Result selectDeptList(@RequestBody JSONObject jsonObject) {
return new Result().ok(resourceService.selectDeptList(jsonObject));
}
@GetMapping("/updateVisits") @GetMapping("/updateVisits")
@ApiOperation("更新能力访问量") @ApiOperation("更新能力访问量")
@LogOperation("更新能力访问量") @LogOperation("更新能力访问量")
@ -156,9 +163,7 @@ public class ResourceController {
@LogOperation("删除") @LogOperation("删除")
//@RequiresPermissions("resource:resource:delete") //@RequiresPermissions("resource:resource:delete")
public Result delete(@RequestBody JSONObject jsonObject) { public Result delete(@RequestBody JSONObject jsonObject) {
resourceService.deleteWithAttrs(jsonObject); resourceService.deleteWithAttrs(jsonObject);
return new Result(); return new Result();
} }

View File

@ -52,4 +52,8 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
* @return * @return
*/ */
Long countAllDept(); Long countAllDept();
List<Map<String, Object>> selectGroupByDeptId();
Integer selectTypeCountByDept(String type);
} }

View File

@ -39,6 +39,7 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
Object selectRecommend(); Object selectRecommend();
Object selectDeptList(JSONObject jsonObject);
List<Map<String, Object>> getAmountGroupByType(); List<Map<String, Object>> getAmountGroupByType();
Long countAllDept(); Long countAllDept();

View File

@ -31,6 +31,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
/** /**
* 资源表 * 资源表
@ -221,7 +222,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
List<ResourceDTO> resourceDTOS = resourceDao.selectMostPopular(selectMap); List<ResourceDTO> resourceDTOS = resourceDao.selectMostPopular(selectMap);
page.setRecords(resourceDTOS); page.setRecords(resourceDTOS);
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>(); QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag()).eq("type", jsonObject.getString("type")); queryWrapper.eq("del_flag", ResourceEntityDelFlag.NORMAL.getFlag())
.eq("type", jsonObject.getString("type"));
Integer count = resourceDao.selectCount(queryWrapper); Integer count = resourceDao.selectCount(queryWrapper);
page.setTotal(count); page.setTotal(count);
return page; return page;
@ -248,8 +250,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
//没有收藏和申请过按最热能力选取,否则根据应用领域最多类型推荐 //没有收藏和申请过按最热能力选取,否则根据应用领域最多类型推荐
if (applyAreaList.isEmpty()) { if (applyAreaList.isEmpty()) {
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
object.put("pageNum", 1); object.put("pageNum", 0);
object.put("pageSize", 6); object.put("pageSize", 9);
object.put("orderFiled", "total");
object.put("orderType", "DESC");
return this.selectMostPopular(object); return this.selectMostPopular(object);
} else { } else {
ResourceDTO resourceDTO = new ResourceDTO(); ResourceDTO resourceDTO = new ResourceDTO();
@ -261,7 +265,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resourceDTO.setInfoList(list); resourceDTO.setInfoList(list);
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(resourceDTO)); JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(resourceDTO));
jsonObject.put("pageNum", 1); jsonObject.put("pageNum", 1);
jsonObject.put("pageSize", 6); jsonObject.put("pageSize", 9);
jsonObject.put("orderField", "total");
jsonObject.put("orderType", "DESC");
return this.pageWithAttrs(jsonObject); return this.pageWithAttrs(jsonObject);
} }
} }
@ -276,4 +282,27 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
public Long countAllDept() { public Long countAllDept() {
return baseDao.countAllDept(); return baseDao.countAllDept();
} }
@Override
public Object selectDeptList(JSONObject jsonObject) {
ArrayList<Map> resultList = new ArrayList<>();
HashMap<String, Object> resourceMap = new HashMap<>();
resourceMap.put("type", "全部能力目录");
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("del_flag", 0);
resourceMap.put("total", resourceDao.selectCount(queryWrapper));
//resourceMap.put("dataList", resourceDao.selectList(queryWrapper));
resultList.add(resourceMap);
List<Map<String, Object>> typeMapList = resourceDao.selectGroupByDeptId();
Map<String, List<Map<String, Object>>> listMap = typeMapList.stream()
.collect(Collectors.groupingBy(m -> m.get("type").toString()));
listMap.entrySet().stream().forEach(item -> {
HashMap<Object, Object> map = new HashMap<>();
map.put("type", item.getKey());
map.put("total", resourceDao.selectTypeCountByDept(item.getKey()));
map.put("dataList", item.getValue());
resultList.add(map);
});
return resultList;
}
} }

View File

@ -37,6 +37,12 @@ public class SysDeptDTO extends TreeNode implements Serializable {
@NotBlank(message="{sysdept.name.require}", groups = DefaultGroup.class) @NotBlank(message="{sysdept.name.require}", groups = DefaultGroup.class)
private String name; private String name;
@ApiModelProperty(value = "类型1省级部门2市级部门3区级部门4企业")
private Integer type;
@ApiModelProperty(value = "")
private Long district;
@ApiModelProperty(value = "排序") @ApiModelProperty(value = "排序")
@Min(value = 0, message = "{sort.number}", groups = DefaultGroup.class) @Min(value = 0, message = "{sort.number}", groups = DefaultGroup.class)
private Integer sort; private Integer sort;
@ -76,6 +82,22 @@ public class SysDeptDTO extends TreeNode implements Serializable {
this.name = name; this.name = name;
} }
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Long getDistrict() {
return district;
}
public void setDistrict(Long district) {
this.district = district;
}
public Integer getSort() { public Integer getSort() {
return sort; return sort;
} }

View File

@ -29,6 +29,14 @@ public class SysDeptEntity extends BaseEntity {
* 部门名称 * 部门名称
*/ */
private String name; private String name;
/**
* 类型1省级部门2市级部门3区级部门4企业
*/
private Integer type;
/**
* 地区
*/
private Long district;
/** /**
* 排序 * 排序
*/ */

View File

@ -17,7 +17,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
@ -26,7 +25,6 @@ import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* 工作动态 * 工作动态
* *
@ -34,13 +32,13 @@ import java.util.Map;
* @since 1.0 2022-05-06 * @since 1.0 2022-05-06
*/ */
@RestController @RestController
@RequestMapping("workDynamics/workdynamics") @RequestMapping("/workdynamics")
@Api(tags="工作动态") @Api(tags="工作动态")
public class WorkDynamicsController { public class WorkDynamicsController {
@Autowired @Autowired
private WorkDynamicsService workDynamicsService; private WorkDynamicsService workDynamicsService;
@GetMapping("page") @GetMapping("/page")
@ApiOperation("分页") @ApiOperation("分页")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="int") , @ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="int") ,
@ -55,7 +53,7 @@ public class WorkDynamicsController {
return new Result<PageData<WorkDynamicsDTO>>().ok(page); return new Result<PageData<WorkDynamicsDTO>>().ok(page);
} }
@GetMapping("{id}") @GetMapping("/select/{id}")
@ApiOperation("信息") @ApiOperation("信息")
//@RequiresPermissions("workDynamics:workdynamics:info") //@RequiresPermissions("workDynamics:workdynamics:info")
public Result<WorkDynamicsDTO> get(@PathVariable("id") Long id){ public Result<WorkDynamicsDTO> get(@PathVariable("id") Long id){
@ -64,7 +62,7 @@ public class WorkDynamicsController {
return new Result<WorkDynamicsDTO>().ok(data); return new Result<WorkDynamicsDTO>().ok(data);
} }
@PostMapping @PostMapping("/insert")
@ApiOperation("保存") @ApiOperation("保存")
@LogOperation("保存") @LogOperation("保存")
//@RequiresPermissions("workDynamics:workdynamics:save") //@RequiresPermissions("workDynamics:workdynamics:save")
@ -77,7 +75,7 @@ public class WorkDynamicsController {
return new Result(); return new Result();
} }
@PutMapping @PutMapping("/update")
@ApiOperation("修改") @ApiOperation("修改")
@LogOperation("修改") @LogOperation("修改")
//@RequiresPermissions("workDynamics:workdynamics:update") //@RequiresPermissions("workDynamics:workdynamics:update")
@ -90,7 +88,7 @@ public class WorkDynamicsController {
return new Result(); return new Result();
} }
@DeleteMapping @DeleteMapping("/delete")
@ApiOperation("删除") @ApiOperation("删除")
@LogOperation("删除") @LogOperation("删除")
//@RequiresPermissions("workDynamics:workdynamics:delete") //@RequiresPermissions("workDynamics:workdynamics:delete")
@ -98,12 +96,12 @@ public class WorkDynamicsController {
//效验数据 //效验数据
AssertUtils.isArrayEmpty(ids, "id"); AssertUtils.isArrayEmpty(ids, "id");
workDynamicsService.delete(ids); workDynamicsService.deleteByIds(ids);
return new Result(); return new Result();
} }
@GetMapping("export") @GetMapping("/export")
@ApiOperation("导出") @ApiOperation("导出")
@LogOperation("导出") @LogOperation("导出")
//@RequiresPermissions("workDynamics:workdynamics:export") //@RequiresPermissions("workDynamics:workdynamics:export")

View File

@ -3,6 +3,7 @@ package io.renren.modules.workDynamics.dao;
import io.renren.common.dao.BaseDao; import io.renren.common.dao.BaseDao;
import io.renren.modules.workDynamics.entity.WorkDynamicsEntity; import io.renren.modules.workDynamics.entity.WorkDynamicsEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* 工作动态 * 工作动态
@ -13,4 +14,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface WorkDynamicsDao extends BaseDao<WorkDynamicsEntity> { public interface WorkDynamicsDao extends BaseDao<WorkDynamicsEntity> {
Integer deleteByIds(@Param("ids") Long[] ids);
} }

View File

@ -24,10 +24,10 @@ public class WorkDynamicsDTO implements Serializable {
private String title; private String title;
@ApiModelProperty(value = "导航图保存地址") @ApiModelProperty(value = "导航图保存地址")
private String imageUrl; private String imageUrl;
@ApiModelProperty(value = "文件地址") @ApiModelProperty(value = "内容")
private String fileUrl; private String content;
@ApiModelProperty(value = "删除标志0:正常1:删除9:其他") @ApiModelProperty(value = "删除标志0:正常1:删除9:其他")
private Integer delFalg; private Integer delFlag;
@ApiModelProperty(value = "创建人") @ApiModelProperty(value = "创建人")
private Long creator; private Long creator;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "创建时间")

View File

@ -31,13 +31,13 @@ public class WorkDynamicsEntity {
*/ */
private String imageUrl; private String imageUrl;
/** /**
* 文件地址 * 内容
*/ */
private String fileUrl; private String content;
/** /**
* 删除标志0:正常1:删除9:其他 * 删除标志0:正常1:删除9:其他
*/ */
private Integer delFalg; private Integer delFlag;
/** /**
* 创建人 * 创建人
*/ */

View File

@ -27,7 +27,7 @@ public class WorkDynamicsExcel {
@ExcelProperty(value = "文件地址", index = 3) @ExcelProperty(value = "文件地址", index = 3)
private String fileUrl; private String fileUrl;
@ExcelProperty(value = "删除标志0:正常1:删除9:其他", index = 4) @ExcelProperty(value = "删除标志0:正常1:删除9:其他", index = 4)
private Integer delFalg; private Integer delFlag;
@ExcelProperty(value = "创建人", index = 5) @ExcelProperty(value = "创建人", index = 5)
private Long creator; private Long creator;
@ExcelProperty(value = "创建时间", index = 6) @ExcelProperty(value = "创建时间", index = 6)

View File

@ -12,4 +12,5 @@ import io.renren.modules.workDynamics.entity.WorkDynamicsEntity;
*/ */
public interface WorkDynamicsService extends CrudService<WorkDynamicsEntity, WorkDynamicsDTO> { public interface WorkDynamicsService extends CrudService<WorkDynamicsEntity, WorkDynamicsDTO> {
void deleteByIds(Long[] ids);
} }

View File

@ -9,6 +9,7 @@ import io.renren.modules.workDynamics.entity.WorkDynamicsEntity;
import io.renren.modules.workDynamics.service.WorkDynamicsService; import io.renren.modules.workDynamics.service.WorkDynamicsService;
import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.SecurityUser;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Map; import java.util.Map;
@ -22,13 +23,21 @@ import java.util.Map;
@Service @Service
public class WorkDynamicsServiceImpl extends CrudServiceImpl<WorkDynamicsDao, WorkDynamicsEntity, WorkDynamicsDTO> implements WorkDynamicsService { public class WorkDynamicsServiceImpl extends CrudServiceImpl<WorkDynamicsDao, WorkDynamicsEntity, WorkDynamicsDTO> implements WorkDynamicsService {
@Autowired
private WorkDynamicsDao workDynamicsDao;
@Override @Override
public QueryWrapper<WorkDynamicsEntity> getWrapper(Map<String, Object> params){ public QueryWrapper<WorkDynamicsEntity> getWrapper(Map<String, Object> params){
QueryWrapper<WorkDynamicsEntity> wrapper = new QueryWrapper<>(); QueryWrapper<WorkDynamicsEntity> wrapper = new QueryWrapper<>();
wrapper.eq("del_flag", 0)
.orderByDesc("create_date");
return wrapper; return wrapper;
} }
@Override
public void deleteByIds(Long[] ids) {
workDynamicsDao.deleteByIds(ids);
}
} }

View File

@ -5,7 +5,6 @@ spring:
druid: druid:
#MySQL #MySQL
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://15.2.21.238:3310/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false url: jdbc:mysql://15.2.21.238:3310/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
username: root username: root
password: Hisense2019 password: Hisense2019

View File

@ -99,32 +99,31 @@
SELECT SELECT
tdr.*, tdr.*,
tda.*, tda.*,
IFNULL(taa2.approve_status, '未申请') AS "applyState",
IFNULL(trs.score, 0 ) AS "score", IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount", IFNULL(taa.applyCount, 0 ) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "collectCount", IFNULL(trc.collectCount, 0) AS "collectCount",
IFNULL(sd.name, '暂无部门信息') AS "deptName", IFNULL(sd.name, '暂无部门信息') AS "deptName",
IFNULL(trc2.isCollect, 'false') AS "isCollect", IFNULL(trc2.isCollect, 'false') AS "isCollect",
(IFNULL(tdr.visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(taa.applyCount, 0)+ IFNULL(trc.collectCount, 0)) AS (IFNULL(tdr.visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(taa.applyCount, 0)+ IFNULL(trc.collectCount, 0)) AS total
total
FROM FROM
tb_data_resource tdr tb_data_resource tdr
LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id 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 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
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 = 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
0 GROUP BY resource_id ) taa ON tdr.id = taa.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
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 1 = 1
AND del_flag = 0 AND del_flag = 0
AND user_id = #{dto.creator} AND user_id = #{dto.creator}
GROUP BY resource_id GROUP BY resource_id
) trc2 ON tdr.id = trc2.resource_id ) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT resource_id, user_id, approve_status 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 LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE 1 = 1 WHERE 1 = 1
AND tdr.type = #{dto.type} AND tdr.type LIKE CONCAT('%',#{dto.type},'%')
AND tdr.del_flag = 0 AND tdr.del_flag = 0
<if test="dto.name != null and dto.name != ''"> <if test="dto.name != null and dto.name != ''">
AND tdr.name like CONCAT('%',#{dto.name},'%') AND tdr.name like CONCAT('%',#{dto.name},'%')
@ -172,60 +171,52 @@
<select id="selectMostPopular" resultType="io.renren.modules.resource.dto.ResourceDTO"> <select id="selectMostPopular" resultType="io.renren.modules.resource.dto.ResourceDTO">
SELECT SELECT
tdr.*, tdr.*,
IFNULL(trs.score, 0 ) AS "score", IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount", IFNULL(taa.applyCount, 0 ) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "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 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
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 = 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
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
WHERE WHERE
1 = 1 1 = 1
AND tdr.del_flag = 0 AND tdr.del_flag = 0
<if test="type != null and type != ''"> <if test="type != null and type != ''">
AND tdr.type = #{type} AND tdr.type LIKE CONCAT('%',#{type},'%')
</if> </if>
<if test="name != null and name != ''"> <if test="name != null and name != ''">
AND tdr.name LIKE CONCAT('%',#{name},'%') AND tdr.name LIKE CONCAT('%',#{name},'%')
</if> </if>
ORDER BY ${orderFiled} ${orderType} ORDER BY ${orderFiled} ${orderType}
LIMIT ${pageNum}, ${pageSize} LIMIT ${pageNum}, ${pageSize}
</select> </select>
<select id="selectDTOById" resultMap="resourceDTO"> <select id="selectDTOById" resultMap="resourceDTO">
SELECT SELECT
tdr.*, tdr.*,
tda.*, tda.*,
IFNULL(trs.score, 0 ) AS "score", IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount", IFNULL(taa.applyCount, 0 ) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "collectCount", IFNULL(trc.collectCount, 0) AS "collectCount",
sd.name as "deptName", sd.name as "deptName",
IFNULL(trc2.isCollect, 'false') AS "isCollect", IFNULL(trc2.isCollect, 'false') AS "isCollect",
IFNULL(taa2.applyState, 'false') AS "applyState" IFNULL(taa2.approve_status, '未申请') AS "applyState"
FROM FROM
tb_data_resource tdr tb_data_resource tdr
LEFT JOIN tb_data_attr tda ON tdr.id = tda.data_resource_id 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 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
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 = 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
0 GROUP BY resource_id ) taa ON tdr.id = taa.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
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag 1 = 1 AND del_flag = 0 AND user_id = #{userId}
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect" LEFT JOIN ( SELECT resource_id, approve_status FROM t_ability_application WHERE
FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 AND user_id = #{userId}
1 = 1 AND del_flag = 0 AND user_id = #{userId} GROUP BY id) taa2 ON tdr.id = taa2.resource_id
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id LEFT JOIN sys_dept sd ON tdr.dept_id = sd.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 = #{userId}
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
WHERE 1 = 1 WHERE 1 = 1
<!-- AND tdr.del_flag = 0--> <!-- AND tdr.del_flag = 0-->
AND tdr.id = #{id} AND tdr.id = #{id}
@ -233,42 +224,40 @@
<select id="selectDTOPage" resultType="io.renren.modules.resource.dto.ResourceDTO"> <select id="selectDTOPage" resultType="io.renren.modules.resource.dto.ResourceDTO">
SELECT SELECT
tdr.*, tdr.*,
IFNULL(trs.score, 0 ) AS "score", IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount", IFNULL(taa.applyCount, 0 ) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "collectCount", IFNULL(trc.collectCount, 0) AS "collectCount",
sd.name AS "deptName", sd.name AS "deptName",
IFNULL(trc2.isCollect, 'false') AS "isCollect", IFNULL(trc2.isCollect, 'false') AS "isCollect",
IFNULL(taa2.applyState, 'false') AS "applyState", IFNULL(taa2.approve_status, '未申请') AS "applyState",
(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, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP 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
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 = 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
0 GROUP BY resource_id ) taa ON tdr.id = taa.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
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND del_flag 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
= 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id
LEFT JOIN ( SELECT resource_id, user_id, ( CASE COUNT( id ) WHEN 1 THEN 'true' ELSE 'false' END ) AS "isCollect" LEFT JOIN ( SELECT resource_id, approve_status FROM t_ability_application WHERE
FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 AND user_id = #{dto.creator}
1 = 1 AND del_flag = 0 AND user_id = #{dto.creator} GROUP BY id) taa2 ON tdr.id = taa2.resource_id
GROUP BY resource_id) trc2 ON tdr.id = trc2.resource_id LEFT JOIN sys_dept sd ON tdr.dept_id = sd.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 WHERE 1 = 1
AND tdr.del_flag = 0 AND tdr.del_flag = 0
<if test="dto.name != null and dto.name != ''"> <if test="dto.name != null and dto.name != ''" >
AND tdr.name LIKE CONCAT('%',#{dto.name},'%') AND tdr.name LIKE CONCAT('%',#{dto.name},'%')
</if> </if>
<if test="dto.type != null and dto.type != ''"> <if test="dto.type != null and dto.type != ''" >
AND tdr.type = #{dto.type} AND tdr.type = #{dto.type}
</if> </if>
<if test="dto.districtId != null and dto.districtId != ''"> <if test="dto.districtId != null and dto.districtId != ''" >
AND tdr.district_id = #{dto.districtId} AND tdr.district_id = #{dto.districtId}
</if> </if>
<if test="dto.deptId != null and dto.deptId != ''" >
AND tdr.dept_id = #{dto.deptId}
</if>
ORDER BY ${orderField} ${orderType} ORDER BY ${orderField} ${orderType}
LIMIT ${pageNum}, ${pageSize} LIMIT ${pageNum}, ${pageSize}
</select> </select>
@ -326,4 +315,50 @@
WHERE WHERE
del_flag = 0 del_flag = 0
</select> </select>
<select id="selectGroupByDeptId" resultType="java.util.Map">
SELECT
*
FROM
(
SELECT
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
sd.NAME AS "deptName",
IFNULL( tdr.deptCount, 0 ) AS "deptCount",
sd.id AS "deptId"
FROM
sys_dept sd
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 GROUP BY dept_id ) tdr ON sd.id = tdr.dept_id
) temp1
WHERE
1 = 1
AND temp1.deptCount != 0
</select>
<select id="selectTypeCountByDept" resultType="java.lang.Integer">
SELECT
SUM( deptCount )
FROM
(
SELECT
*
FROM
(
SELECT
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
sd.NAME AS "deptName",
IFNULL( tdr.deptCount, 0 ) AS "deptCount"
FROM
sys_dept sd
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0 GROUP BY dept_id ) tdr ON sd.id = tdr.dept_id
) temp1
WHERE
1 = 1
AND temp1.deptCount != 0
) temp2
WHERE 1 = 1
AND temp2.type = #{type}
GROUP BY
temp2.type
</select>
</mapper> </mapper>

View File

@ -7,8 +7,8 @@
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="title" column="title"/> <result property="title" column="title"/>
<result property="imageUrl" column="image_url"/> <result property="imageUrl" column="image_url"/>
<result property="fileUrl" column="file_url"/> <result property="content" column="content"/>
<result property="delFalg" column="del_falg"/> <result property="delFlag" column="del_flag"/>
<result property="creator" column="creator"/> <result property="creator" column="creator"/>
<result property="createDate" column="create_date"/> <result property="createDate" column="create_date"/>
<result property="updater" column="updater"/> <result property="updater" column="updater"/>
@ -20,4 +20,15 @@
<result property="note5" column="note5"/> <result property="note5" column="note5"/>
</resultMap> </resultMap>
<update id="deleteByIds">
update tb_work_dynamics
set del_flag = 1 ,
update_date = now()
where 1 = 1
and id in
<foreach collection="ids" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</update>
</mapper> </mapper>