新增浏览记录,算法仓查询接口,修复能力修改bug

This commit is contained in:
dinggang 2022-05-17 18:13:13 +08:00
parent b49f52b121
commit c073b8fe41
15 changed files with 426 additions and 18 deletions

View File

@ -1,9 +1,11 @@
package io.renren.common.controller;
import com.alibaba.fastjson.JSONObject;
import io.renren.common.annotation.LogOperation;
import io.renren.common.utils.Result;
import io.renren.modules.processForm.service.TAbilityApplicationService;
import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.resourceBrowse.service.ResourceBrowseService;
import io.renren.modules.sys.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -11,10 +13,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
@ -35,6 +36,8 @@ public class CensusController {
private SysUserService sysUserService;
@Autowired
private TAbilityApplicationService tAbilityApplicationService;
@Autowired
private ResourceBrowseService resourceBrowseService;
@Value("${census.type}")
private String[] censusTypes; // 需要进行统计的资源类型
@ -151,4 +154,16 @@ public class CensusController {
});
return new Result<List<Map<String, Object>>>().ok(dbAmount);
}
@PostMapping("/trafficStatistics")
@ApiOperation("浏览量统计")
@LogOperation("浏览量统计")
public Result trafficStatistics(@RequestBody JSONObject jsonObject) {
HashMap<String, Object> resultMap = new HashMap<>();
String startDate = jsonObject.getString("startDate");
String endDate = jsonObject.getString("endDate");
resultMap.put("browseAvg", null);
//resultMap.put("browseMax", resourceBrowseService.selectMax());
return new Result().ok(resultMap);
}
}

View File

@ -47,12 +47,10 @@ public class ResourceController {
@ApiImplicitParam(name = "name", value = "资源名称", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "creator", value = "创建者用户id", paramType = "query", dataType = "String")
@ApiImplicitParam(name = "creator", value = "创建者用户id", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "delFlag", value = "创建者用户id", paramType = "query", dataType = "String")
})
public Result<PageData<ResourceDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
//if (!params.containsKey("del_flag")) {
// params.put("del_flag", 0);
//}
PageData<ResourceDTO> page = resourceService.page(params);
page.getList().forEach(item -> {
item.setInfoList(resourceService.selectAttrsByResourceId(item.getId()));
@ -168,6 +166,19 @@ public class ResourceController {
return new Result();
}
@GetMapping("algorithmPage")
@ApiOperation("算法仓分页查询")
@LogOperation("算法仓分页查询")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = "name", value = "资源名称", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),
})
public Result algorithmPage(@ApiIgnore@RequestParam Map<String, Object> params) {
return new Result().ok(resourceService.algorithmPage(params));
}
/*
@GetMapping("export")
@ApiOperation("导出")

View File

@ -56,4 +56,6 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
List<Map<String, Object>> selectGroupByDeptId(@Param("type") String type);
Integer selectTypeCountByDept(@Param("deptType") String deptType, @Param("resourceType") String resourceType);
List<ResourceDTO> selectAlgorithmPage(Map<String, Object> params);
}

View File

@ -43,4 +43,7 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
List<Map<String, Object>> getAmountGroupByType();
Long countAllDept();
Object algorithmPage(Map<String, Object> params);
}

View File

@ -69,18 +69,21 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
wrapper.like(StringUtils.isNotBlank(params.get("name").toString()), "name", params.get("name").toString());
break;
case "creator":
wrapper.eq(StringUtils.isNotBlank(params.get("creator").toString()), "creator", params.get("creator").toString())
.ne("del_flag", 1);
wrapper.eq(StringUtils.isNotBlank(params.get("creator").toString()), "creator", params.get("creator").toString());
break;
//case "del_flag":
// wrapper.eq("del_flag", params.get("del_flag"));
// break;
}
});
wrapper.orderByDesc("create_date");
//if (!params.containsKey("creator") || StringUtils.isEmpty(params.get("creator").toString())) { // 创建者查询时
// wrapper.ne("del_flag", 1);
//}
if (params.containsKey("selectType") && "1".equals(params.get("selectType").toString())) { // 创建者查询时
wrapper.ne("del_flag", 1);
} else if (params.containsKey("selectType") && "0".equals(params.get("selectType").toString())) {
if (params.containsKey("delFlag") && !"".equals(params.get("delFlag").toString())) {
wrapper.eq("del_flag", params.get("delFlag"));
} else {
wrapper.in(true,"del_flag", 0,5);
}
}
wrapper.orderByAsc("del_flag")
.orderByDesc("create_date");
return wrapper;
}
@ -132,6 +135,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
attrDao.delete4Resource(list);
List<AttrEntity> attrEntities = dto.getInfoList();
attrEntities.forEach(item -> {
item.setId(null);
item.setDelFlag(ResourceEntityDelFlag.NORMAL.getFlag());
attrDao.insert(item);
});
@ -326,4 +330,11 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
});
return resultList;
}
@Override
public Object algorithmPage(Map<String, Object> params) {
params.put("pageNum", (Integer.parseInt(params.get("page").toString()) -1) * Integer.parseInt(params.get("limit").toString()));
params.put("pageSize", params.get("limit"));
return resourceDao.selectAlgorithmPage(params);
}
}

View File

@ -0,0 +1,115 @@
package io.renren.modules.resourceBrowse.controller;
import io.renren.common.annotation.LogOperation;
import io.renren.common.constant.Constant;
import io.renren.common.page.PageData;
import io.renren.common.utils.ExcelUtils;
import io.renren.common.utils.Result;
import io.renren.common.validator.AssertUtils;
import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup;
import io.renren.common.validator.group.UpdateGroup;
import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
import io.renren.modules.resourceBrowse.excel.ResourceBrowseExcel;
import io.renren.modules.resourceBrowse.service.ResourceBrowseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 浏览记录
*
* @author dg
* @since 1.0 2022-05-17
*/
@RestController
@RequestMapping("/resourceBrowse")
@Api(tags="浏览记录")
public class ResourceBrowseController {
@Autowired
private ResourceBrowseService resourceBrowseService;
@GetMapping("/page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String")
})
//@RequiresPermissions("resourceBrowse:resourcebrowse:page")
public Result<PageData<ResourceBrowseDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<ResourceBrowseDTO> page = resourceBrowseService.page(params);
return new Result<PageData<ResourceBrowseDTO>>().ok(page);
}
@GetMapping("/select/{id}")
@ApiOperation("信息")
//@RequiresPermissions("resourceBrowse:resourcebrowse:info")
public Result<ResourceBrowseDTO> get(@PathVariable("id") Long id){
ResourceBrowseDTO data = resourceBrowseService.get(id);
return new Result<ResourceBrowseDTO>().ok(data);
}
@PostMapping("/insert")
@ApiOperation("保存")
@LogOperation("保存")
//@RequiresPermissions("resourceBrowse:resourcebrowse:save")
public Result save(@RequestBody ResourceBrowseDTO dto){
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
resourceBrowseService.save(dto);
return new Result();
}
//@PutMapping("/update")
//@ApiOperation("修改")
//@LogOperation("修改")
////@RequiresPermissions("resourceBrowse:resourcebrowse:update")
//public Result update(@RequestBody ResourceBrowseDTO dto){
// //效验数据
// ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
//
// resourceBrowseService.update(dto);
//
// return new Result();
//}
@DeleteMapping("/delete")
@ApiOperation("删除")
@LogOperation("删除")
//@RequiresPermissions("resourceBrowse:resourcebrowse:delete")
public Result delete(@RequestBody Long[] ids){
//效验数据
AssertUtils.isArrayEmpty(ids, "id");
resourceBrowseService.delete(ids);
return new Result();
}
@GetMapping("/export")
@ApiOperation("导出")
@LogOperation("导出")
//@RequiresPermissions("resourceBrowse:resourcebrowse:export")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<ResourceBrowseDTO> list = resourceBrowseService.list(params);
ExcelUtils.exportExcelToTarget(response, null, "浏览记录", list, ResourceBrowseExcel.class);
}
}

View File

@ -0,0 +1,16 @@
package io.renren.modules.resourceBrowse.dao;
import io.renren.common.dao.BaseDao;
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 浏览记录
*
* @author dg
* @since 1.0 2022-05-17
*/
@Mapper
public interface ResourceBrowseDao extends BaseDao<ResourceBrowseEntity> {
}

View File

@ -0,0 +1,44 @@
package io.renren.modules.resourceBrowse.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 浏览记录
*
* @author dg
* @since 1.0 2022-05-17
*/
@Data
@ApiModel(value = "浏览记录")
public class ResourceBrowseDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
private Long id;
@ApiModelProperty(value = "用户ID")
private Long userId;
@ApiModelProperty(value = "能力ID")
private Long resourceId;
@ApiModelProperty(value = "状态0:正常,")
private Integer state;
@ApiModelProperty(value = "创建人")
private Long creator;
@ApiModelProperty(value = "创建时间")
private Date createDate;
@ApiModelProperty(value = "修改人")
private Long updater;
@ApiModelProperty(value = "修改时间")
private Date updateDate;
@ApiModelProperty(value = "备用字段1")
private String note1;
@ApiModelProperty(value = "备用字段2")
private String note2;
@ApiModelProperty(value = "备用字段3")
private String note3;
}

View File

@ -0,0 +1,69 @@
package io.renren.modules.resourceBrowse.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import com.baomidou.mybatisplus.annotation.*;
import java.util.Date;
/**
* 浏览记录
*
* @author dg
* @since 1.0 2022-05-17
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("tb_resource_browse")
public class ResourceBrowseEntity {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId
private Long id;
/**
* 用户ID
*/
private Long userId;
/**
* 能力ID
*/
private Long resourceId;
/**
* 状态0:正常
*/
private Integer state;
/**
* 创建人
*/
@TableField(fill = FieldFill.INSERT)
private Long creator;
/**
* 创建时间
*/
@TableField(fill = FieldFill.INSERT)
private Date createDate;
/**
* 修改人
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Long updater;
/**
* 修改时间
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private Date updateDate;
/**
* 备用字段1
*/
private String note1;
/**
* 备用字段2
*/
private String note2;
/**
* 备用字段3
*/
private String note3;
}

View File

@ -0,0 +1,43 @@
package io.renren.modules.resourceBrowse.excel;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
import lombok.Data;
import java.util.Date;
/**
* 浏览记录
*
* @author dg
* @since 1.0 2022-05-17
*/
@Data
@ContentRowHeight(20)
@HeadRowHeight(20)
@ColumnWidth(25)
public class ResourceBrowseExcel {
@ExcelProperty(value = "主键", index = 0)
private Long id;
@ExcelProperty(value = "用户ID", index = 1)
private Long userId;
@ExcelProperty(value = "能力ID", index = 2)
private Long resourceId;
@ExcelProperty(value = "状态0:正常,", index = 3)
private Integer state;
@ExcelProperty(value = "创建人", index = 4)
private Long creator;
@ExcelProperty(value = "创建时间", index = 5)
private Date createDate;
@ExcelProperty(value = "修改人", index = 6)
private Long updater;
@ExcelProperty(value = "修改时间", index = 7)
private Date updateDate;
@ExcelProperty(value = "备用字段1", index = 8)
private String note1;
@ExcelProperty(value = "备用字段2", index = 9)
private String note2;
@ExcelProperty(value = "备用字段3", index = 10)
private String note3;
}

View File

@ -0,0 +1,15 @@
package io.renren.modules.resourceBrowse.service;
import io.renren.common.service.CrudService;
import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
/**
* 浏览记录
*
* @author dg
* @since 1.0 2022-05-17
*/
public interface ResourceBrowseService extends CrudService<ResourceBrowseEntity, ResourceBrowseDTO> {
}

View File

@ -0,0 +1,36 @@
package io.renren.modules.resourceBrowse.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.constant.Constant;
import io.renren.modules.resourceBrowse.dao.ResourceBrowseDao;
import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
import io.renren.modules.resourceBrowse.service.ResourceBrowseService;
import io.renren.modules.security.user.SecurityUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* 浏览记录
*
* @author dg
* @since 1.0 2022-05-17
*/
@Service
public class ResourceBrowseServiceImpl extends CrudServiceImpl<ResourceBrowseDao, ResourceBrowseEntity, ResourceBrowseDTO> implements ResourceBrowseService {
@Override
public QueryWrapper<ResourceBrowseEntity> getWrapper(Map<String, Object> params){
QueryWrapper<ResourceBrowseEntity> wrapper = new QueryWrapper<>();
wrapper.eq("state", 0)
.eq("user_id", SecurityUser.getUserId())
.orderByDesc("create_date");
return wrapper;
}
}

View File

@ -75,7 +75,6 @@ public class ResourceScoreController {
dto.setUserId(user.getId());
dto.setDelFlag(0);
resourceScoreService.save(dto);
return new Result();
}

View File

@ -376,4 +376,13 @@
GROUP BY
temp2.type
</select>
<select id="selectAlgorithmPage" resultType="io.renren.modules.resource.dto.ResourceDTO">
SELECT *
FROM tb_data_resource
WHERE 1 = 1
ORDER BY ${orderField} ${orderType}
LIMIT ${pageNum}, ${pageSize}
</select>
</mapper>

View File

@ -0,0 +1,20 @@
<?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="io.renren.modules.resourceBrowse.dao.ResourceBrowseDao">
<resultMap type="io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity" id="resourceBrowseMap">
<result property="id" column="id"/>
<result property="userId" column="user_id"/>
<result property="resourceId" column="resource_id"/>
<result property="state" column="state"/>
<result property="creator" column="creator"/>
<result property="createDate" column="create_date"/>
<result property="updater" column="updater"/>
<result property="updateDate" column="update_date"/>
<result property="note1" column="note1"/>
<result property="note2" column="note2"/>
<result property="note3" column="note3"/>
</resultMap>
</mapper>