门户首页查询最新能力,最热能力实现修改,编目字段表新增字段,能力资源表字段修改

This commit is contained in:
dinggang 2022-04-25 14:08:34 +08:00
parent cd0aca28c8
commit b5dd0c91f8
10 changed files with 81 additions and 70 deletions

View File

@ -28,6 +28,8 @@ public class CategoryDTO implements Serializable {
private Long pid;
@ApiModelProperty(value = "是否为属性字段,true/false")
private String isAttr;
@ApiModelProperty(value = "输入类型input/单行文本textArea/多行文本select/下拉选择img/图片video/视频file/文件")
private String type;
@ApiModelProperty(value = "是否作为筛选条件,true/false")
private String isFilterCriteria;
@ApiModelProperty(value = "是否和字典表关联,true/false")

View File

@ -42,6 +42,10 @@ public class Category implements Serializable {
* 是否为属性字段,true/false
*/
private String isAttr;
/**
* 输入类型input/单行文本textArea/多行文本select/下拉选择img/图片video/视频file/文件
*/
private String type;
/**
* 是否作为筛选条件,true/false
*/

View File

@ -93,14 +93,14 @@ public class ResourceController {
return new Result<>().ok(resourceService.selectTotal());
}
@GetMapping("/selectNewest")
@PostMapping("/selectNewest")
@ApiOperation("查询最新上架能力")
@LogOperation("查询最新上架能力")
public Result selectNewest(@RequestBody JSONObject jsonObject) {
return new Result<>().ok(resourceService.selectNewest(jsonObject));
}
@GetMapping("/selectMostPopular")
@PostMapping("/selectMostPopular")
@ApiOperation("查询热门能力")
@LogOperation("查询热门能力")
public Result selectMostPopular(@RequestBody JSONObject jsonObject) {
@ -110,11 +110,8 @@ public class ResourceController {
@GetMapping("/updateVisits")
@ApiOperation("更新能力访问量")
@LogOperation("更新能力访问量")
public Result updateVisits(@RequestBody ResourceEntity resourceEntity) {
if (ObjectUtils.isEmpty(resourceEntity.getId()) || ObjectUtils.isEmpty(resourceEntity.getVisits())) {
return new Result().error();
}
resourceService.updateVisits(resourceEntity);
public Result updateVisits(@RequestParam Long id) {
resourceService.updateVisits(id);
return new Result();
}

View File

@ -24,5 +24,5 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
List<Map> selectTypeCount(Long deptId);
List<ResourceDTO> selectMostPopular();
List<ResourceDTO> selectMostPopular(Map<String, Object> selectMap);
}

View File

@ -20,7 +20,7 @@ import java.util.List;
public class ResourceDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
@ApiModelProperty(value = "主键ID")
private Long id;
@ApiModelProperty(value = "类型:基础设施,数据资源等")
private String type;
@ -30,20 +30,20 @@ public class ResourceDTO implements Serializable {
private String description;
@ApiModelProperty(value = "链接URL")
private String link;
@ApiModelProperty(value = "apiURL")
private String apiUrl;
@ApiModelProperty(value = "groupID")
private String groupId;
@ApiModelProperty(value = "所属部门")
private Long deptId;
@ApiModelProperty(value = "部门联系人")
private String deptContacts;
@ApiModelProperty(value = "联系电话")
private String deptPhone;
@ApiModelProperty(value = "地区编码")
private Long districtId;
@ApiModelProperty(value = "图片保存地址")
private String image;
@ApiModelProperty(value = "数据量")
private String dataVolume;
@ApiModelProperty(value = "访问量")
private Long visits;
@ApiModelProperty(value = "下载量")
private Long downloads;
@ApiModelProperty(value = "评分")
private String score;
@ApiModelProperty(value = "删除标志0:正常1:已删除9其他")
private Integer delFlag;
@ApiModelProperty(value = "创建人")

View File

@ -3,6 +3,8 @@ package io.renren.modules.resource.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.baomidou.mybatisplus.annotation.*;
import java.io.Serializable;
import java.util.Date;
/**
@ -39,34 +41,34 @@ public class ResourceEntity {
*/
private String link;
/**
* apiURL
*/
private String apiUrl;
/**
* groupID
*/
private String groupId;
/**
* 所属部门
*/
private Long deptId;
/**
* 部门联系人
*/
private String deptContacts;
/**
* 联系电话
*/
private String deptPhone;
/**
* 地区编码
*/
private Long districtId;
/**
* 图片保存地址
*/
private String image;
/**
* 数据量
*/
private String dataVolume;
/**
* 访问量
*/
private Long visits;
/**
* 下载量
*/
private Long downloads;
/**
* 评分
*/
private String score;
/**
* 删除标志0:正常1:已删除9其他
*/
private Integer delFlag;

View File

@ -38,5 +38,5 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
Object selectMostPopular(JSONObject jsonObject);
void updateVisits(ResourceEntity resourceEntity);
void updateVisits(Long id);
}

View File

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -80,8 +81,6 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resourceEntity.setDelFlag(0);
resourceDao.insert(resourceEntity);
BeanUtils.copyProperties(resourceEntity, dto); // 将entity id 写入 dto
List<AttrEntity> attrEntities= dto.getInfoList();
attrEntities.forEach(item -> {
item.setDelFlag(0);
@ -237,26 +236,32 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
@Override
public Object selectNewest(JSONObject jsonObject) {
IPage<ResourceEntity> page = new Page<>(jsonObject.getIntValue("pageNum"), jsonObject.getIntValue("pageSize"));
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc("create_date")
.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type"));
return resourceDao.selectList(queryWrapper);
.eq(StringUtils.isNotBlank(jsonObject.getString("type")),"type", jsonObject.getString("type"))
.eq("del_flag", 0);
IPage<ResourceEntity> entityIPage = resourceDao.selectPage(page, queryWrapper);
return entityIPage;
}
@Override
public Object selectMostPopular(JSONObject jsonObject) {
resourceDao.selectMostPopular();
return null;
Map<String, Object> selectMap = JSON.toJavaObject(jsonObject, Map.class);
List<ResourceDTO> resourceDTOS = resourceDao.selectMostPopular(selectMap);
return resourceDTOS;
}
@Override
public void updateVisits(ResourceEntity resourceEntity) {
public void updateVisits(Long id) {
ResourceEntity resourceEntity = resourceDao.selectById(id);
ResourceEntity entity = new ResourceEntity();
entity.setVisits(resourceEntity.getVisits() + 1);
UpdateWrapper<ResourceEntity> updateWrapper = new UpdateWrapper<>();
updateWrapper.lambda()
.set(ResourceEntity::getVisits, resourceEntity.getVisits() + 1L)
.eq(ResourceEntity::getId, resourceEntity.getId())
.eq(ResourceEntity::getDelFlag, 0);
resourceDao.update(null, updateWrapper);
resourceDao.update(entity, updateWrapper);
}
}

View File

@ -33,7 +33,6 @@ public class ResourceScoreServiceImpl extends CrudServiceImpl<ResourceScoreDao,
public QueryWrapper<ResourceScoreEntity> getWrapper(Map<String, Object> params){
QueryWrapper<ResourceScoreEntity> wrapper = new QueryWrapper<>();
return wrapper;
}
@ -52,7 +51,9 @@ public class ResourceScoreServiceImpl extends CrudServiceImpl<ResourceScoreDao,
.eq("del_flag", 0);
ResourceScoreDTO scoreDTO = new ResourceScoreDTO();
ResourceScoreEntity scoreEntity = resourceScoreDao.selectOne(queryWrapper);
if (ObjectUtils.allNotNull(scoreEntity)) {
BeanUtils.copyProperties(scoreEntity, scoreDTO);
}
return scoreDTO;
}
}

View File

@ -10,12 +10,10 @@
<result property="description" column="description"/>
<result property="link" column="link"/>
<result property="deptId" column="dept_id"/>
<result property="deptContacts" column="dept_contacts"/>
<result property="deptPhone" column="dept_phone"/>
<result property="districtId" column="district_id"/>
<result property="image" column="image"/>
<result property="dataVolume" column="data_volume"/>
<result property="visits" column="visits"/>
<result property="downloads" column="downloads"/>
<result property="score" column="score"/>
<result property="delFlag" column="del_flag"/>
<result property="creator" column="creator"/>
<result property="createDate" column="create_date"/>
@ -35,12 +33,10 @@
<result property="description" column="description"/>
<result property="link" column="link"/>
<result property="deptId" column="dept_id"/>
<result property="deptContacts" column="dept_contacts"/>
<result property="deptPhone" column="dept_phone"/>
<result property="districtId" column="district_id"/>
<result property="image" column="image"/>
<result property="dataVolume" column="data_volume"/>
<result property="visits" column="visits"/>
<result property="downloads" column="downloads"/>
<result property="score" column="score"/>
<result property="delFlag" column="del_flag"/>
<result property="creator" column="creator"/>
<result property="createDate" column="create_date"/>
@ -135,23 +131,27 @@
<select id="selectMostPopular" resultType="io.renren.modules.resource.dto.ResourceDTO">
SELECT
tdr.id,
tdr.dept_id,
tdr.description,
tdr.downloads,
tdr.visits,
tdr.*,
trs.score,
taa.applyCount,
(IFNULL(downloads, 0) + IFNULL(visits, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)) as total
trc.collectCount,
(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, SUM( score ) AS "score" FROM tb_resource_score WHERE 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 del_flag = 0 GROUP BY resource_id ) taa ON tdr.id = taa.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 "collectCount" FROM tb_resource_collection WHERE 1 = 1 and del_flag = 0 GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
WHERE
1 = 1
AND tdr.id = trs.resource_id
AND tdr.del_flag = 0
ORDER BY downloads DESC
<if test="type != null and type != ''">
AND tdr.type = #{type}
</if>
<if test="name != null and name != ''">
AND tdr.name LIKE CONCAT('%',#{name},'%')
</if>
ORDER BY ${orderFiled} ${orderType}
LIMIT ${pageNum}, ${pageSize}
</select>
</mapper>