forked from Gitlink/microservices
parent
c7983bd62c
commit
b73eece682
|
|
@ -156,7 +156,7 @@ public class FrontController extends BaseController {
|
|||
@Log(title = "专区前台项目操作", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/editProject/{projectId}")
|
||||
@ApiOperation(value = "编辑项目聚合")
|
||||
public AjaxResult editProject(@PathVariable("projectId") Long projectId,@RequestBody ZoneProjectFrontUpdateVo zoneProjectFrontUpdateVo) {
|
||||
public AjaxResult editProject(@PathVariable("projectId") Long projectId, @RequestBody ZoneProjectFrontUpdateVo zoneProjectFrontUpdateVo) {
|
||||
return success(zoneProjectService.updateMyZoneProject(projectId, zoneProjectFrontUpdateVo.toZoneProjectUpdateVo()));
|
||||
}
|
||||
|
||||
|
|
@ -253,6 +253,25 @@ public class FrontController extends BaseController {
|
|||
@RequestParam(value = "reason", required = false) String reason) {
|
||||
return toAjax(zoneResourceService.takeUpAiResource(id, reason));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取资源统计
|
||||
*/
|
||||
@RequiresPermissions("zone:front:resource:query")
|
||||
@GetMapping("/resourceStatistics")
|
||||
@ApiOperation("获取资源统计")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "isMine", value = "是否查询我的资源(true-我的资源,false-专区资源)", paramType = "query", dataType = "boolean"),
|
||||
@ApiImplicitParam(name = "zoneId", value = "专区ID", paramType = "query", dataType = "Long", required = true),
|
||||
@ApiImplicitParam(name = "resourceCategory", value = "资源分类(SKILL/MODEL/DATASET),为空则查询所有", paramType = "query", dataType = "String")
|
||||
})
|
||||
public GenericsAjaxResult<UserResourceStatisticsVo> resourceStatistics(
|
||||
@ApiParam(name = "isMine", value = "是否查询我的资源") @RequestParam(value = "isMine", required = false) Boolean isMine,
|
||||
@ApiParam(name = "zoneId") @RequestParam(value = "zoneId") Long zoneId,
|
||||
@ApiParam(name = "resourceCategory") @RequestParam(value = "resourceCategory", required = false) String resourceCategory) {
|
||||
return genericsSuccess(zoneResourceService.getResourceStatistics(zoneId, isMine, resourceCategory));
|
||||
}
|
||||
|
||||
/**
|
||||
* 点赞/取消点赞
|
||||
*/
|
||||
|
|
@ -326,7 +345,7 @@ public class FrontController extends BaseController {
|
|||
|
||||
|
||||
/**
|
||||
* 查询我的资源详情
|
||||
* 查询资源是否点赞
|
||||
*/
|
||||
@RequiresPermissions("zone:front:resource:query")
|
||||
@GetMapping("/{ids}/like")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
package com.microservices.zone.resource.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 用户资源统计信息VO
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("资源统计信息")
|
||||
public class UserResourceStatisticsVo {
|
||||
|
||||
@ApiModelProperty(value = "点赞总数")
|
||||
private Integer likeCount;
|
||||
|
||||
@ApiModelProperty(value = "已发布总数")
|
||||
private Integer publishedCount;
|
||||
|
||||
@ApiModelProperty(value = "待审核总数")
|
||||
private Integer pendingCount;
|
||||
}
|
||||
|
|
@ -188,6 +188,16 @@ public interface IZoneResourceService {
|
|||
*/
|
||||
GenericsTableDataInfo<ZoneResourceDataVo> selectAiDatasetResourceList(ZoneResource zoneResource);
|
||||
|
||||
/**
|
||||
* 查询资源统计信息
|
||||
*
|
||||
* @param zoneId 专区ID(isMine=false时使用)
|
||||
* @param isMine 创建者(isMine=true时使用)
|
||||
* @param resourceCategory 资源分类(SKILL/MODEL/DATASET/null表示所有)
|
||||
* @return 统计信息
|
||||
*/
|
||||
UserResourceStatisticsVo getResourceStatistics(Long zoneId, Boolean isMine, String resourceCategory);
|
||||
|
||||
/**
|
||||
* 下架AI资源
|
||||
*
|
||||
|
|
|
|||
|
|
@ -490,6 +490,63 @@ public class ZoneResourceServiceImpl implements IZoneResourceService {
|
|||
return PageUtils.toPage(list, x -> zoneResourceToData(x, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserResourceStatisticsVo getResourceStatistics(Long zoneId, Boolean isMine, String resourceCategory) {
|
||||
String createBy = null;
|
||||
if (isMine) {
|
||||
createBy = SecurityUtils.getUsername();
|
||||
}
|
||||
UserResourceStatisticsVo statistics = new UserResourceStatisticsVo();
|
||||
|
||||
// 构造查询条件
|
||||
ZoneResource likeQuery = new ZoneResource();
|
||||
likeQuery.setZoneId(zoneId);
|
||||
if (StringUtils.isNotEmpty(createBy)) {
|
||||
likeQuery.setCreateBy(createBy);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(resourceCategory)) {
|
||||
likeQuery.setResourceCategory(resourceCategory);
|
||||
}
|
||||
|
||||
// 查询点赞总数
|
||||
List<ZoneResource> resourceList = zoneResourceMapper.selectZoneResourceList(likeQuery);
|
||||
int totalLikeCount = 0;
|
||||
for (ZoneResource resource : resourceList) {
|
||||
if (resource.getLikeCount() != null) {
|
||||
totalLikeCount += resource.getLikeCount();
|
||||
}
|
||||
}
|
||||
statistics.setLikeCount(totalLikeCount);
|
||||
|
||||
// 统计已发布数量
|
||||
ZoneResource publishedQuery = new ZoneResource();
|
||||
publishedQuery.setZoneId(zoneId);
|
||||
if (StringUtils.isNotEmpty(createBy)) {
|
||||
publishedQuery.setCreateBy(createBy);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(resourceCategory)) {
|
||||
publishedQuery.setResourceCategory(resourceCategory);
|
||||
}
|
||||
publishedQuery.setAuditStatus(ZoneConstants.RESOURCE_AUDIT_PASS);
|
||||
Integer publishedCount = zoneResourceMapper.selectZoneResourceCount(publishedQuery);
|
||||
statistics.setPublishedCount(publishedCount);
|
||||
|
||||
// 统计待审核数量
|
||||
ZoneResource pendingQuery = new ZoneResource();
|
||||
pendingQuery.setZoneId(zoneId);
|
||||
if (StringUtils.isNotEmpty(createBy)) {
|
||||
pendingQuery.setCreateBy(createBy);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(resourceCategory)) {
|
||||
pendingQuery.setResourceCategory(resourceCategory);
|
||||
}
|
||||
pendingQuery.setAuditStatus(ZoneConstants.RESOURCE_NOT_AUDIT);
|
||||
Integer pendingCount = zoneResourceMapper.selectZoneResourceCount(pendingQuery);
|
||||
statistics.setPendingCount(pendingCount);
|
||||
|
||||
return statistics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int takeDownAiResource(Long id, String reason) {
|
||||
ZoneResource resource = getAiResourceById(id);
|
||||
|
|
|
|||
Loading…
Reference in New Issue