forked from Gitlink/microservices
Compare commits
4 Commits
master
...
feat_chiev
| Author | SHA1 | Date |
|---|---|---|
|
|
4b1042c25d | |
|
|
e9c41768e1 | |
|
|
6ef1fafac8 | |
|
|
616bf1229f |
|
|
@ -43,7 +43,6 @@ nbdist/
|
|||
*.log
|
||||
*.xml.versionsBackup
|
||||
*.swp
|
||||
logs
|
||||
|
||||
!*/build/*.java
|
||||
!*/build/*.html
|
||||
|
|
|
|||
36
README.md
36
README.md
|
|
@ -1,36 +0,0 @@
|
|||
## 系统模块
|
||||
|
||||
~~~
|
||||
com.microservices
|
||||
├── microservices-ui // 前端框架
|
||||
├── microservices-gateway // 网关模块
|
||||
├── microservices-auth // 认证中心
|
||||
├── microservices-api // 接口模块
|
||||
│ └── microservices-api-system // 系统接口
|
||||
├── microservices-common // 通用模块
|
||||
│ └── microservices-common-async // 异步线程池配置
|
||||
│ └── microservices-common-core // 核心模块
|
||||
│ └── microservices-common-datascope // 权限范围
|
||||
│ └── microservices-common-datasource // 多数据源
|
||||
│ └── microservices-common-httpClient // http调用
|
||||
│ └── microservices-common-log // 日志记录
|
||||
│ └── microservices-common-redis // 缓存服务
|
||||
│ └── microservices-common-seata // seata分布式事务
|
||||
│ └── microservices-common-security // 安全模块
|
||||
│ └── microservices-common-swagger // 系统接口
|
||||
├── microservices-modules // 业务模块
|
||||
│ └── microservices-cms // 内容管理模块
|
||||
│ └── microservices-dms // 数据管理体系模块
|
||||
│ └── microservices-dss // 数据统计系统模块
|
||||
│ └── microservices-file // 文件服务
|
||||
│ └── microservices-gen // 代码生成
|
||||
│ └── microservices-job // 定时任务
|
||||
│ └── microservices-pms // 项目管理系统模块
|
||||
│ └── microservices-system // 系统模块
|
||||
│ └── microservices-wiki // Wiki模块
|
||||
│ └── microservices-zone // 特色专区系统模块
|
||||
├── microservices-visual // 图形化管理模块
|
||||
│ └── microservices-visual-monitor // 监控中心
|
||||
├──pom.xml // 公共依赖
|
||||
~~~
|
||||
|
||||
|
|
@ -9,8 +9,6 @@ import com.microservices.system.api.factory.RemoteCmsFallbackFactory;
|
|||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户服务
|
||||
*
|
||||
|
|
@ -160,22 +158,4 @@ public interface RemoteCmsService {
|
|||
@GetMapping("/doc/getJSONObject/{cmsDocId}")
|
||||
R<JSONObject> selectCmsDocJSONObjectById(@PathVariable(value = "cmsDocId") Long cmsDocId
|
||||
, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
@PutMapping("/project/changeOrgRole/user/{userId}/operate/{operate}")
|
||||
R<Boolean> changeUserOrgRole(@PathVariable("userId") Long userId, @PathVariable("operate") int operate
|
||||
, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 首页文章合并列表(接收置顶文章 docId 有序列表,返回合并去重后的结果)
|
||||
* 供 Zone 服务 /open/getTopDoc 改造后调用
|
||||
*
|
||||
* @param zoneId 专区ID
|
||||
* @param topDocIds 置顶文章 docId 有序列表
|
||||
* @param source 来源
|
||||
* @return 合并后的首页文章 JSONObject 列表
|
||||
*/
|
||||
@PostMapping("/doc/homePageDocMergeList/{zoneId}")
|
||||
R<List<JSONObject>> selectHomePageDocMergeList(@PathVariable("zoneId") Long zoneId,
|
||||
@RequestBody List<Long> topDocIds,
|
||||
@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public interface RemoteDeptService {
|
|||
* 根据组织id删除部门
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @param source 请求来源
|
||||
* @param source 请求来源
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
@DeleteMapping("/dept/deleteDeptByDeptId")
|
||||
|
|
@ -105,7 +105,7 @@ public interface RemoteDeptService {
|
|||
* 通过用户名查询用户下组织及组织对应角色列表
|
||||
*
|
||||
* @param deptId 组织ID
|
||||
* @param source 请求来源
|
||||
* @param source 请求来源
|
||||
* @return 用户下组织及组织对应角色列表
|
||||
*/
|
||||
@GetMapping("/SysUserDeptRole/userByDeptId/{deptId}/list")
|
||||
|
|
@ -115,7 +115,7 @@ public interface RemoteDeptService {
|
|||
/**
|
||||
* 查询组织编号下拥有传入角色权限字符串的用户名
|
||||
*
|
||||
* @param deptId 组织编号
|
||||
* @param deptId 组织编号
|
||||
* @param roleKeys 角色权限字符串
|
||||
* @return 组织下拥有传入角色权限字符串的用户名列表
|
||||
*/
|
||||
|
|
@ -126,7 +126,7 @@ public interface RemoteDeptService {
|
|||
* 检查用户是否在指定部门下具有指定角色
|
||||
*
|
||||
* @param currentDeptId 组织编号
|
||||
* @param roleKey 角色权限字符串
|
||||
* @param roleKey 角色权限字符串
|
||||
* @return 组织下拥有传入角色权限字符串的用户名列表
|
||||
*/
|
||||
@GetMapping("/SysUserDeptRole/checkUserInDeptHasRole")
|
||||
|
|
@ -143,17 +143,6 @@ public interface RemoteDeptService {
|
|||
@GetMapping("/SysUserDeptRole/checkUserInDeptHasPerms")
|
||||
R<Boolean> checkUserInDeptHasPerms(@RequestParam("currentDeptId") Long currentDeptId, @RequestParam("userId") Long userId, @RequestParam("perms") String perms, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 检查用户是否在指定部门或指定部门的父级部门下具有指定菜单权限
|
||||
*
|
||||
* @param deptId 指定组织id
|
||||
* @param userId 用户id
|
||||
* @param perms 菜单权限
|
||||
* @return 用户是否在指定部门下具有菜单权限 是true 否false
|
||||
*/
|
||||
@GetMapping("/SysUserDeptRole/checkUserInDeptOrParentDeptHasPerms")
|
||||
R<Boolean> checkUserInDeptOrParentDeptHasPerms(@RequestParam("deptId") Long deptId, @RequestParam("userId") Long userId, @RequestParam("perms") String perms, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 检查用户是否在指定部门下
|
||||
*
|
||||
|
|
@ -163,7 +152,4 @@ public interface RemoteDeptService {
|
|||
*/
|
||||
@GetMapping("/SysUserDeptRole/checkUserInDept")
|
||||
R<Boolean> checkUserInDept(@RequestParam("currentDeptId") Long currentDeptId, @RequestParam("userId") Long userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
@GetMapping("/SysUserDeptRole/getSysUserDeptRoleByDeptIdAndUserId")
|
||||
R<SysUserDeptRole> getSysUserDeptRoleByDeptIdAndUserId(@RequestParam("deptId") Long deptId, @RequestParam("userId") Long userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ import com.microservices.system.api.domain.SysLogininfor;
|
|||
import com.microservices.system.api.domain.SysOperLog;
|
||||
import com.microservices.system.api.factory.RemoteLogFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
|
||||
/**
|
||||
* 日志服务
|
||||
|
|
@ -38,20 +38,4 @@ public interface RemoteLogService
|
|||
*/
|
||||
@PostMapping("/logininfor")
|
||||
public R<Boolean> saveLogininfor(@RequestBody SysLogininfor sysLogininfor, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 获取操作日志列表
|
||||
*
|
||||
* @param title 日志标题
|
||||
* @param operUrl 操作地址
|
||||
* @param status 操作状态
|
||||
* @param topN 获取最新N条
|
||||
* @return 操作日志列表
|
||||
*/
|
||||
@GetMapping("/operlog/latest")
|
||||
R<List<SysOperLog>> getLatestOperLogList(@RequestParam(value = "title", required = false) String title,
|
||||
@RequestParam(value = "operUrl", required = false) String operUrl,
|
||||
@RequestParam(value = "status", required = false) Integer status,
|
||||
@RequestParam(value = "topN") Integer topN,
|
||||
@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,15 +57,6 @@ public interface RemoteUserService {
|
|||
@GetMapping("/user/getSysUserByUserId/{userId}")
|
||||
public R<SysUser> getSysUserByUserId(@PathVariable("userId") Long userId, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 通过用户ID数组批量获取用户信息(POST方法,解决URL长度限制)
|
||||
*
|
||||
* @param userIds 用户ID数组
|
||||
* @param source 请求来源
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/user/getSysUserListByUserIds")
|
||||
R<List<SysUser>> postSysUserListByUserIds(@RequestBody Long[] userIds, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
/**
|
||||
* 组织下新增用户身份
|
||||
|
|
@ -73,7 +64,7 @@ public interface RemoteUserService {
|
|||
* @param deptId
|
||||
* @param userId
|
||||
* @param roleKey
|
||||
* @param source 请求来源
|
||||
* @param source 请求来源
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/SysUserDeptRole/dept/{deptId}/user/{userId}/role/{roleKey}")
|
||||
|
|
@ -83,13 +74,14 @@ public interface RemoteUserService {
|
|||
, @PathVariable("roleKey") String roleKey
|
||||
, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
|
||||
/**
|
||||
* 组织下删除用户身份
|
||||
*
|
||||
* @param deptId
|
||||
* @param userId
|
||||
* @param roleKey
|
||||
* @param source 请求来源
|
||||
* @param source 请求来源
|
||||
* @return 结果
|
||||
*/
|
||||
@DeleteMapping("/SysUserDeptRole/dept/{deptId}/user/{userId}/role/{roleKey}")
|
||||
|
|
@ -99,16 +91,18 @@ public interface RemoteUserService {
|
|||
@PathVariable("roleKey") String roleKey,
|
||||
@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*
|
||||
* @param sysUser 用户信息
|
||||
* @param source 请求来源
|
||||
* @param source 请求来源
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/user/register")
|
||||
public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
|
||||
/**
|
||||
* 通过GitLinkToken获取本系统Token
|
||||
*
|
||||
|
|
@ -129,6 +123,7 @@ public interface RemoteUserService {
|
|||
@GetMapping("/SysUserDeptRole/userByUserName/{userName}/list")
|
||||
public R<List<SysUserDeptRole>> getSysUserDeptRoleListByUserName(@PathVariable("userName") String userName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户下第一个身份
|
||||
*
|
||||
|
|
@ -200,7 +195,7 @@ public interface RemoteUserService {
|
|||
/**
|
||||
* 通过GitLink用户Id创建用户
|
||||
*
|
||||
* @param gitLinkUserId GitLinkUserId
|
||||
* @param gitLinkUserId GitLink用户Id
|
||||
* @param source 请求来源
|
||||
* @return 系统用户
|
||||
*/
|
||||
|
|
@ -211,7 +206,7 @@ public interface RemoteUserService {
|
|||
* 根据角色Key获取菜单权限集合
|
||||
*
|
||||
* @param roleKey 角色Key
|
||||
* @param source 请求来源
|
||||
* @param source 请求来源
|
||||
* @return 菜单权限集合
|
||||
*/
|
||||
@GetMapping("/menu/roleMenuPermissionByRoleKey/{roleKey}")
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 内容管理服务降级处理
|
||||
*
|
||||
|
|
@ -85,16 +83,6 @@ public class RemoteCmsFallbackFactory implements FallbackFactory<RemoteCmsServic
|
|||
public R<JSONObject> selectCmsDocJSONObjectById(Long cmsDocId, String source) {
|
||||
return R.fail("获取文章JSON对象失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Boolean> changeUserOrgRole(Long userId, int operate, String source) {
|
||||
return R.fail("更新组织权限失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<JSONObject>> selectHomePageDocMergeList(Long zoneId, List<Long> topDocIds, String source) {
|
||||
return R.fail("获取首页文章合并列表失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,20 +83,10 @@ public class RemoteDeptFallbackFactory implements FallbackFactory<RemoteDeptServ
|
|||
return R.fail("检查用户是否在指定部门下具有指定菜单权限失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Boolean> checkUserInDeptOrParentDeptHasPerms(Long deptId, Long userId, String perms, String source) {
|
||||
return R.fail("检查用户是否在指定部门或指定部门的父级部门下具有指定菜单权限失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Boolean> checkUserInDept(Long currentDeptId, Long userId, String source) {
|
||||
return R.fail("检查用户是否在指定部门下失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<SysUserDeptRole> getSysUserDeptRoleByDeptIdAndUserId(Long deptId, Long userId, String source) {
|
||||
return R.fail("获取用户在指定部门下的角色失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 日志服务降级处理
|
||||
*
|
||||
|
|
@ -38,12 +36,6 @@ public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogServic
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<SysOperLog>> getLatestOperLogList(String title, String operUrl, Integer status, Integer topN, String source)
|
||||
{
|
||||
return R.fail("获取最新操作日志失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,12 +52,6 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
return R.fail("获取用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<List<SysUser>> postSysUserListByUserIds(Long[] userIds, String source) {
|
||||
|
||||
return R.fail("批量获取用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<Boolean> addUserIdentify(Long deptId, Long userId, String roleKey, String source) {
|
||||
return R.fail("组织下新增用户身份失败:" + throwable.getMessage());
|
||||
|
|
|
|||
|
|
@ -80,10 +80,6 @@ public class CacheConstants {
|
|||
* 通过组织Id获取专区详情JSON对象
|
||||
*/
|
||||
public final static String ZONE_JSON_OF_DEPT_ID_KEY = "zoneJSONOfDeptId:";
|
||||
/**
|
||||
* 积分发放部门
|
||||
*/
|
||||
public final static String ZONE_POINTS_DEPT_ID_KEY = "zonePointsDeptId";
|
||||
/**
|
||||
* 内容管理同步缓存前缀
|
||||
*/
|
||||
|
|
@ -249,18 +245,6 @@ public class CacheConstants {
|
|||
return ZONE_PROJECT_SORT_BY_SCORE + "*:" + zoneId + ":*";
|
||||
}
|
||||
|
||||
/**
|
||||
* 专区统计数据缓存前缀
|
||||
*/
|
||||
private final static String ZONE_STATISTICS_KEY = "zone:statistics:";
|
||||
|
||||
/**
|
||||
* 获取专区统计数据缓存key
|
||||
*/
|
||||
public static String getZoneStatisticsKey(Long zoneId) {
|
||||
return ZONE_STATISTICS_KEY + zoneId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件打包是否完成(0:代表未完成;1:代表已完成;-1:代表打包失败,需要重新打包)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ package com.microservices.common.core.constant;
|
|||
*
|
||||
* @author microservices
|
||||
*/
|
||||
public class UserConstants {
|
||||
public class UserConstants
|
||||
{
|
||||
/**
|
||||
* 平台内系统用户的唯一标志
|
||||
*/
|
||||
|
|
@ -27,89 +28,55 @@ public class UserConstants {
|
|||
*/
|
||||
public static final String DEL_FLAG_FALSE = "0";
|
||||
|
||||
/**
|
||||
* 正常状态
|
||||
*/
|
||||
/** 正常状态 */
|
||||
public static final String NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 异常状态
|
||||
*/
|
||||
/** 异常状态 */
|
||||
public static final String EXCEPTION = "1";
|
||||
|
||||
/**
|
||||
* 用户封禁状态
|
||||
*/
|
||||
/** 用户封禁状态 */
|
||||
public static final String USER_DISABLE = "1";
|
||||
|
||||
/**
|
||||
* 角色封禁状态
|
||||
*/
|
||||
/** 角色封禁状态 */
|
||||
public static final String ROLE_DISABLE = "1";
|
||||
|
||||
/**
|
||||
* 部门正常状态
|
||||
*/
|
||||
/** 部门正常状态 */
|
||||
public static final String DEPT_NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 部门停用状态
|
||||
*/
|
||||
/** 部门停用状态 */
|
||||
public static final String DEPT_DISABLE = "1";
|
||||
|
||||
/**
|
||||
* 字典正常状态
|
||||
*/
|
||||
/** 字典正常状态 */
|
||||
public static final String DICT_NORMAL = "0";
|
||||
|
||||
/**
|
||||
* 是否为系统默认(是)
|
||||
*/
|
||||
/** 是否为系统默认(是) */
|
||||
public static final String YES = "Y";
|
||||
|
||||
/**
|
||||
* 是否菜单外链(是)
|
||||
*/
|
||||
/** 是否菜单外链(是) */
|
||||
public static final String YES_FRAME = "0";
|
||||
|
||||
/**
|
||||
* 是否菜单外链(否)
|
||||
*/
|
||||
/** 是否菜单外链(否) */
|
||||
public static final String NO_FRAME = "1";
|
||||
|
||||
/**
|
||||
* 菜单类型(目录)
|
||||
*/
|
||||
/** 菜单类型(目录) */
|
||||
public static final String TYPE_DIR = "M";
|
||||
|
||||
/**
|
||||
* 菜单类型(菜单)
|
||||
*/
|
||||
/** 菜单类型(菜单) */
|
||||
public static final String TYPE_MENU = "C";
|
||||
|
||||
/**
|
||||
* 菜单类型(按钮)
|
||||
*/
|
||||
/** 菜单类型(按钮) */
|
||||
public static final String TYPE_BUTTON = "F";
|
||||
|
||||
/**
|
||||
* Layout组件标识
|
||||
*/
|
||||
/** Layout组件标识 */
|
||||
public final static String LAYOUT = "Layout";
|
||||
|
||||
/**
|
||||
* ParentView组件标识
|
||||
*/
|
||||
/** ParentView组件标识 */
|
||||
public final static String PARENT_VIEW = "ParentView";
|
||||
|
||||
/**
|
||||
* InnerLink组件标识
|
||||
*/
|
||||
/** InnerLink组件标识 */
|
||||
public final static String INNER_LINK = "InnerLink";
|
||||
|
||||
/**
|
||||
* 校验是否唯一的返回标识
|
||||
*/
|
||||
/** 校验是否唯一的返回标识 */
|
||||
public final static boolean UNIQUE = true;
|
||||
public final static boolean NOT_UNIQUE = false;
|
||||
|
||||
|
|
@ -155,28 +122,4 @@ public class UserConstants {
|
|||
* 项目管理-知识库管理权限
|
||||
*/
|
||||
public static final String PMS_PERMS_DOCS_MANAGE = "pms:docs:manage";
|
||||
/**
|
||||
* 文章管理-文章删除权限
|
||||
*/
|
||||
public static final String CMS_PERMS_DOCS_DELETE = "cms:doc:remove";
|
||||
/**
|
||||
* 文章管理-新增文章权限
|
||||
*/
|
||||
public static final String CMS_PERMS_DOCS_ADD = "cms:doc:add";
|
||||
/**
|
||||
* 文章管理-编辑文章权限
|
||||
*/
|
||||
public static final String CMS_PERMS_DOCS_EDIT = "cms:doc:edit";
|
||||
/**
|
||||
* 文章管理-审核文章权限
|
||||
*/
|
||||
public static final String CMS_PERMS_DOCS_AUDIT = "cms:doc:audit";
|
||||
/**
|
||||
* 专区管理-审核项目权限
|
||||
*/
|
||||
public static final String ZONE_PERMS_PROJECT_AUDIT = "zone:project:audit";
|
||||
/**
|
||||
* 专区管理-审核资源权限
|
||||
*/
|
||||
public static final String ZONE_PERMS_RESOURCE_AUDIT = "zone:resource:audit";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ package com.microservices.common.core.enums;
|
|||
public enum DocAndZoneOperation
|
||||
{
|
||||
OPERATION_CREATE("创建", "create"), OPERATION_UPDATE("更新", "update"),
|
||||
OPERATION_DELETE("删除", "delete"), OPERATION_NON_REPO_UPDATE("非仓库更新", "nonRepoUpdate");
|
||||
OPERATION_DELETE("删除", "delete");
|
||||
|
||||
private final String operationName;
|
||||
private final String operationCode;
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
public static String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
|
||||
|
||||
private static String[] parsePatterns = {
|
||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||
|
|
@ -267,9 +265,4 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||
cal.add(Calendar.DATE, -7 * times);
|
||||
return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, cal.getTime());
|
||||
}
|
||||
|
||||
public static long dateTimeToUnix(Date date) {
|
||||
// date.getTime() 返回当前 Date 对象表示的毫秒数,除以 1000 后得到以秒为单位的时间戳,即 10 位时间戳
|
||||
return date.getTime() / 1000;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,17 +211,6 @@ public class HttpAPIService {
|
|||
return doRequest(httpDelete, headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* 不带Header的get请求
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public JSONObject doGet(String url) throws Exception {
|
||||
return doGet(url, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 带Header的get请求
|
||||
*
|
||||
|
|
|
|||
|
|
@ -115,7 +115,8 @@ public class AuthLogic {
|
|||
* @param permission 权限字符串
|
||||
* @return 用户是否具备某权限
|
||||
*/
|
||||
public boolean hasPermi(String permission) {
|
||||
public boolean hasPermi(String permission)
|
||||
{
|
||||
return hasPermi(tokenService.getMenuPermissions(), permission);
|
||||
}
|
||||
|
||||
|
|
@ -125,8 +126,10 @@ public class AuthLogic {
|
|||
* @param permission 权限字符串
|
||||
* @return 用户是否具备某权限
|
||||
*/
|
||||
public void checkPermi(String permission) {
|
||||
if (!hasPermi(tokenService.getMenuPermissions(), permission)) {
|
||||
public void checkPermi(String permission)
|
||||
{
|
||||
if (!hasPermi(tokenService.getMenuPermissions(), permission))
|
||||
{
|
||||
throw new NotPermissionException(permission);
|
||||
}
|
||||
}
|
||||
|
|
@ -150,10 +153,13 @@ public class AuthLogic {
|
|||
*
|
||||
* @param permissions 权限列表
|
||||
*/
|
||||
public void checkPermiAnd(String... permissions) {
|
||||
public void checkPermiAnd(String... permissions)
|
||||
{
|
||||
Set<String> permissionList = tokenService.getMenuPermissions();
|
||||
for (String permission : permissions) {
|
||||
if (!hasPermi(permissionList, permission)) {
|
||||
for (String permission : permissions)
|
||||
{
|
||||
if (!hasPermi(permissionList, permission))
|
||||
{
|
||||
throw new NotPermissionException(permission);
|
||||
}
|
||||
}
|
||||
|
|
@ -164,10 +170,13 @@ public class AuthLogic {
|
|||
*
|
||||
* @param permissions 权限码数组
|
||||
*/
|
||||
public void checkPermiOr(String... permissions) {
|
||||
public void checkPermiOr(String... permissions)
|
||||
{
|
||||
Set<String> permissionList = tokenService.getMenuPermissions();
|
||||
for (String permission : permissions) {
|
||||
if (hasPermi(permissionList, permission)) {
|
||||
for (String permission : permissions)
|
||||
{
|
||||
if (hasPermi(permissionList, permission))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -182,7 +191,8 @@ public class AuthLogic {
|
|||
* @param role 角色标识
|
||||
* @return 用户是否具备某角色
|
||||
*/
|
||||
public boolean hasRole(String role) {
|
||||
public boolean hasRole(String role)
|
||||
{
|
||||
return hasRole(tokenService.getRolePermissions(), role);
|
||||
}
|
||||
|
||||
|
|
@ -215,10 +225,13 @@ public class AuthLogic {
|
|||
*
|
||||
* @param roles 角色标识数组
|
||||
*/
|
||||
public void checkRoleAnd(String... roles) {
|
||||
public void checkRoleAnd(String... roles)
|
||||
{
|
||||
Set<String> roleList = tokenService.getRolePermissions();
|
||||
for (String role : roles) {
|
||||
if (!hasRole(roleList, role)) {
|
||||
for (String role : roles)
|
||||
{
|
||||
if (!hasRole(roleList, role))
|
||||
{
|
||||
throw new NotRoleException(role);
|
||||
}
|
||||
}
|
||||
|
|
@ -229,14 +242,18 @@ public class AuthLogic {
|
|||
*
|
||||
* @param roles 角色标识数组
|
||||
*/
|
||||
public void checkRoleOr(String... roles) {
|
||||
public void checkRoleOr(String... roles)
|
||||
{
|
||||
Set<String> roleList = tokenService.getRolePermissions();
|
||||
for (String role : roles) {
|
||||
if (hasRole(roleList, role)) {
|
||||
for (String role : roles)
|
||||
{
|
||||
if (hasRole(roleList, role))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (roles.length > 0) {
|
||||
if (roles.length > 0)
|
||||
{
|
||||
throw new NotRoleException(roles);
|
||||
}
|
||||
}
|
||||
|
|
@ -306,9 +323,6 @@ public class AuthLogic {
|
|||
public boolean hasUserIdentity(Long deptId, String roleKey) {
|
||||
LoginUser loginUser = getLoginUser();
|
||||
List<SysUserDeptRole> sysUserDeptRoleList = tokenService.getAllUserIdentity(loginUser.getUsername());
|
||||
if (sysUserDeptRoleList == null) {
|
||||
return false;
|
||||
}
|
||||
return sysUserDeptRoleList.stream()
|
||||
.anyMatch(x -> {
|
||||
if (x.getDeptId() != null && x.getSysRole() != null && x.getDeptId().equals(deptId)) {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import com.microservices.common.core.utils.uuid.IdUtils;
|
|||
import com.microservices.common.redis.service.RedisService;
|
||||
import com.microservices.common.security.interceptor.HeaderInterceptor;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.system.api.RemoteDeptService;
|
||||
import com.microservices.system.api.RemoteUserService;
|
||||
import com.microservices.system.api.domain.SysRole;
|
||||
import com.microservices.system.api.domain.SysUser;
|
||||
|
|
@ -39,8 +38,6 @@ public class TokenService {
|
|||
private RedisService redisService;
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
@Autowired
|
||||
private RemoteDeptService remoteDeptService;
|
||||
|
||||
protected static final long MILLIS_SECOND = 1000;
|
||||
|
||||
|
|
@ -332,16 +329,4 @@ public class TokenService {
|
|||
}
|
||||
return loginUser.getSysUser();
|
||||
}
|
||||
|
||||
public Boolean hasDeptPerms(Long deptId, String perms) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
Boolean hasPerms = FeignUtils.getReturnData(
|
||||
remoteDeptService.checkUserInDeptOrParentDeptHasPerms(deptId, loginUser.getUserId(), perms, SecurityConstants.INNER)
|
||||
);
|
||||
|
||||
if (hasPerms == null) {
|
||||
hasPerms = false;
|
||||
}
|
||||
return hasPerms;
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@ package com.microservices.cms.doc.controller;
|
|||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.cms.doc.domain.*;
|
||||
import com.microservices.cms.doc.service.ICmsDocService;
|
||||
import com.microservices.common.core.constant.UserConstants;
|
||||
import com.microservices.common.core.domain.R;
|
||||
import com.microservices.common.core.web.controller.BaseController;
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
|
|
@ -18,7 +17,6 @@ import io.swagger.annotations.*;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
@ -108,13 +106,23 @@ public class CmsDocController extends BaseController {
|
|||
@ApiImplicitParam(name = "pageNum", value = "当前记录起始索引", paramType = "query", dataType = "Integer"),
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页显示记录数", paramType = "query", dataType = "Integer"),
|
||||
})
|
||||
public GenericsTableDataInfo<CmsDocAllDto> docListByZone(
|
||||
public TableDataInfo docListByZone(
|
||||
@ApiParam(name = "zoneId", value = "专区Id") @PathVariable("zoneId") Long zoneId
|
||||
, CmsDocSearchVo cmsDocSearchVo) {
|
||||
Long deptId = cmsDocService.getDeptIdByZoneId(zoneId);
|
||||
cmsDocSearchVo.setIsOpen(true);
|
||||
cmsDocSearchVo.setIsOpen(false);
|
||||
startPage();
|
||||
return cmsDocService.selectAllDocList(deptId, cmsDocSearchVo);
|
||||
List<CmsDocAllDto> list = cmsDocService.selectCmsDocListByDept(deptId, cmsDocSearchVo);
|
||||
list.forEach(x -> {
|
||||
String docDetailUrl = cmsDocService.getDocDetailUrl(x.getDeptId(), x.getId());
|
||||
x.setDocDetailUrl(docDetailUrl);
|
||||
|
||||
Boolean editable = cmsDocService.isCmsDocEditable(x);
|
||||
x.setEditable(editable);
|
||||
|
||||
});
|
||||
int count = cmsDocService.selectCmsDocCountByDept(deptId, cmsDocSearchVo);
|
||||
return getDataTable(list, count);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -156,7 +164,7 @@ public class CmsDocController extends BaseController {
|
|||
/**
|
||||
* 新增文章信息
|
||||
*/
|
||||
@RequiresPermissions(UserConstants.CMS_PERMS_DOCS_ADD)
|
||||
@RequiresPermissions("cms:doc:add")
|
||||
@Log(title = "文章信息", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/dir/{dirId}")
|
||||
@ApiOperation("在栏目下创建文章")
|
||||
|
|
@ -193,7 +201,7 @@ public class CmsDocController extends BaseController {
|
|||
/**
|
||||
* 删除文章
|
||||
*/
|
||||
@RequiresPermissions(UserConstants.CMS_PERMS_DOCS_DELETE)
|
||||
@RequiresPermissions("cms:doc:remove")
|
||||
@Log(title = "文章信息", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiOperation("删除文章/栏目")
|
||||
|
|
@ -204,13 +212,13 @@ public class CmsDocController extends BaseController {
|
|||
/**
|
||||
* 修改文章信息
|
||||
*/
|
||||
@RequiresPermissions(UserConstants.CMS_PERMS_DOCS_EDIT)
|
||||
@RequiresPermissions("cms:doc:edit")
|
||||
@Log(title = "文章信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation("更新文章")
|
||||
public AjaxResult edit(@ApiParam(name = "id", value = "文章Id") @PathVariable Long id,
|
||||
@ApiParam(name = "cmsDoc", value = "文章实体对象") @RequestBody CmsDocDto cmsDocDto) {
|
||||
return success(cmsDocService.updateCmsDoc(id, cmsDocDto));
|
||||
return toAjax(cmsDocService.updateCmsDoc(id, cmsDocDto));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -223,18 +231,18 @@ public class CmsDocController extends BaseController {
|
|||
public AjaxResult editCmsDIr(@ApiParam(name = "id", value = "栏目Id") @PathVariable Long id,
|
||||
@ApiParam(name = "cmsDirUpdateVo", value = "栏目更新对象") @RequestBody CmsDirUpdateVo cmsDirUpdateVo) {
|
||||
cmsDocService.updateCmsDir(id, cmsDirUpdateVo);
|
||||
return success("栏目信息更新成功");
|
||||
return success("异步更新栏目信息");
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核文章信息
|
||||
*/
|
||||
@RequiresPermissions(UserConstants.CMS_PERMS_DOCS_AUDIT)
|
||||
@RequiresPermissions("cms:doc:audit")
|
||||
@Log(title = "文章信息", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/{id}/audit")
|
||||
@ApiOperation("审核文章")
|
||||
public AjaxResult audit(@ApiParam(name = "id", value = "文章Id") @PathVariable Long id,
|
||||
@ApiParam(name = "cmsDocAuditVo", value = "文章审核对象") @RequestBody CmsDocAuditVo cmsDocAuditVo) {
|
||||
@ApiParam(name = "cmsDocAuditVo", value = "文章审核对象") @RequestBody CmsDocAuditVo cmsDocAuditVo) {
|
||||
return toAjax(cmsDocService.auditCmsDoc(id, cmsDocAuditVo));
|
||||
}
|
||||
|
||||
|
|
@ -307,24 +315,6 @@ public class CmsDocController extends BaseController {
|
|||
return R.ok(cmsDocJSONObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 内部接口:首页文章合并列表(接收置顶文章 docId 有序列表,返回合并去重后的结果)
|
||||
* 供 Zone 服务 Feign 调用,用于 /open/getTopDoc 改造
|
||||
*/
|
||||
@InnerAuth
|
||||
@PostMapping("/homePageDocMergeList/{zoneId}")
|
||||
@ApiOperation(value = "首页文章合并列表", hidden = true)
|
||||
public R<List<JSONObject>> selectHomePageDocMergeList(
|
||||
@PathVariable("zoneId") Long zoneId,
|
||||
@RequestBody List<Long> topDocIds) {
|
||||
List<CmsDocBaseDto> list = cmsDocService.selectHomePageDocMergeList(zoneId, topDocIds);
|
||||
List<JSONObject> result = new ArrayList<>();
|
||||
for (CmsDocBaseDto dto : list) {
|
||||
result.add(JSONObject.from(dto));
|
||||
}
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过组织Id获取专区下文章阅读数量
|
||||
*
|
||||
|
|
|
|||
|
|
@ -5,17 +5,12 @@ import com.microservices.cms.doc.domain.*;
|
|||
import com.microservices.cms.doc.service.ICmsDocCommentService;
|
||||
import com.microservices.cms.doc.service.ICmsDocService;
|
||||
import com.microservices.cms.doc.service.ICmsWechatService;
|
||||
import com.microservices.cms.search.dto.DocSearchResult;
|
||||
import com.microservices.common.core.web.controller.BaseController;
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
import com.microservices.common.core.web.domain.GenericsAjaxResult;
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import com.microservices.common.core.web.page.TableDataInfo;
|
||||
import com.microservices.common.log.annotation.Log;
|
||||
import com.microservices.common.log.enums.BusinessType;
|
||||
import com.microservices.cms.search.dto.DocSearchRequest;
|
||||
import com.microservices.cms.search.dto.DocSearchResponse;
|
||||
import com.microservices.cms.search.service.IGlobalSearchService;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -40,22 +35,6 @@ public class OpenController extends BaseController {
|
|||
@Autowired
|
||||
private ICmsWechatService cmsWechatService;
|
||||
|
||||
@Autowired
|
||||
private IGlobalSearchService globalSearchService;
|
||||
|
||||
/**
|
||||
* 文章搜索接口
|
||||
*
|
||||
* @return 搜索结果
|
||||
*/
|
||||
@ApiOperation("文章搜索")
|
||||
@PostMapping("/search")
|
||||
public GenericsTableDataInfo<DocSearchResult> docSearch(@RequestBody DocSearchRequest docSearchRequest) {
|
||||
logger.info("文章搜索请求: keyword={}", docSearchRequest.getKeyword());
|
||||
DocSearchResponse response = globalSearchService.docSearch(docSearchRequest);
|
||||
return new GenericsTableDataInfo<>(response.getResults(), response.getTotal());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询栏目列表
|
||||
*/
|
||||
|
|
@ -89,7 +68,7 @@ public class OpenController extends BaseController {
|
|||
public GenericsTableDataInfo<CmsDocBaseDto> docList(@ApiParam(name = "dirId", value = "栏目Id") @PathVariable("dirId") Long dirId
|
||||
, CmsDocSearchVo cmsDocSearchVo) {
|
||||
cmsDocSearchVo.setIsOpen(true);
|
||||
List<CmsDocBaseDto> list = cmsDocService.selectSetDefaultHeadImgCmsDocList(dirId, cmsDocSearchVo);
|
||||
List<CmsDocBaseDto> list = cmsDocService.selectCmsDocList(dirId, cmsDocSearchVo);
|
||||
return getAllGenericsDataTableToPage(list);
|
||||
}
|
||||
|
||||
|
|
@ -121,19 +100,6 @@ public class OpenController extends BaseController {
|
|||
return getAllGenericsDataTableToPage(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文章列表(不区分栏目)
|
||||
*/
|
||||
@GetMapping("/zone/{zoneId}/allDocList")
|
||||
@ApiOperation("查询文章列表(不区分栏目)")
|
||||
public GenericsTableDataInfo<CmsDocAllDto> allDocList(@ApiParam(name = "zoneId", value = "专区Id") @PathVariable("zoneId") Long zoneId,
|
||||
CmsDocSearchVo cmsDocSearchVo) {
|
||||
Long deptId = cmsDocService.getDeptIdByZoneId(zoneId);
|
||||
cmsDocSearchVo.setIsOpen(true);
|
||||
startPage();
|
||||
return cmsDocService.selectAllDocList(deptId, cmsDocSearchVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询首页文章列表
|
||||
*/
|
||||
|
|
@ -209,9 +175,9 @@ public class OpenController extends BaseController {
|
|||
@Log(title = "同步文章数据", businessType = BusinessType.UPDATE)
|
||||
public AjaxResult syncDocData(
|
||||
@ApiParam(name = "deptId", value = "组织Id", required = true) @PathVariable("deptId") Long deptId
|
||||
, @RequestBody() String bodyStr
|
||||
,@RequestBody() String bodyStr
|
||||
, HttpServletRequest request) {
|
||||
cmsDocService.syncDocData(deptId, bodyStr);
|
||||
cmsDocService.syncDocData(deptId,bodyStr);
|
||||
return AjaxResult.success("同步消息发送成功");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,9 +41,6 @@ public class CmsDir implements Comparable<CmsDir> {
|
|||
@ApiModelProperty(value = "排序", hidden = true)
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty(value = "文章头图")
|
||||
private String headImg;
|
||||
|
||||
public String getName() {
|
||||
if (name != null) {
|
||||
name = name.replaceAll(CmsConstants.DIR_SEPARATOR,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ public class CmsDirUpdateVo {
|
|||
@ApiModelProperty(value = "顺序")
|
||||
private Integer order;
|
||||
|
||||
@ApiModelProperty(value = "文章头图")
|
||||
private String headImg;
|
||||
public CmsDir toCmsDir() {
|
||||
CmsDir cmsDir = new CmsDir();
|
||||
cmsDir.setName(name);
|
||||
return cmsDir;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.microservices.cms.doc.domain;
|
|||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.microservices.cms.utils.CmsConstants;
|
||||
import com.microservices.common.core.annotation.Excel;
|
||||
import com.microservices.common.core.utils.bean.BeanUtils;
|
||||
import com.microservices.common.core.web.domain.BaseSortEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
@ -37,27 +36,19 @@ public class CmsDoc extends BaseSortEntity {
|
|||
@Excel(name = "文件名称")
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
/** 文件路径 */
|
||||
@Excel(name = "文件路径")
|
||||
private String filePath;
|
||||
|
||||
/**
|
||||
* 文件SHA
|
||||
*/
|
||||
/** 文件SHA */
|
||||
@Excel(name = "文件SHA")
|
||||
private String fileSha;
|
||||
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
/** 文件大小 */
|
||||
@Excel(name = "文件大小")
|
||||
private Long fileSize;
|
||||
|
||||
/**
|
||||
* 文件URL
|
||||
*/
|
||||
/** 文件URL */
|
||||
@Excel(name = "文件URL")
|
||||
private String fileUrl;
|
||||
|
||||
|
|
@ -171,16 +162,10 @@ public class CmsDoc extends BaseSortEntity {
|
|||
*/
|
||||
private String keywords;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public CmsDir copyToCmsDir() {
|
||||
CmsDir cmsDir = new CmsDir();
|
||||
cmsDir.setId(id);
|
||||
cmsDir.setName(name);
|
||||
cmsDir.setHeadImg(headImg);
|
||||
cmsDir.setSort(this.getSort());
|
||||
cmsDir.setCreatedAt(getCreateTime());
|
||||
return cmsDir;
|
||||
|
|
@ -201,8 +186,6 @@ public class CmsDoc extends BaseSortEntity {
|
|||
HotCmsDocDto hotCmsDocDto = new HotCmsDocDto();
|
||||
hotCmsDocDto.setId(id);
|
||||
hotCmsDocDto.setName(name);
|
||||
hotCmsDocDto.setSummary(summary);
|
||||
hotCmsDocDto.setPublishTime(publishTime);
|
||||
return hotCmsDocDto;
|
||||
}
|
||||
|
||||
|
|
@ -224,12 +207,30 @@ public class CmsDoc extends BaseSortEntity {
|
|||
}
|
||||
|
||||
private CmsDocBaseDto getCmsDocBaseDto(CmsDocBaseDto cmsDocDto) {
|
||||
BeanUtils.copyProperties(this, cmsDocDto);
|
||||
cmsDocDto.setId(id);
|
||||
cmsDocDto.setName(name);
|
||||
cmsDocDto.setHeadImg(headImg);
|
||||
cmsDocDto.setIsHomepage(isHomepage);
|
||||
cmsDocDto.setSummary(summary);
|
||||
cmsDocDto.setEditorType(editorType);
|
||||
cmsDocDto.setDeptId(deptId);
|
||||
|
||||
if (visits == null) {
|
||||
cmsDocDto.setVisits(0L);
|
||||
} else {
|
||||
cmsDocDto.setVisits(visits);
|
||||
}
|
||||
|
||||
cmsDocDto.setPublishTime(publishTime);
|
||||
cmsDocDto.setPublishUser(publishUser);
|
||||
cmsDocDto.setPublishUserUrl(publishUserUrl);
|
||||
cmsDocDto.setPublishUserImage(publishUserImage);
|
||||
cmsDocDto.setPublishUserNickname(publishUserNickname);
|
||||
cmsDocDto.setAuditStatus(auditStatus);
|
||||
cmsDocDto.setAuditType(auditType);
|
||||
cmsDocDto.setCreateBy(createBy);
|
||||
cmsDocDto.setKeywords(keywords);
|
||||
|
||||
return cmsDocDto;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,10 +20,4 @@ public class CmsDocAuditVo {
|
|||
*/
|
||||
@ApiModelProperty(value = "是否重新编辑: 0不允许重新编辑 1允许重新编辑")
|
||||
private Integer reedit;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiModelProperty(value = "审核备注")
|
||||
private String remark;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,10 +101,6 @@ public class CmsDocBaseDto {
|
|||
*/
|
||||
@ApiModelProperty("关键词")
|
||||
private String keywords;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
public void setPublishTime(Date publishTime) {
|
||||
if (publishTime != null) {
|
||||
|
|
|
|||
|
|
@ -83,10 +83,4 @@ public class CmsDocSearchVo {
|
|||
*/
|
||||
@ApiModelProperty("关键词")
|
||||
private String keywords;
|
||||
|
||||
/**
|
||||
* 排除文章Id
|
||||
*/
|
||||
@ApiModelProperty(value = "排除文章Id", hidden = true)
|
||||
private Long excludeId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
package com.microservices.cms.doc.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* CmsDoc with full-text search score
|
||||
* 用于全局搜索结果,包含全文搜索相关度评分
|
||||
*
|
||||
* @author otto
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CmsDocWithScore extends CmsDoc implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 全文搜索相关度评分(来自 MySQL MATCH...AGAINST)
|
||||
*/
|
||||
private Double searchScore;
|
||||
}
|
||||
|
|
@ -1,13 +1,10 @@
|
|||
package com.microservices.cms.doc.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.microservices.common.core.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author otto
|
||||
*/
|
||||
|
|
@ -26,11 +23,4 @@ public class HotCmsDocDto {
|
|||
@Excel(name = "文章名称")
|
||||
@ApiModelProperty("文章名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("文章概要")
|
||||
private String summary;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@ApiModelProperty("发布时间")
|
||||
private Date publishTime;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.microservices.cms.doc.domain.gitlink;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
|
@ -24,12 +22,4 @@ public class EntryDto implements Comparable<EntryDto> {
|
|||
// 重写Comparable接口的compareTo方法,根据年龄升序排列,降序修改相减顺序即可
|
||||
return Math.toIntExact(entryDto.getCommit().getCreated_at_unix() - this.commit.getCreated_at_unix());
|
||||
}
|
||||
|
||||
public static EntryDto getEntryDtoFromJson(JSONObject subEntriesResult) {
|
||||
FileEntryDto fileEntryDto = subEntriesResult.toJavaObject(FileEntryDto.class);
|
||||
if (fileEntryDto == null || fileEntryDto.getEntries() == null) {
|
||||
throw new ServiceException("该文章不存在");
|
||||
}
|
||||
return fileEntryDto.getEntries();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.microservices.cms.doc.mapper;
|
|||
|
||||
import com.microservices.cms.doc.domain.CmsDoc;
|
||||
import com.microservices.cms.doc.domain.CmsDocSearchVo;
|
||||
import com.microservices.cms.doc.domain.CmsDocWithScore;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
|
@ -24,14 +23,6 @@ public interface CmsDocMapper {
|
|||
*/
|
||||
public CmsDoc selectCmsDocById(Long id);
|
||||
|
||||
/**
|
||||
* 批量查询文章信息
|
||||
*
|
||||
* @param ids 文章ID列表
|
||||
* @return 文章信息列表
|
||||
*/
|
||||
List<CmsDoc> selectCmsDocByIds(@Param("ids") List<Long> ids);
|
||||
|
||||
/**
|
||||
* 查询文章信息列表
|
||||
*
|
||||
|
|
@ -40,17 +31,6 @@ public interface CmsDocMapper {
|
|||
*/
|
||||
public List<CmsDoc> selectCmsDocList(CmsDocSearchVo cmsDocSearchVo);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询文章信息列表(设置默认头图为栏目头图)
|
||||
*
|
||||
* @param cmsDocSearchVo 文章信息
|
||||
* @return 文章信息集合
|
||||
*/
|
||||
List<CmsDoc> selectCmsDocListSetDefaultHeadImg(CmsDocSearchVo cmsDocSearchVo);
|
||||
|
||||
|
||||
/**
|
||||
* 新增文章信息
|
||||
*
|
||||
|
|
@ -91,11 +71,6 @@ public interface CmsDocMapper {
|
|||
|
||||
CmsDoc selectCmsDocByFilePathAndDeptId(@Param("filePath") String filePath, @Param("deptId") Long deptId);
|
||||
|
||||
/**
|
||||
* 按文章名+deptId查询(忽略dirName),用于Webhook防重判断
|
||||
*/
|
||||
CmsDoc selectCmsDocByNameAndDeptIdIgnoreDirName(@Param("name") String name, @Param("deptId") Long deptId);
|
||||
|
||||
List<CmsDoc> selectHotCmsDocList(CmsDoc cmsDocInput);
|
||||
|
||||
List<CmsDoc> selectCmsDocDirByDeptIdAndInName(@Param("deptId") Long deptId, @Param("cmsDirNameList") List<String> cmsDirNameList);
|
||||
|
|
@ -197,50 +172,4 @@ public interface CmsDocMapper {
|
|||
Long getNotAuditCmsCountByDeptId(Long deptId);
|
||||
|
||||
Long getCmsDocVisitsByDeptId(Long deptId);
|
||||
|
||||
/**
|
||||
* 根据组织id获取专区下所有文章和栏目
|
||||
* @param deptId 组织id
|
||||
* @return 文章和栏目列表
|
||||
*/
|
||||
List<CmsDoc> selectCmsDocAndDirListByDept(Long deptId);
|
||||
|
||||
void updateCmsDocShaByPathAndDeptId(@Param("sha") String sha, @Param("filePath") String filePath, @Param("deptId") Long deptId);
|
||||
|
||||
/**
|
||||
* 全局搜索 - 全文索引查询
|
||||
*
|
||||
* @param keyword 搜索关键词
|
||||
* @param deptId 组织ID(可选)
|
||||
* @param offset 偏移量
|
||||
* @param pageSize 每页数量
|
||||
* @return 搜索结果列表
|
||||
*/
|
||||
List<CmsDoc> globalSearch(@Param("keyword") String keyword, @Param("deptId") Long deptId,
|
||||
@Param("offset") int offset, @Param("pageSize") int pageSize);
|
||||
|
||||
/**
|
||||
* 全局搜索结果计数
|
||||
*
|
||||
* @param keyword 搜索关键词
|
||||
* @param deptId 组织ID(可选)
|
||||
* @return 结果数量
|
||||
*/
|
||||
Long globalSearchCount(@Param("keyword") String keyword, @Param("deptId") Long deptId);
|
||||
|
||||
/**
|
||||
* 全局搜索 - 全文索引查询(含评分)
|
||||
*
|
||||
* @param keyword 搜索关键词
|
||||
* @param deptId 组织ID(可选)
|
||||
* @param offset 偏移量
|
||||
* @param pageSize 每页数量
|
||||
* @return 搜索结果列表(含评分)
|
||||
*/
|
||||
List<CmsDocWithScore> globalSearchWithScore(
|
||||
@Param("keyword") String keyword,
|
||||
@Param("deptId") Long deptId,
|
||||
@Param("offset") int offset,
|
||||
@Param("pageSize") int pageSize
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public interface ICmsAsyncService {
|
|||
|
||||
void asyncCreateBranchAndDeleteFileAndCreatePR(CmsDoc newDocWithAudit, CmsProject cmsProject);
|
||||
|
||||
void asyncMoveFileToNewDir(CmsProject cmsProject, CmsDoc oldCmsDir, String newCmsDirName);
|
||||
void asyncMoveFileToNewDir(CmsProject cmsProject, CmsDoc oldCmsDir, CmsDoc newCmsDir);
|
||||
|
||||
/**
|
||||
* 推送文章数据到搜索引擎
|
||||
|
|
@ -99,38 +99,4 @@ public interface ICmsAsyncService {
|
|||
* @param cmsDoc 文章
|
||||
*/
|
||||
void pushDocDataSearchEngine(CmsDoc cmsDoc);
|
||||
|
||||
void clearTmpDoc(CmsProject cmsProject,List<CmsDoc> tmpDocList);
|
||||
|
||||
/**
|
||||
* 异步增加文章发布积分
|
||||
*
|
||||
* @param deptId 组织ID
|
||||
* @param createBy 创建人用户名
|
||||
* @param docId 文章ID
|
||||
* @param subjectDesc 文章标题
|
||||
*/
|
||||
void addPublishDocPointsAsync(Long deptId, String createBy, Long docId, String subjectDesc);
|
||||
|
||||
/**
|
||||
* 异步增加文章浏览积分(每满100次+2,上限50)
|
||||
*
|
||||
* @param deptId 组织ID
|
||||
* @param createBy 创建人用户名
|
||||
* @param docId 文章ID
|
||||
* @param docName 文章名称
|
||||
* @param totalVisits 累计阅读次数
|
||||
* @param pointsTriggerCount 当前第几次增加积分
|
||||
*/
|
||||
void addVisitsDocPointsAsync(Long deptId, String createBy, Long docId, String docName, Long totalVisits);
|
||||
|
||||
/**
|
||||
* 异步增加文章被设为精选的积分
|
||||
*
|
||||
* @param deptId 组织ID
|
||||
* @param createBy 创建人用户名
|
||||
* @param docId 文章ID
|
||||
* @param subjectDesc 文章标题
|
||||
*/
|
||||
void addFeaturedDocPointsAsync(Long deptId, String createBy, Long docId, String subjectDesc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import com.microservices.cms.doc.domain.*;
|
|||
import com.microservices.cms.doc.domain.gitlink.EntryDto;
|
||||
import com.microservices.cms.doc.domain.gitlink.FileEntryDto;
|
||||
import com.microservices.cms.project.domain.CmsProject;
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
|
@ -57,9 +56,9 @@ public interface ICmsDocService {
|
|||
*
|
||||
* @param id
|
||||
* @param cmsDocDto 文章信息
|
||||
* @return 结果 文章id
|
||||
* @return 结果
|
||||
*/
|
||||
public Long updateCmsDoc(Long id, CmsDocDto cmsDocDto);
|
||||
public boolean updateCmsDoc(Long id, CmsDocDto cmsDocDto);
|
||||
|
||||
/**
|
||||
* 批量删除文章信息
|
||||
|
|
@ -145,15 +144,6 @@ public interface ICmsDocService {
|
|||
*/
|
||||
List<CmsDocBaseDto> selectHomePageDocList(Long deptId);
|
||||
|
||||
/**
|
||||
* 查询首页文章合并列表(积分置顶文章 + 首页推荐文章,自动去重,置顶在前)
|
||||
*
|
||||
* @param zoneId 专区ID
|
||||
* @param topDocIds 置顶文章 docId 有序列表(前端按此顺序排列)
|
||||
* @return 合并后的首页文章列表(isTop=true 标识置顶文章)
|
||||
*/
|
||||
List<CmsDocBaseDto> selectHomePageDocMergeList(Long zoneId, List<Long> topDocIds);
|
||||
|
||||
/**
|
||||
* 初始化栏目
|
||||
*
|
||||
|
|
@ -208,8 +198,6 @@ public interface ICmsDocService {
|
|||
*/
|
||||
List<CmsDocAllDto> selectCmsDocListByDept(Long deptId, CmsDocSearchVo cmsDocSearchVo);
|
||||
|
||||
GenericsTableDataInfo<CmsDocAllDto> selectAllDocList(Long deptId, CmsDocSearchVo cmsDocSearchVo);
|
||||
|
||||
/**
|
||||
* 查询专区下文章数量
|
||||
*
|
||||
|
|
@ -300,12 +288,4 @@ public interface ICmsDocService {
|
|||
CmsDocBaseDto selectCmsDocBaseInfoById(Long id);
|
||||
|
||||
Long getCmsDocVisitsByDeptId(Long deptId);
|
||||
|
||||
List<CmsDocBaseDto> selectSetDefaultHeadImgCmsDocList(Long dirId, CmsDocSearchVo cmsDocSearchVo);
|
||||
|
||||
List<CmsDoc> selectCmsDocAndDirListByDept(Long deptId);
|
||||
|
||||
void updateCmsDocShaByPathAndDeptId(String sha, String filePath, Long deptId);
|
||||
|
||||
List<CmsDoc> getTmpDocList(CmsDoc cmsDoc);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,18 +16,14 @@ import com.microservices.cms.project.service.ICmsProjectService;
|
|||
import com.microservices.cms.utils.CmsConstants;
|
||||
import com.microservices.cms.utils.CmsGitLinkRequestUrl;
|
||||
import com.microservices.cms.utils.CmsUtils;
|
||||
import com.microservices.cms.utils.CustomExecutorFactory;
|
||||
import com.microservices.common.core.constant.CacheConstants;
|
||||
import com.microservices.common.core.constant.Constants;
|
||||
import com.microservices.common.core.constant.SecurityConstants;
|
||||
import com.microservices.common.core.enums.DocAndZoneOperation;
|
||||
import com.microservices.common.core.enums.DocAuditStatus;
|
||||
import com.microservices.common.core.enums.SystemRole;
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.common.core.utils.DateUtils;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.core.utils.html.EscapeUtil;
|
||||
import com.microservices.common.core.utils.sign.Base64;
|
||||
import com.microservices.common.core.utils.uuid.IdUtils;
|
||||
import com.microservices.common.httpClient.constant.GitLinkConstants;
|
||||
import com.microservices.common.httpClient.service.HttpAPIService;
|
||||
|
|
@ -35,7 +31,6 @@ import com.microservices.common.httpClient.util.GitLinkRequestHelper;
|
|||
import com.microservices.common.redis.service.RedisService;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.system.api.RemoteDeptService;
|
||||
import com.microservices.system.api.RemoteUserService;
|
||||
import com.microservices.system.api.RemoteZoneService;
|
||||
import com.microservices.system.api.utils.FeignUtils;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
|
|
@ -52,7 +47,6 @@ import org.springframework.util.DigestUtils;
|
|||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -98,10 +92,7 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
@Autowired
|
||||
private RemoteZoneService remoteZoneService;
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
@Autowired
|
||||
private RequestConfig config;
|
||||
|
||||
/**
|
||||
* 异步设置文章更新时间
|
||||
*
|
||||
|
|
@ -118,7 +109,7 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
} else {
|
||||
redisService.setCacheObject(updateDocIntervalKey, cmsProject.getName(), 1L, TimeUnit.MINUTES);
|
||||
}
|
||||
CmsDocSearchVo cmsDocSearch = new CmsDocSearchVo();
|
||||
CmsDocSearchVo cmsDocSearch=new CmsDocSearchVo();
|
||||
cmsDocSearch.setDeptId(cmsProject.getDeptId());
|
||||
List<CmsDoc> cmsDocList = cmsDocMapper.selectCmsDocList(cmsDocSearch);
|
||||
for (EntryDto entryDto : entryDtoList) {
|
||||
|
|
@ -159,7 +150,7 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
webhook.put("eventCondition", "push");
|
||||
webhook.put("http_method", "POST");
|
||||
webhook.put("secret", "");
|
||||
webhook.put("url", gatewayUrl + "/cms/doc/open/dept/" + cmsProject.getDeptId());
|
||||
webhook.put("url", gatewayUrl+"/cms/doc/open/dept/"+cmsProject.getDeptId());
|
||||
webhook.put("events", new String[]{"push"});
|
||||
jsonObject.put("webhook", webhook);
|
||||
//增加Webhook
|
||||
|
|
@ -240,7 +231,7 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
}
|
||||
|
||||
private void syncDocAddedData(CmsProject cmsProject, List<String> addedList) {
|
||||
for (String addedFilePath : addedList) {
|
||||
for (String addedFilePath:addedList) {
|
||||
try {
|
||||
String[] filePathList = addedFilePath.split("/");
|
||||
if (filePathList.length != 2) {
|
||||
|
|
@ -256,27 +247,18 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
}
|
||||
CmsDoc cmsDoc = cmsDocMapper.selectCmsDocByNameAndDeptId(CmsUtils.getFileNameNoSuffix(entry.getName()), cmsProject.getDeptId(), dirName);
|
||||
if (cmsDoc == null) {
|
||||
// 防重:按文章名+deptId查一次,排除正在移动栏目的已有记录
|
||||
String docName = CmsUtils.getFileNameNoSuffix(entry.getName());
|
||||
CmsDoc existingDoc = cmsDocMapper.selectCmsDocByNameAndDeptIdIgnoreDirName(docName, cmsProject.getDeptId());
|
||||
if (existingDoc != null) {
|
||||
existingDoc.setDirName(dirName);
|
||||
existingDoc.setFilePath(dirName + "/" + existingDoc.getFileName());
|
||||
cmsDocMapper.updateCmsDoc(existingDoc);
|
||||
} else {
|
||||
syncCreateDoc(entry, dirName, cmsProject.getDeptId(), fileEntry.getLast_commit());
|
||||
}
|
||||
syncCreateDoc(entry, dirName, cmsProject.getDeptId(), fileEntry.getLast_commit());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}catch (Exception e){
|
||||
logger.error("[{}]同步新增文章发生异常:{}"
|
||||
, cmsProject.getName(), e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void syncDocRemovedData(CmsProject cmsProject, List<String> removedList) {
|
||||
for (String removedFilePath : removedList) {
|
||||
private void syncDocRemovedData(CmsProject cmsProject,List<String> removedList) {
|
||||
for (String removedFilePath:removedList) {
|
||||
try {
|
||||
String[] filePathList = removedFilePath.split("/");
|
||||
if (filePathList.length != 2) {
|
||||
|
|
@ -375,7 +357,7 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
cmsDocSearch.setDeptId(cmsDir.getDeptId());
|
||||
cmsDocSearch.setDirName(cmsDir.getName());
|
||||
cmsDocSearch.setIsDir(false);
|
||||
List<CmsDoc> cmsDocList = cmsDocMapper.selectCmsDocList(cmsDocSearch);
|
||||
List<CmsDoc> cmsDocList=cmsDocMapper.selectCmsDocList(cmsDocSearch);
|
||||
//获取数据库所有文件的filePath
|
||||
List<String> databaseFilePathList = cmsDocList.stream().map(CmsDoc::getFilePath).collect(Collectors.toList());
|
||||
//获取需要新增的文章
|
||||
|
|
@ -401,16 +383,16 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
@Override
|
||||
public void asyncDocData(Long deptId, String bodyStr) {
|
||||
//防止多次操作同时执行,将同步内容放入队列,根据先后时间执行同步动作
|
||||
String cmsSyncDeptIdKey = CacheConstants.CMS_SYNC_DEPT_ID_KEY + deptId;
|
||||
String cmsSyncDeptIdKey=CacheConstants.CMS_SYNC_DEPT_ID_KEY+deptId;
|
||||
//为当前同步操作生成UUID,若拿到的UUID为自身,则执行本次同步动作
|
||||
String UUID = IdUtils.fastSimpleUUID();
|
||||
String UUID= IdUtils.fastSimpleUUID();
|
||||
redisService.leftPush(cmsSyncDeptIdKey, UUID);
|
||||
//设置缓存过期时间,防止异常情况导致同步无法继续执行
|
||||
redisService.expire(cmsSyncDeptIdKey, 3600, TimeUnit.SECONDS);
|
||||
String currentUUID = String.valueOf(redisService.listIndexOf(cmsSyncDeptIdKey, -1));
|
||||
//设置最大循环阈值,防止意外情况导致死循环(7200次,约1小时左右)
|
||||
int threshold = 7200;
|
||||
while (!UUID.equals(currentUUID) && threshold != 0) {
|
||||
int threshold=7200;
|
||||
while (!UUID.equals(currentUUID)&&threshold!=0){
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
|
|
@ -420,41 +402,41 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
threshold--;
|
||||
}
|
||||
|
||||
try {
|
||||
CmsProject cmsProject = cmsProjectService.selectCmsProjectByDeptId(deptId);
|
||||
JSONObject body = JSONObject.parseObject(bodyStr);
|
||||
try{
|
||||
CmsProject cmsProject=cmsProjectService.selectCmsProjectByDeptId(deptId);
|
||||
JSONObject body=JSONObject.parseObject(bodyStr);
|
||||
//获取本次推送中Commit总数
|
||||
Integer totalCommits = body.getInteger("total_commits");
|
||||
Integer totalCommits=body.getInteger("total_commits");
|
||||
//从webhook请求中获取本次提交内容
|
||||
JSONArray commits = body.getJSONArray("commits");
|
||||
JSONArray commits=body.getJSONArray("commits");
|
||||
//当commit总数大于提交的列表数量时,代表此次PUSH未携带所有commit,此时进行一次全量同步
|
||||
if (totalCommits != null
|
||||
&& commits != null
|
||||
&& totalCommits > commits.size()) {
|
||||
if(totalCommits!=null
|
||||
&&commits!=null
|
||||
&&totalCommits>commits.size()){
|
||||
fullSyncDocData(cmsProject);
|
||||
} else {
|
||||
for (int i = commits.size() - 1; i >= 0; i--) {
|
||||
JSONObject commit = commits.getJSONObject(i);
|
||||
}else{
|
||||
for (int i = commits.size()-1; i >=0 ; i--) {
|
||||
JSONObject commit=commits.getJSONObject(i);
|
||||
//获取新增的文件列表
|
||||
JSONArray addedList = commit.getJSONArray("added");
|
||||
if (addedList != null) {
|
||||
syncDocAddedData(cmsProject, addedList.toJavaList(String.class));
|
||||
JSONArray addedList=commit.getJSONArray("added");
|
||||
if(addedList!=null){
|
||||
syncDocAddedData(cmsProject,addedList.toJavaList(String.class));
|
||||
}
|
||||
//获取删除的文件列表
|
||||
JSONArray removedList = commit.getJSONArray("removed");
|
||||
if (removedList != null) {
|
||||
syncDocRemovedData(cmsProject, removedList.toJavaList(String.class));
|
||||
JSONArray removedList=commit.getJSONArray("removed");
|
||||
if(removedList!=null){
|
||||
syncDocRemovedData(cmsProject,removedList.toJavaList(String.class));
|
||||
}
|
||||
//获取更新的文件列表
|
||||
JSONArray modifiedList = commit.getJSONArray("modified");
|
||||
if (modifiedList != null) {
|
||||
JSONArray modifiedList=commit.getJSONArray("modified");
|
||||
if(modifiedList!=null){
|
||||
syncDocModifiedData(cmsProject, modifiedList.toJavaList(String.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}catch (Exception e) {
|
||||
logger.error("同步文章时发送异常:{}", e.getMessage());
|
||||
} finally {
|
||||
}finally {
|
||||
//本次同步执行完成后,再弹出该UUID
|
||||
redisService.rightPop(cmsSyncDeptIdKey, 500, TimeUnit.MICROSECONDS);
|
||||
}
|
||||
|
|
@ -487,12 +469,12 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void syncCreateDir(String dirName, EntryDto entry, CmsProject cmsProject, boolean isCreateKeep) {
|
||||
public void syncCreateDir(String dirName,EntryDto entry,CmsProject cmsProject,boolean isCreateKeep){
|
||||
CmsDoc cmsDir = new CmsDoc();
|
||||
cmsDir.setName(dirName);
|
||||
cmsDir.setCreateTime(entry.getCommit().getCreated_at());
|
||||
boolean insertResult;
|
||||
if (isCreateKeep) {
|
||||
if(isCreateKeep){
|
||||
//若该栏目不存在,检查文件夹中是否存在.keep文件
|
||||
JSONObject subEntriesResult = gitLinkRequestHelper.doGet(
|
||||
CmsGitLinkRequestUrl.GET_FILE_SUB_ENTRIES(cmsProject, cmsDir.getName(), CmsConstants.BRANCH_MASTER));
|
||||
|
|
@ -502,14 +484,14 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
|
||||
if (keepEntry != null) {
|
||||
//若存在,则在数据库中创建该栏目
|
||||
insertResult = createCmsDir(cmsDir, cmsProject.getDeptId(), keepEntry);
|
||||
insertResult=createCmsDir(cmsDir,cmsProject.getDeptId(),keepEntry);
|
||||
} else {
|
||||
//若不存在,则在数据库中创建该栏目,同时在仓库的该文件夹下创建.keep文件
|
||||
insertResult = cmsDocService.insertCmsDocDir(cmsProject.getDeptId(), cmsDir.copyToCmsDir());
|
||||
}
|
||||
} else {
|
||||
}else{
|
||||
//若不自动创建,则在数据库中创建根据文件名该栏目
|
||||
insertResult = createCmsDir(cmsDir, cmsProject.getDeptId(), entry);
|
||||
insertResult=createCmsDir(cmsDir,cmsProject.getDeptId(),entry);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -518,7 +500,7 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean createCmsDir(CmsDoc cmsDir, Long deptId, EntryDto entry) {
|
||||
private boolean createCmsDir(CmsDoc cmsDir,Long deptId,EntryDto entry){
|
||||
cmsDir.setIsDir(true);
|
||||
cmsDir.setFilePath(cmsDir.getDirPath());
|
||||
cmsDir.setDeptId(deptId);
|
||||
|
|
@ -632,12 +614,11 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
100, "..."), tmpBranchName);
|
||||
} catch (ServiceException e) {
|
||||
//忽略重复创建PR异常
|
||||
if (!e.getMessage().contains("合并请求已存在")) {
|
||||
if (!"请求GitLink失败(合并请求已存在)".equals(e.getMessage())) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cmsDocService.updateCmsCommonDatabase(cmsDoc, tmpBranchName);
|
||||
}
|
||||
|
||||
|
|
@ -697,7 +678,6 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
requestBody);
|
||||
cmsDoc.setAuditPrNumber(result.getString("pull_request_number") + "-" + result.getString("pull_request_id"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CmsDoc updateCmsDocDatabaseAndUpdateForGitLink(CmsDoc oldCmsDoc, CmsDocDto cmsDocDto, String branchName) {
|
||||
if (oldCmsDoc == null) {
|
||||
|
|
@ -738,8 +718,8 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
|
||||
if (isChangeName || isChangeDir) {
|
||||
oldCmsDoc = renameAndChangeDirCmsDoc(oldCmsDoc, cmsProject, newName, newDirName, branchName);
|
||||
// 立即更新数据库中的dirName/filePath,避免GitLink Webhook回调时查不到记录导致重复INSERT
|
||||
cmsDocMapper.updateCmsDoc(oldCmsDoc);
|
||||
//todo 此处是否需要更新数据库待讨论
|
||||
//updateCmsCommonDatabase(oldCmsDoc);
|
||||
}
|
||||
|
||||
boolean isChangeContent = false;
|
||||
|
|
@ -891,87 +871,27 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void asyncMoveFileToNewDir(CmsProject cmsProject, CmsDoc oldCmsDir, String newCmsDirName) {
|
||||
@Async
|
||||
public void asyncMoveFileToNewDir(CmsProject cmsProject, CmsDoc oldCmsDir, CmsDoc newCmsDir) {
|
||||
try {
|
||||
JSONObject dirFilesJson = gitLinkRequestHelper.doGet(CmsGitLinkRequestUrl.GET_DIR_SUB_ENTRIES(
|
||||
cmsProject,
|
||||
oldCmsDir.getName(),
|
||||
CmsConstants.BRANCH_MASTER));
|
||||
List<EntryDto> entryDtoList = cmsDocService.getEntriesFromRequestResult(dirFilesJson, cmsProject, false);
|
||||
CountDownLatch countDownLatch = new CountDownLatch(entryDtoList.size());
|
||||
// 异步获取每篇文章内容
|
||||
entryDtoList.forEach(entryDto -> {
|
||||
CustomExecutorFactory.threadPoolExecutor.execute(() -> {
|
||||
try {
|
||||
JSONObject fileSubEntriesResult = gitLinkRequestHelper.doGet(
|
||||
CmsGitLinkRequestUrl.GET_FILE_SUB_ENTRIES(
|
||||
cmsProject,
|
||||
entryDto.getPath(),
|
||||
CmsConstants.BRANCH_MASTER));
|
||||
EntryDto cmsDocEntryDto = EntryDto.getEntryDtoFromJson(fileSubEntriesResult);
|
||||
entryDto.setContent(cmsDocEntryDto.getContent());
|
||||
} finally {
|
||||
countDownLatch.countDown();
|
||||
}
|
||||
});
|
||||
});
|
||||
try {
|
||||
countDownLatch.await();
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("栏目重命名失败(将对应代码库中文章移动至新文件夹失败):{}", e.getMessage());
|
||||
throw new ServiceException("栏目重命名失败");
|
||||
}
|
||||
|
||||
for (EntryDto entryDto : entryDtoList) {
|
||||
JSONObject updateFileBody = new JSONObject();
|
||||
updateFileBody.put("branch", CmsConstants.BRANCH_MASTER);
|
||||
updateFileBody.put("message", "移动文章至新栏目");
|
||||
updateFileBody.put("from_path", entryDto.getPath());
|
||||
String newFilePath = newCmsDirName + "/" + entryDto.getName();
|
||||
updateFileBody.put("filepath", newFilePath);
|
||||
updateFileBody.put("base64_filepath", Base64.contentToBase64(newFilePath));
|
||||
updateFileBody.put("sha", entryDto.getSha());
|
||||
String content = entryDto.getContent();
|
||||
if (content == null) {
|
||||
content = "";
|
||||
}
|
||||
updateFileBody.put("content", content);
|
||||
gitLinkRequestHelper.doPut(CmsGitLinkRequestUrl.UPDATE_FILE(cmsProject), updateFileBody);
|
||||
}
|
||||
CmsDoc newCmsDoc = oldCmsDir.copyToRenameCmsDir(newCmsDirName);
|
||||
//在数据库中重命名该栏目
|
||||
cmsDocService.updateCmsCommonDatabase(newCmsDoc, CmsConstants.BRANCH_MASTER);
|
||||
remoteZoneService.lockCmsByDeptId(cmsProject.getDeptId(), 1, SecurityConstants.INNER);
|
||||
//创建新栏目
|
||||
String message = String.format("重命名栏目:由[%s]重命名为[%s]", oldCmsDir.getName(), newCmsDir.getName());
|
||||
cmsDocService.createFileByGitLink(newCmsDir, message, "");
|
||||
//在数据库中重命名该栏目,防止后续操作推送的WebHook重复创建栏目
|
||||
cmsDocService.updateCmsCommonDatabase(newCmsDir, CmsConstants.BRANCH_MASTER);
|
||||
//将原栏目中所有文章移动到新栏目中
|
||||
moveCmsDocToNewCmsDir(cmsProject, oldCmsDir.getName(), newCmsDir.getName(), message);
|
||||
//删除旧栏目
|
||||
deleteCmsDocByGitLink(cmsProject, oldCmsDir);
|
||||
} catch (Exception e) {
|
||||
logger.error("重命名栏目失败(原栏目名称[{}],新栏目名称[{}]):{}", oldCmsDir.getName(), newCmsDirName, e.getMessage());
|
||||
throw new ServiceException("重命名栏目失败(原栏目名称[" + oldCmsDir.getName() + "],新栏目名称[" + newCmsDirName + "])");
|
||||
logger.error("重命名栏目失败(原栏目名称[{}],新栏目名称[{}]):{}", oldCmsDir.getName(), newCmsDir.getName(), e.getMessage());
|
||||
throw new ServiceException("重命名栏目失败(原栏目名称[" + oldCmsDir.getName() + "],新栏目名称[" + newCmsDir.getName() + "])");
|
||||
} finally {
|
||||
remoteZoneService.lockCmsByDeptId(cmsProject.getDeptId(), 0, SecurityConstants.INNER);
|
||||
}
|
||||
// finally {
|
||||
// remoteZoneService.lockCmsByDeptId(cmsProject.getDeptId(), 0, SecurityConstants.INNER);
|
||||
// }
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @Async
|
||||
// public void asyncMoveFileToNewDir(CmsProject cmsProject, CmsDoc oldCmsDir, CmsDoc newCmsDir) {
|
||||
// try {
|
||||
// remoteZoneService.lockCmsByDeptId(cmsProject.getDeptId(), 1, SecurityConstants.INNER);
|
||||
// //创建新栏目
|
||||
// String message = String.format("重命名栏目:由[%s]重命名为[%s]", oldCmsDir.getName(), newCmsDir.getName());
|
||||
// cmsDocService.createFileByGitLink(newCmsDir, message, "");
|
||||
// //在数据库中重命名该栏目,防止后续操作推送的WebHook重复创建栏目
|
||||
// cmsDocService.updateCmsCommonDatabase(newCmsDir, CmsConstants.BRANCH_MASTER);
|
||||
// //将原栏目中所有文章移动到新栏目中
|
||||
// moveCmsDocToNewCmsDir(cmsProject, oldCmsDir.getName(), newCmsDir.getName(), message);
|
||||
// //删除旧栏目
|
||||
// deleteCmsDocByGitLink(cmsProject, oldCmsDir);
|
||||
// } catch (Exception e) {
|
||||
// logger.error("重命名栏目失败(原栏目名称[{}],新栏目名称[{}]):{}", oldCmsDir.getName(), newCmsDir.getName(), e.getMessage());
|
||||
// throw new ServiceException("重命名栏目失败(原栏目名称[" + oldCmsDir.getName() + "],新栏目名称[" + newCmsDir.getName() + "])");
|
||||
// } finally {
|
||||
// remoteZoneService.lockCmsByDeptId(cmsProject.getDeptId(), 0, SecurityConstants.INNER);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void pushDocDataSearchEngine(CmsDoc cmsDoc) {
|
||||
|
|
@ -1018,23 +938,6 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearTmpDoc(CmsProject cmsProject, List<CmsDoc> tmpDocList) {
|
||||
CustomExecutorFactory.threadPoolExecutor.execute(() -> {
|
||||
for (CmsDoc tmpDoc : tmpDocList) {
|
||||
//拒绝GitLink合并请求
|
||||
String gitLinkPullRequestNumber = tmpDoc.getAuditPrNumber().split("-")[0];
|
||||
gitLinkRequestHelper.doPost(
|
||||
CmsGitLinkRequestUrl.REFUSE_MERGE_PULL_REQUEST(cmsProject, gitLinkPullRequestNumber), null);
|
||||
gitLinkRequestHelper.doPost(CmsGitLinkRequestUrl.DELETE_BRANCH(cmsProject, tmpDoc.getAuditTmpBranchName()), null);
|
||||
// 所有删除操作调整为将审核状态设置为已拒绝
|
||||
tmpDoc.setAuditStatus(DocAuditStatus.AUDIT_FAIL.getAuditCode());
|
||||
tmpDoc.setRemark("管理员删除");
|
||||
cmsDocMapper.updateCmsDoc(tmpDoc);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void moveCmsDocToNewCmsDir(CmsProject cmsProject, String oldDirName, String newDirName, String message) {
|
||||
CmsDocSearchVo cmsDocSearch = new CmsDocSearchVo();
|
||||
cmsDocSearch.setIsDir(false);
|
||||
|
|
@ -1087,127 +990,4 @@ public class CmsAsyncServiceImpl implements ICmsAsyncService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否为积分部门
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 是否为积分部门
|
||||
*/
|
||||
private boolean isPointsDept(Long deptId) {
|
||||
Long cachedPointsDeptId = redisService.getCacheObject(CacheConstants.ZONE_POINTS_DEPT_ID_KEY);
|
||||
return cachedPointsDeptId != null && cachedPointsDeptId > 0 && cachedPointsDeptId.equals(deptId);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void addPublishDocPointsAsync(Long deptId, String createBy, Long docId, String subjectDesc) {
|
||||
try {
|
||||
if (deptId == null || createBy == null) {
|
||||
logger.warn("文章审核通过增加积分失败,deptId或createBy为空,docId={}", docId);
|
||||
return;
|
||||
}
|
||||
// 检查是否为积分部门
|
||||
if (!isPointsDept(deptId)) {
|
||||
logger.info("文章审核通过增加积分跳过,非积分部门,deptId={},docId={}", deptId, docId);
|
||||
return;
|
||||
}
|
||||
// 获取用户ID
|
||||
com.microservices.system.api.domain.SysUser sysUser = FeignUtils.getReturnData(
|
||||
remoteUserService.getSysUserByUserName(createBy, SecurityConstants.INNER));
|
||||
if (sysUser == null || sysUser.getUserId() == null) {
|
||||
logger.warn("文章审核通过增加积分失败,未找到用户信息,createBy={},docId={}", createBy, docId);
|
||||
return;
|
||||
}
|
||||
|
||||
// 直接写入 Redis 积分队列,由 Zone 模块定时任务消费
|
||||
JSONObject task = new JSONObject();
|
||||
task.put("sourceType", CmsConstants.PUBLISH_DOC);
|
||||
task.put("userId", sysUser.getUserId());
|
||||
task.put("deptId", deptId);
|
||||
task.put("sourceId", docId);
|
||||
task.put("subjectDesc", subjectDesc);
|
||||
task.put("operatorId", sysUser.getUserId());
|
||||
redisService.leftPush(CmsConstants.ZONE_POINTS_ASYNC_QUEUE_KEY, task.toJSONString());
|
||||
logger.info("文章审核通过增加积分任务已写入队列,docId={},userId={},deptId={}", docId, sysUser.getUserId(), deptId);
|
||||
} catch (Exception e) {
|
||||
// 捕获异常,确保不影响主事务
|
||||
logger.error("文章审核通过增加积分异常,docId={}", docId, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void addVisitsDocPointsAsync(Long deptId, String createBy, Long docId, String docName, Long totalVisits) {
|
||||
try {
|
||||
if (deptId == null || createBy == null) {
|
||||
logger.warn("文章浏览增加积分失败,参数不合法,deptId={},createBy={}", deptId, createBy);
|
||||
return;
|
||||
}
|
||||
// 检查是否为积分部门
|
||||
if (!isPointsDept(deptId)) {
|
||||
logger.info("文章浏览增加积分跳过,非积分部门,deptId={},docId={}", deptId, docId);
|
||||
return;
|
||||
}
|
||||
// 获取用户ID
|
||||
com.microservices.system.api.domain.SysUser sysUser = FeignUtils.getReturnData(
|
||||
remoteUserService.getSysUserByUserName(createBy, SecurityConstants.INNER));
|
||||
if (sysUser == null || sysUser.getUserId() == null) {
|
||||
logger.warn("文章浏览增加积分失败,未找到用户信息,createBy={},docId={}", createBy, docId);
|
||||
return;
|
||||
}
|
||||
// 直接写入 Redis 积分队列,由 Zone 模块定时任务消费
|
||||
JSONObject task = new JSONObject();
|
||||
task.put("sourceType", CmsConstants.VISITS_DOC);
|
||||
task.put("userId", sysUser.getUserId());
|
||||
task.put("deptId", deptId);
|
||||
task.put("sourceId", docId);
|
||||
// JSONObject sourceData = new JSONObject();
|
||||
// sourceData.put("totalVisits", totalVisits);
|
||||
// sourceData.put("currentIncrement", pointsTriggerCount);
|
||||
task.put("sourceData", totalVisits);
|
||||
task.put("subjectDesc", docName);
|
||||
task.put("operatorId", SecurityUtils.getUserId());
|
||||
redisService.leftPush(CmsConstants.ZONE_POINTS_ASYNC_QUEUE_KEY, task.toJSONString());
|
||||
logger.info("文章浏览增加积分任务已写入队列,docId={},userId={},deptId={},totalVisits={}", docId, sysUser.getUserId(), deptId, totalVisits);
|
||||
} catch (Exception e) {
|
||||
// 捕获异常,确保不影响主事务
|
||||
logger.error("文章浏览增加积分异常,docId={}", docId, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void addFeaturedDocPointsAsync(Long deptId, String createBy, Long docId, String subjectDesc) {
|
||||
try {
|
||||
if (deptId == null || createBy == null) {
|
||||
logger.warn("积分-文章精选:参数不合法,deptId={},createBy={}", deptId, createBy);
|
||||
return;
|
||||
}
|
||||
// 检查是否为积分部门
|
||||
if (!isPointsDept(deptId)) {
|
||||
logger.info("积分-文章精选:非积分部门,deptId={},docId={}", deptId, docId);
|
||||
return;
|
||||
}
|
||||
// 获取用户ID
|
||||
com.microservices.system.api.domain.SysUser sysUser = FeignUtils.getReturnData(
|
||||
remoteUserService.getSysUserByUserName(createBy, SecurityConstants.INNER));
|
||||
if (sysUser == null || sysUser.getUserId() == null) {
|
||||
logger.warn("积分-文章精选:未找到用户信息,createBy={},docId={}", createBy, docId);
|
||||
return;
|
||||
}
|
||||
// 直接写入 Redis 积分队列,由 Zone 模块定时任务消费
|
||||
JSONObject task = new JSONObject();
|
||||
task.put("sourceType", CmsConstants.FEATURED_DOC);
|
||||
task.put("userId", sysUser.getUserId());
|
||||
task.put("deptId", deptId);
|
||||
task.put("sourceId", docId);
|
||||
task.put("subjectDesc", "《" + subjectDesc + "》管理员标记");
|
||||
task.put("operatorId", SecurityUtils.getUserId());
|
||||
redisService.leftPush(CmsConstants.ZONE_POINTS_ASYNC_QUEUE_KEY, task.toJSONString());
|
||||
logger.info("文章被设为精选增加积分任务已写入队列,docId={},userId={},deptId={}", docId, sysUser.getUserId(), deptId);
|
||||
} catch (Exception e) {
|
||||
// 捕获异常,确保不影响主事务
|
||||
logger.error("文章被设为精选增加积分异常,docId={}", docId, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import com.microservices.cms.utils.CmsGitLinkRequestUrl;
|
|||
import com.microservices.common.core.constant.CacheConstants;
|
||||
import com.microservices.common.core.constant.HttpStatus;
|
||||
import com.microservices.common.core.constant.SecurityConstants;
|
||||
import com.microservices.common.core.constant.UserConstants;
|
||||
import com.microservices.common.core.enums.DocAndZoneOperation;
|
||||
import com.microservices.common.core.enums.DocAuditStatus;
|
||||
import com.microservices.common.core.enums.SystemRole;
|
||||
|
|
@ -24,12 +23,10 @@ import com.microservices.common.core.utils.DateUtils;
|
|||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.core.utils.bean.BeanUtils;
|
||||
import com.microservices.common.core.utils.html.EscapeUtil;
|
||||
import com.microservices.common.core.web.page.GenericsTableDataInfo;
|
||||
import com.microservices.common.httpClient.constant.GitLinkConstants;
|
||||
import com.microservices.common.httpClient.util.GitLinkRequestHelper;
|
||||
import com.microservices.common.redis.service.RedisService;
|
||||
import com.microservices.common.security.auth.AuthUtil;
|
||||
import com.microservices.common.security.service.TokenService;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.system.api.RemoteDeptService;
|
||||
import com.microservices.system.api.RemoteUserService;
|
||||
|
|
@ -50,11 +47,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -86,8 +79,6 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
@Autowired
|
||||
private RemoteDeptService remoteDeptService;
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
@Autowired
|
||||
@Lazy
|
||||
private ICmsDocCommentService cmsDocCommentService;
|
||||
@Value("${cms.detailPath:/newdetail}")
|
||||
|
|
@ -97,7 +88,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
* 查询文章信息
|
||||
*
|
||||
* @param id 文章信息主键
|
||||
* @param isOpen 是否公开访问
|
||||
* @param isOpen
|
||||
* @return 文章信息
|
||||
*/
|
||||
@Override
|
||||
|
|
@ -112,14 +103,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
|
||||
CmsProject cmsProject = cmsProjectService.selectCmsProjectByDeptId(cmsDoc.getDeptId());
|
||||
|
||||
// 确定查询文件的分支:已发布文章或非仓库改动使用 master,其他使用临时分支
|
||||
String branchName;
|
||||
if (DocAuditStatus.AUDIT_PASS.getAuditCode().equals(cmsDoc.getAuditStatus())
|
||||
|| (cmsDoc.getAuditType() != null && cmsDoc.getAuditType().contains(DocAndZoneOperation.OPERATION_NON_REPO_UPDATE.getOperationCode()))) {
|
||||
branchName = CmsConstants.BRANCH_MASTER;
|
||||
} else {
|
||||
branchName = cmsDoc.getAuditTmpBranchName();
|
||||
}
|
||||
String branchName = DocAuditStatus.AUDIT_PASS.getAuditCode().equals(cmsDoc.getAuditStatus()) ? CmsConstants.BRANCH_MASTER : cmsDoc.getAuditTmpBranchName();
|
||||
FileEntryDto fileEntryDto = getFileEntryDto(cmsProject, cmsDoc.getFilePath(), branchName);
|
||||
EntryDto entryDto = fileEntryDto.getEntries();
|
||||
|
||||
|
|
@ -130,7 +114,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
if (cmsDoc.getPublishTime() != null && cmsDoc.getPublishTime().after(cmsDoc.getCreateTime())) {
|
||||
cmsDocDto.setIsFirstPublish(false);
|
||||
}
|
||||
if (isOpen && DocAuditStatus.AUDIT_PASS.getAuditCode().equals(cmsDoc.getAuditStatus())) {
|
||||
if (isOpen) {
|
||||
updateVisits(cmsDocDto.getId());
|
||||
}
|
||||
return cmsDocDto;
|
||||
|
|
@ -186,21 +170,6 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
return cmsDocList.stream().map(CmsDoc::copyToCmsDocAllDto).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public GenericsTableDataInfo<CmsDocAllDto> selectAllDocList(Long deptId, CmsDocSearchVo cmsDocSearchVo) {
|
||||
List<CmsDocAllDto> list = selectCmsDocListByDept(deptId, cmsDocSearchVo);
|
||||
list.forEach(x -> {
|
||||
String docDetailUrl = getDocDetailUrl(x.getDeptId(), x.getId());
|
||||
x.setDocDetailUrl(docDetailUrl);
|
||||
|
||||
Boolean editable = isCmsDocEditable(x);
|
||||
x.setEditable(editable);
|
||||
|
||||
});
|
||||
int count = selectCmsDocCountByDept(deptId, cmsDocSearchVo);
|
||||
return new GenericsTableDataInfo<>(list, Long.valueOf(count));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int selectCmsDocCountByDept(Long deptId, CmsDocSearchVo cmsDocSearchVo) {
|
||||
cmsDocSearchVo.setDeptId(deptId);
|
||||
|
|
@ -228,21 +197,20 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
@Override
|
||||
public void updateCmsDir(Long id, CmsDirUpdateVo cmsDirUpdateVo) {
|
||||
CmsDoc oldCmsDir = selectCmsDir(id);
|
||||
checkCmsLockStatus(oldCmsDir.getDeptId());
|
||||
//设置栏目排序
|
||||
setCmsSort(cmsDirUpdateVo.getOrder(), oldCmsDir, false, null);
|
||||
oldCmsDir.setHeadImg(cmsDirUpdateVo.getHeadImg());
|
||||
updateCmsCommonDatabase(oldCmsDir, CmsConstants.BRANCH_MASTER);
|
||||
CmsProject cmsProject = cmsProjectService.selectCmsProjectByDeptId(oldCmsDir.getDeptId());
|
||||
String newCmsDirName = cmsDirUpdateVo.getName();
|
||||
CmsDoc newCmsDir = oldCmsDir.copyToRenameCmsDir(cmsDirUpdateVo.getName());
|
||||
|
||||
if (StringUtils.isNotEmpty(newCmsDirName) && !newCmsDirName.equals(oldCmsDir.getName())) {
|
||||
CmsDoc cmsDir = cmsDocMapper.selectCmsDocDirByNameAndDeptId(newCmsDirName, oldCmsDir.getDeptId());
|
||||
if (StringUtils.isNotEmpty(newCmsDir.getName()) && !newCmsDir.getName().equals(oldCmsDir.getName())) {
|
||||
CmsDoc cmsDir = cmsDocMapper.selectCmsDocDirByNameAndDeptId(newCmsDir.getName(), oldCmsDir.getDeptId());
|
||||
if (cmsDir != null) {
|
||||
throw new ServiceException("栏目名称已存在,不允许进行重命名(新栏目名称[" + newCmsDirName + "])");
|
||||
throw new ServiceException("栏目名称已存在,不允许进行重命名(新栏目名称[" + newCmsDir.getName() + "])");
|
||||
}
|
||||
cmsAsyncService.asyncMoveFileToNewDir(cmsProject, oldCmsDir, newCmsDir);
|
||||
}
|
||||
// 异步修改栏目名称(将仓库内原文件夹下所有文章移动到新文件夹下)
|
||||
cmsAsyncService.asyncMoveFileToNewDir(cmsProject, oldCmsDir, newCmsDirName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -263,14 +231,14 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
@Override
|
||||
public List<CmsDocDetailDto> selectCmsDocDetailList(Long dirId) {
|
||||
List<CmsDocDetailDto> cmsDocDetailDtoList = new ArrayList<>();
|
||||
CmsDoc cmsDir = selectCmsDir(dirId);
|
||||
CmsDoc cmsDir = cmsDocMapper.selectCmsDocDirById(dirId);
|
||||
CmsProject cmsProject = cmsProjectService.selectCmsProjectByDeptId(cmsDir.getDeptId());
|
||||
CmsDocSearchVo cmsDocSearchVo = new CmsDocSearchVo();
|
||||
cmsDocSearchVo.setDirName(cmsDir.getName());
|
||||
cmsDocSearchVo.setDeptId(cmsDir.getDeptId());
|
||||
cmsDocSearchVo.setIsDir(false);
|
||||
List<CmsDoc> cmsDocList = cmsDocMapper.selectCmsDocListSetDefaultHeadImg(cmsDocSearchVo);
|
||||
List<CompletableFuture<CmsDocDetailDto>> futures = new ArrayList<>();
|
||||
List<CmsDoc> cmsDocList = cmsDocMapper.selectCmsDocList(cmsDocSearchVo);
|
||||
List<CompletableFuture<CmsDocDetailDto>> futures = new ArrayList();
|
||||
for (CmsDoc cmsDoc : cmsDocList) {
|
||||
CompletableFuture<CmsDocDetailDto> future = CompletableFuture.supplyAsync(() -> {
|
||||
CmsDocDetailDto cmsDocDetailDto = cmsDoc.copyToCmsDocDetailDto();
|
||||
|
|
@ -315,21 +283,6 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
return selectCmsDocListByDatabase(dirId, cmsDocSearchVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CmsDocBaseDto> selectSetDefaultHeadImgCmsDocList(Long dirId, CmsDocSearchVo cmsDocSearchVo) {
|
||||
return selectCmsDocListSetDefaultHeadImgByDatabase(dirId, cmsDocSearchVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CmsDoc> selectCmsDocAndDirListByDept(Long deptId) {
|
||||
return cmsDocMapper.selectCmsDocAndDirListByDept(deptId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCmsDocShaByPathAndDeptId(String sha, String filePath, Long deptId) {
|
||||
cmsDocMapper.updateCmsDocShaByPathAndDeptId(sha, filePath, deptId);
|
||||
}
|
||||
|
||||
private List<CmsDocBaseDto> selectCmsDocListByDatabase(Long dirId, CmsDocSearchVo cmsDocSearchVo) {
|
||||
CmsDoc cmsDocDir = selectCmsDir(dirId);
|
||||
|
||||
|
|
@ -342,25 +295,6 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
return cmsDocList.stream().map(CmsDoc::copyToCmsDocBaseDto).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置文章默认头图为栏目头图
|
||||
*
|
||||
* @param dirId 栏目id
|
||||
* @param cmsDocSearchVo 文章查询条件
|
||||
* @return 文章列表
|
||||
*/
|
||||
private List<CmsDocBaseDto> selectCmsDocListSetDefaultHeadImgByDatabase(Long dirId, CmsDocSearchVo cmsDocSearchVo) {
|
||||
CmsDoc cmsDocDir = selectCmsDir(dirId);
|
||||
|
||||
cmsDocSearchVo.setDeptId(cmsDocDir.getDeptId());
|
||||
cmsDocSearchVo.setDirName(cmsDocDir.getName());
|
||||
List<CmsDoc> cmsDocList = cmsDocMapper.selectCmsDocListSetDefaultHeadImg(cmsDocSearchVo);
|
||||
if (cmsDocList == null || cmsDocList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return cmsDocList.stream().map(CmsDoc::copyToCmsDocBaseDto).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查专区资讯是否处于锁定状态,若处于则抛出异常
|
||||
*
|
||||
|
|
@ -390,16 +324,12 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
checkCmsLockStatus(dirDoc.getDeptId());
|
||||
CmsDoc cmsDoc = cmsDocInputDto.toCmsDoc(dirDoc);
|
||||
|
||||
if (isNoAuditRequired(dirDoc.getDeptId()) || tokenService.hasDeptPerms(dirDoc.getDeptId(), UserConstants.CMS_PERMS_DOCS_AUDIT)) {
|
||||
if (isNoAuditRequired(dirDoc.getDeptId()) || isCurrentUserZoneAdmin(dirDoc.getDeptId())) {
|
||||
//文章自动置为审核通过状态值
|
||||
cmsDoc.setAuditStatus(DocAuditStatus.AUDIT_PASS.getAuditCode());
|
||||
boolean success = insertCommonCmsDoc(cmsDoc,
|
||||
"创建文章:" + StringUtils.truncateStringAndConcatenatingSpecifiedString(cmsDoc.getName(), 100, "..."),
|
||||
cmsDocInputDto.getContent());
|
||||
if (success) {
|
||||
// 自动审核通过时也需要增加积分
|
||||
cmsAsyncService.addPublishDocPointsAsync(cmsDoc.getDeptId(), cmsDoc.getCreateBy(), cmsDoc.getId(), cmsDoc.getName());
|
||||
}
|
||||
return success ? cmsDoc.getId().intValue() : null;
|
||||
} else {
|
||||
//创建临时分支,创建文件,创建PR
|
||||
|
|
@ -437,9 +367,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
public String getCmsDocFileContent(CmsProject cmsProject, CmsDoc cmsDoc) {
|
||||
String branchName = CmsConstants.BRANCH_MASTER;
|
||||
if (!DocAuditStatus.AUDIT_PASS.getAuditCode().equals(cmsDoc.getAuditStatus())) {
|
||||
if (StringUtils.isNotEmpty(cmsDoc.getAuditTmpBranchName())) {
|
||||
branchName = cmsDoc.getAuditTmpBranchName();
|
||||
}
|
||||
branchName = cmsDoc.getAuditTmpBranchName();
|
||||
}
|
||||
//当删除文章为文件夹时,判断该文件夹下是否存在文章,若存在需先删除所有文章
|
||||
JSONObject getSubEntriesResult = gitLinkRequestHelper.doGet(
|
||||
|
|
@ -459,34 +387,9 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean auditCmsDoc(Long docId, CmsDocAuditVo cmsDocAuditVo) {
|
||||
CmsDoc cmsDoc = cmsDocMapper.selectCmsDocById(docId);
|
||||
if (cmsDoc == null) {
|
||||
throw new ServiceException("该文章不存在");
|
||||
}
|
||||
checkCmsLockStatus(cmsDoc.getDeptId());
|
||||
CmsProject cmsProject = cmsProjectService.selectCmsProjectByDeptId(cmsDoc.getDeptId());
|
||||
|
||||
// 设置审核备注
|
||||
cmsDoc.setRemark(cmsDocAuditVo.getRemark());
|
||||
|
||||
if (cmsDocAuditVo.getPass() == 1) {
|
||||
// 处理非仓库改动的审核通过
|
||||
if (cmsDoc.getAuditType() != null
|
||||
&& cmsDoc.getAuditType().contains(DocAndZoneOperation.OPERATION_NON_REPO_UPDATE.getOperationCode())) {
|
||||
Long oldCmsDocId = Long.parseLong(cmsDoc.getAuditType().split("-")[1]);
|
||||
CmsDoc oldCmsDoc = cmsDocMapper.selectCmsDocById(oldCmsDocId);
|
||||
|
||||
// 用新文章的非仓库字段更新旧文章
|
||||
oldCmsDoc.setHeadImg(cmsDoc.getHeadImg());
|
||||
oldCmsDoc.setSummary(cmsDoc.getSummary());
|
||||
oldCmsDoc.setKeywords(cmsDoc.getKeywords());
|
||||
oldCmsDoc.setRemark(cmsDoc.getRemark());
|
||||
cmsDocMapper.updateCmsDoc(oldCmsDoc);
|
||||
|
||||
// 删除待审核记录
|
||||
cmsDocMapper.deleteCmsDocById(cmsDoc.getId());
|
||||
return true;
|
||||
}
|
||||
|
||||
//同意合并请求
|
||||
JSONObject result = mergePullRequestByGitLink(cmsProject, cmsDoc);
|
||||
if (result.containsKey(GitLinkConstants.STATUS_KEY)) {
|
||||
|
|
@ -508,16 +411,8 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
}
|
||||
}
|
||||
if (cmsDocAuditVo.getPass() == 0) {
|
||||
// 处理非仓库改动的审核拒绝
|
||||
if (cmsDoc.getAuditType().contains(DocAndZoneOperation.OPERATION_NON_REPO_UPDATE.getOperationCode())) {
|
||||
handleCmsDocWithNoPassByReedit(cmsDocAuditVo, cmsDoc, cmsProject);
|
||||
return true;
|
||||
}
|
||||
|
||||
//拒绝GitLink合并请求
|
||||
String gitLinkPullRequestNumber = cmsDoc.getAuditPrNumber().split("-")[0];
|
||||
JSONObject result = gitLinkRequestHelper.doPost(
|
||||
CmsGitLinkRequestUrl.REFUSE_MERGE_PULL_REQUEST(cmsProject, gitLinkPullRequestNumber), null);
|
||||
JSONObject result = refuseMergePullRequestByGitLink(cmsDoc, cmsProject);
|
||||
if (result.containsKey(GitLinkConstants.STATUS_KEY)) {
|
||||
//2.若拒绝GitLink合并请求操作返回正确的状态值,更新数据库
|
||||
if (result.getInteger(GitLinkConstants.STATUS_KEY).equals(1)) {
|
||||
|
|
@ -564,10 +459,8 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
if (cmsDocAuditVo.getReedit().equals(0)) {
|
||||
//删除待审核文章
|
||||
cmsDocMapper.deleteCmsDocById(cmsDoc.getId());
|
||||
// 删除分支(如果有)
|
||||
if (StringUtils.isNotEmpty(cmsDoc.getAuditTmpBranchName())) {
|
||||
gitLinkRequestHelper.doPost(CmsGitLinkRequestUrl.DELETE_BRANCH(cmsProject, cmsDoc.getAuditTmpBranchName()), null);
|
||||
}
|
||||
//删除分支
|
||||
gitLinkRequestHelper.doDelete(CmsGitLinkRequestUrl.DELETE_BRANCH(cmsProject, cmsDoc.getAuditTmpBranchName()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -579,7 +472,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
int success = deleteCmsDocDatabaseById(ids);
|
||||
if (success == ids.length) {
|
||||
//删除临时分支
|
||||
gitLinkRequestHelper.doPost(CmsGitLinkRequestUrl.DELETE_BRANCH(cmsProject, cmsDoc.getAuditTmpBranchName()), null);
|
||||
gitLinkRequestHelper.doDelete(CmsGitLinkRequestUrl.DELETE_BRANCH(cmsProject, cmsDoc.getAuditTmpBranchName()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -599,7 +492,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
int success = cmsDocMapper.deleteCmsDocById(newDocId);
|
||||
if (success > 0) {
|
||||
//删除临时分支
|
||||
gitLinkRequestHelper.doPost(CmsGitLinkRequestUrl.DELETE_BRANCH(cmsProject, cmsDoc.getAuditTmpBranchName()), null);
|
||||
gitLinkRequestHelper.doDelete(CmsGitLinkRequestUrl.DELETE_BRANCH(cmsProject, cmsDoc.getAuditTmpBranchName()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -613,13 +506,11 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
int success = cmsDocMapper.updateCmsDoc(cmsDoc);
|
||||
if (success > 0) {
|
||||
//删除临时分支
|
||||
gitLinkRequestHelper.doPost(CmsGitLinkRequestUrl.DELETE_BRANCH(cmsProject, cmsDoc.getAuditTmpBranchName()), null);
|
||||
gitLinkRequestHelper.doDelete(CmsGitLinkRequestUrl.DELETE_BRANCH(cmsProject, cmsDoc.getAuditTmpBranchName()));
|
||||
}
|
||||
|
||||
// 推送文章地址到搜索引擎
|
||||
cmsAsyncService.pushDocDataSearchEngine(cmsDoc);
|
||||
// 文章审核通过后,给作者增加积分(异步执行,不影响主事务)
|
||||
cmsAsyncService.addPublishDocPointsAsync(cmsDoc.getDeptId(), cmsDoc.getCreateBy(), cmsDoc.getId(), cmsDoc.getName());
|
||||
}
|
||||
|
||||
private JSONObject mergePullRequestByGitLink(CmsProject cmsProject, CmsDoc cmsDoc) {
|
||||
|
|
@ -634,6 +525,12 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
CmsGitLinkRequestUrl.MERGE_PULL_REQUEST(cmsProject, gitLinkPullRequestId), requestBody);
|
||||
}
|
||||
|
||||
private JSONObject refuseMergePullRequestByGitLink(CmsDoc cmsDoc, CmsProject cmsProject) {
|
||||
//1.调用gitlink拒绝合并请求接口
|
||||
return gitLinkRequestHelper.doPost(
|
||||
CmsGitLinkRequestUrl.REFUSE_MERGE_PULL_REQUEST(cmsProject, cmsDoc.getAuditPrNumber()), null);
|
||||
}
|
||||
|
||||
public static String sha1(String data) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA1");
|
||||
|
|
@ -655,7 +552,6 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
throw new ServiceException("计算字符串Sha出错");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCmsSort(Integer order, CmsDoc oldCmsDoc, boolean isChangeOnDir, String isHomePage) {
|
||||
//调整文章/栏目顺序
|
||||
|
|
@ -775,47 +671,11 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long updateCmsDoc(Long id, CmsDocDto cmsDocDto) {
|
||||
public boolean updateCmsDoc(Long id, CmsDocDto cmsDocDto) {
|
||||
CmsDoc oldCmsDoc = cmsDocMapper.selectCmsDocById(id);
|
||||
checkCmsLockStatus(oldCmsDoc.getDeptId());
|
||||
if (!hasRepoRelatedChanged(oldCmsDoc, cmsDocDto)) {
|
||||
// 更新非仓库字段到原文章对象
|
||||
if (StringUtils.isNotEmpty(cmsDocDto.getHeadImg())) {
|
||||
oldCmsDoc.setHeadImg(cmsDocDto.getHeadImg());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(cmsDocDto.getSummary())) {
|
||||
oldCmsDoc.setSummary(cmsDocDto.getSummary());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(cmsDocDto.getKeywords())) {
|
||||
oldCmsDoc.setKeywords(cmsDocDto.getKeywords());
|
||||
}
|
||||
|
||||
// 管理员或免审核:直接更新原记录
|
||||
if (tokenService.hasDeptPerms(oldCmsDoc.getDeptId(), UserConstants.CMS_PERMS_DOCS_AUDIT)
|
||||
|| isNoAuditRequired(oldCmsDoc.getDeptId())) {
|
||||
cmsDocMapper.updateCmsDoc(oldCmsDoc);
|
||||
return oldCmsDoc.getId();
|
||||
}
|
||||
|
||||
// 需要审核:创建新的待审核记录(与仓库改动逻辑一致)
|
||||
if (oldCmsDoc.getAuditStatus().equals(DocAuditStatus.AUDIT_PASS.getAuditCode())) {
|
||||
CmsDoc newDocWithAudit = insertDocWithAudit(oldCmsDoc,
|
||||
DocAndZoneOperation.OPERATION_NON_REPO_UPDATE.getOperationCode() + "-" + oldCmsDoc.getId(),
|
||||
DocAuditStatus.TO_BE_AUDIT.getAuditCode());
|
||||
return newDocWithAudit.getId();
|
||||
}
|
||||
oldCmsDoc.setAuditStatus(DocAuditStatus.TO_BE_AUDIT.getAuditCode());
|
||||
if (oldCmsDoc.getAuditType().contains(DocAndZoneOperation.OPERATION_CREATE.getOperationCode())
|
||||
|| oldCmsDoc.getAuditType().contains(DocAndZoneOperation.OPERATION_UPDATE.getOperationCode())) {
|
||||
CmsProject cmsProject = cmsProjectService.selectCmsProjectByDeptId(oldCmsDoc.getDeptId());
|
||||
// 重新开启PR
|
||||
String gitLinkPullRequestNumber = oldCmsDoc.getAuditPrNumber().split("-")[0];
|
||||
gitLinkRequestHelper.doPost(CmsGitLinkRequestUrl.REOPEN_PULL_REQUEST(cmsProject, gitLinkPullRequestNumber), null);
|
||||
}
|
||||
// 待审核/未通过文章重新编辑
|
||||
cmsDocMapper.updateCmsDoc(oldCmsDoc);
|
||||
return oldCmsDoc.getId();
|
||||
return cmsDocMapper.updateCmsDoc(oldCmsDoc) > 0;
|
||||
}
|
||||
// 当文章名称发生更改时,判断文章名是否在当前栏目下已存在
|
||||
if (StringUtils.isNotEmpty(cmsDocDto.getName()) && !cmsDocDto.getName().equals(oldCmsDoc.getName())) {
|
||||
|
|
@ -828,16 +688,8 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
}
|
||||
checkDocName(cmsDocDto.getName(), oldCmsDoc.getDeptId(), dirName);
|
||||
}
|
||||
|
||||
// 当用户更新栏目时,需检查新栏目下是否已存在相同文章名
|
||||
if (cmsDocDto.getDirId() != null) {
|
||||
CmsDir cmsDir = selectCmsDirById(cmsDocDto.getDirId(), false);
|
||||
if (cmsDir != null && !cmsDir.getName().equals(oldCmsDoc.getDirName())) {
|
||||
checkDocName(cmsDocDto.getName(), oldCmsDoc.getDeptId(), cmsDir.getName());
|
||||
}
|
||||
}
|
||||
//用户为专区管理员或专区无审核机制时,直接更新文章及仓库主分支
|
||||
if (tokenService.hasDeptPerms(oldCmsDoc.getDeptId(), UserConstants.CMS_PERMS_DOCS_AUDIT) || isNoAuditRequired(oldCmsDoc.getDeptId())) {
|
||||
if (isCurrentUserZoneAdmin(oldCmsDoc.getDeptId()) || isNoAuditRequired(oldCmsDoc.getDeptId())) {
|
||||
//专区管理员重新编辑并提交审核未通过文章 或 重新编辑并提交待审核文章时专区不需审核机制
|
||||
if (!oldCmsDoc.getAuditStatus().equals(DocAuditStatus.AUDIT_PASS.getAuditCode())) {
|
||||
//文章审核类型:update-原文章id 取出原文章id直接更新,删除待审核更新类型文章
|
||||
|
|
@ -845,15 +697,14 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
Long originCmsDocId = Long.parseLong(oldCmsDoc.getAuditType().split("-")[1]);
|
||||
CmsDoc originCmsDoc = cmsDocMapper.selectCmsDocById(originCmsDocId);
|
||||
deleteTmpBranchIfBranchExist(oldCmsDoc);
|
||||
BeanUtils.copyProperties(originCmsDoc, oldCmsDoc);
|
||||
BeanUtils.copyProperties(originCmsDoc,oldCmsDoc);
|
||||
cmsDocMapper.deleteCmsDocById(id);
|
||||
} else
|
||||
//文章审核类型:create 直接新增文章
|
||||
if (oldCmsDoc.getAuditType() != null && oldCmsDoc.getAuditType().contains(DocAndZoneOperation.OPERATION_CREATE.getOperationCode())) {
|
||||
deleteTmpBranchIfBranchExist(oldCmsDoc);
|
||||
cmsDocMapper.deleteCmsDocById(id);
|
||||
directlyInsertAuditedCmsDocWhenZoneHasNoAuditRequired(cmsDocDto, oldCmsDoc);
|
||||
return oldCmsDoc.getId();
|
||||
return directlyInsertAuditedCmsDocWhenZoneHasNoAuditRequired(cmsDocDto, oldCmsDoc);
|
||||
}
|
||||
}
|
||||
String branchName = CmsConstants.BRANCH_MASTER;
|
||||
|
|
@ -861,62 +712,25 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
oldCmsDoc.setAuditStatus(DocAuditStatus.AUDIT_PASS.getAuditCode());
|
||||
oldCmsDoc.setAuditTmpBranchName(null);
|
||||
oldCmsDoc.setKeywords(cmsDocDto.getKeywords());
|
||||
updateCmsCommonDatabase(oldCmsDoc, CmsConstants.BRANCH_MASTER);
|
||||
return oldCmsDoc.getId();
|
||||
return updateCmsCommonDatabase(oldCmsDoc, CmsConstants.BRANCH_MASTER) > 0;
|
||||
} else {
|
||||
|
||||
CmsDoc newDocWithAudit = new CmsDoc();
|
||||
//待审核、未通过文章重新编辑并提交
|
||||
if (DocAuditStatus.AUDIT_FAIL.getAuditCode().equals(oldCmsDoc.getAuditStatus())
|
||||
|| DocAuditStatus.TO_BE_AUDIT.getAuditCode().equals(oldCmsDoc.getAuditStatus())) {
|
||||
|
||||
// 非仓库改动待审核记录:检查是否有仓库改动
|
||||
if (oldCmsDoc.getAuditType() != null
|
||||
&& oldCmsDoc.getAuditType().contains(DocAndZoneOperation.OPERATION_NON_REPO_UPDATE.getOperationCode())) {
|
||||
|
||||
if (!hasRepoRelatedChanged(oldCmsDoc, cmsDocDto)) {
|
||||
// 纯非仓库改动:继续在当前记录上更新
|
||||
oldCmsDoc.setAuditStatus(DocAuditStatus.TO_BE_AUDIT.getAuditCode());
|
||||
if (StringUtils.isNotEmpty(cmsDocDto.getHeadImg())) {
|
||||
oldCmsDoc.setHeadImg(cmsDocDto.getHeadImg());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(cmsDocDto.getSummary())) {
|
||||
oldCmsDoc.setSummary(cmsDocDto.getSummary());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(cmsDocDto.getKeywords())) {
|
||||
oldCmsDoc.setKeywords(cmsDocDto.getKeywords());
|
||||
}
|
||||
cmsDocMapper.updateCmsDoc(oldCmsDoc);
|
||||
return oldCmsDoc.getId();
|
||||
} else {
|
||||
// 有仓库改动:转为仓库改动类型,删除当前记录,重新创建
|
||||
Long oldCmsDocId = Long.parseLong(oldCmsDoc.getAuditType().split("-")[1]);
|
||||
CmsDoc originCmsDoc = cmsDocMapper.selectCmsDocById(oldCmsDocId);
|
||||
cmsDocMapper.deleteCmsDocById(oldCmsDoc.getId());
|
||||
|
||||
// 按照仓库改动逻辑重新创建
|
||||
newDocWithAudit = insertDocWithAudit(originCmsDoc,
|
||||
DocAndZoneOperation.OPERATION_UPDATE.getOperationCode() + "-" + oldCmsDocId,
|
||||
DocAuditStatus.TO_BE_AUDIT.getAuditCode());
|
||||
cmsAsyncService.asyncUpdateBranchAndFileAndCreatePR(newDocWithAudit, cmsDocDto);
|
||||
return newDocWithAudit.getId();
|
||||
}
|
||||
}
|
||||
|
||||
// 仓库改动待审核记录:继续在当前记录上更新
|
||||
oldCmsDoc.setAuditStatus(DocAuditStatus.TO_BE_AUDIT.getAuditCode());
|
||||
newDocWithAudit = oldCmsDoc;
|
||||
} else {
|
||||
} else
|
||||
//更新已发布文章
|
||||
if (oldCmsDoc.getAuditStatus().equals(DocAuditStatus.AUDIT_PASS.getAuditCode())) {
|
||||
//1.创建一条auditType="update-原文章id",audit_status为2,其余字段与待更新文章一致的新文章数据
|
||||
newDocWithAudit = insertDocWithAudit(oldCmsDoc,
|
||||
DocAndZoneOperation.OPERATION_UPDATE.getOperationCode() + "-" + id,
|
||||
DocAuditStatus.TO_BE_AUDIT.getAuditCode());
|
||||
}
|
||||
//1.创建一条auditType="update-原文章id",audit_status为2,其余字段与待更新文章一致的新文章数据
|
||||
newDocWithAudit = insertDocWithAudit(oldCmsDoc,
|
||||
DocAndZoneOperation.OPERATION_UPDATE.getOperationCode() + "-" + id,
|
||||
DocAuditStatus.TO_BE_AUDIT.getAuditCode());
|
||||
}
|
||||
cmsAsyncService.asyncUpdateBranchAndFileAndCreatePR(newDocWithAudit, cmsDocDto);
|
||||
return newDocWithAudit.getId();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -968,10 +782,10 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
private void deleteTmpBranchIfBranchExist(CmsDoc cmsDoc) {
|
||||
CmsProject cmsProject = cmsProjectService.selectCmsProjectByDeptId(cmsDoc.getDeptId());
|
||||
try {
|
||||
gitLinkRequestHelper.doPost(CmsGitLinkRequestUrl.DELETE_BRANCH(cmsProject, cmsDoc.getAuditTmpBranchName()), null);
|
||||
gitLinkRequestHelper.doDelete(CmsGitLinkRequestUrl.DELETE_BRANCH(cmsProject, cmsDoc.getAuditTmpBranchName()));
|
||||
} catch (ServiceException e) {
|
||||
//忽略分支不存在异常
|
||||
if (!"分支不存在!".equals(e.getMessage())) {
|
||||
if(!"分支不存在!".equals(e.getMessage())) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -999,29 +813,15 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
}
|
||||
|
||||
private CmsDoc insertDocWithAudit(CmsDoc oldCmsDoc, String auditType, String auditStatus) {
|
||||
List<CmsDoc> tmpDocList = getTmpDocList(oldCmsDoc);
|
||||
if (!tmpDocList.isEmpty()) {
|
||||
throw new ServiceException("已存在待审核操作,请等待审核完成后再进行操作");
|
||||
}
|
||||
oldCmsDoc.setId(null);
|
||||
oldCmsDoc.setAuditType(auditType);
|
||||
oldCmsDoc.setAuditStatus(auditStatus);
|
||||
oldCmsDoc.setCreateBy(SecurityUtils.getUsername());
|
||||
|
||||
// 非 repo 改动:显式设置 auditTmpBranchName 为 null(没有对应的分支)
|
||||
if (auditType != null && auditType.contains(DocAndZoneOperation.OPERATION_NON_REPO_UPDATE.getOperationCode())) {
|
||||
oldCmsDoc.setAuditTmpBranchName(null);
|
||||
}
|
||||
|
||||
cmsDocMapper.insertCmsDoc(oldCmsDoc);
|
||||
return oldCmsDoc;
|
||||
}
|
||||
|
||||
private CmsDoc insertDeletedDocWithAudit(CmsDoc oldCmsDoc, Long oldCmsDocId) {
|
||||
List<CmsDoc> tmpDocList = getTmpDocList(oldCmsDoc);
|
||||
if (!tmpDocList.isEmpty()) {
|
||||
throw new ServiceException("已存在待审核操作,请等待审核完成后再进行操作");
|
||||
}
|
||||
oldCmsDoc.setId(null);
|
||||
oldCmsDoc.setAuditType(DocAndZoneOperation.OPERATION_DELETE.getOperationCode() + "-" + oldCmsDocId);
|
||||
oldCmsDoc.setAuditStatus(DocAuditStatus.TO_BE_AUDIT.getAuditCode());
|
||||
|
|
@ -1063,7 +863,6 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
cmsDoc.setIsDir(true);
|
||||
cmsDoc.setFilePath(cmsDoc.getDirPath(cmsDir.getName()));
|
||||
cmsDoc.setDeptId(deptId);
|
||||
cmsDoc.setHeadImg(cmsDir.getHeadImg());
|
||||
cmsDoc.setName(cmsDir.getName());
|
||||
return insertCommonCmsDoc(cmsDoc, "创建栏目:" + cmsDir.getName(), "");
|
||||
}
|
||||
|
|
@ -1150,7 +949,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
List<CmsDoc> cmsDocList = cmsDocMapper.selectHotCmsDocList(cmsDocInput);
|
||||
if (cmsDocList != null) {
|
||||
//todo:需检查该文章是否在GitLink中存在
|
||||
return cmsDocList.stream().map(CmsDoc::copyToHotCmsDocDto).collect(Collectors.toList());
|
||||
return cmsDocList.stream().map(x -> x.copyToHotCmsDocDto()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
return new ArrayList<>();
|
||||
|
|
@ -1167,13 +966,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
visits = visits + cmsDoc.getVisits();
|
||||
}
|
||||
cmsDoc.setVisits(visits);
|
||||
int rows = cmsDocMapper.updateCmsDoc(cmsDoc);
|
||||
if (rows > 0) {
|
||||
cmsAsyncService.addVisitsDocPointsAsync(cmsDoc.getDeptId(), cmsDoc.getCreateBy(),
|
||||
cmsDoc.getId(), cmsDoc.getName(), cmsDoc.getVisits());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return cmsDocMapper.updateCmsDoc(cmsDoc) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1197,7 +990,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
for (CmsDoc cmsDir : cmsDirList) {
|
||||
CmsDocSearchVo cmsDocSearchVo = new CmsDocSearchVo();
|
||||
cmsDocSearchVo.setIsOpen(isOpen);
|
||||
List<CmsDocBaseDto> cmsDocBaseDtoList = selectSetDefaultHeadImgCmsDocList(cmsDir.getId(), cmsDocSearchVo);
|
||||
List<CmsDocBaseDto> cmsDocBaseDtoList = selectCmsDocList(cmsDir.getId(), cmsDocSearchVo);
|
||||
CmsDocOverviewDto cmsDocOverviewDto = new CmsDocOverviewDto();
|
||||
cmsDocOverviewDto.setId(cmsDir.getId());
|
||||
cmsDocOverviewDto.setName(cmsDir.getName());
|
||||
|
|
@ -1297,9 +1090,6 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
//首页推荐时,需将顺序设置为1
|
||||
setCmsSort(1, cmsDoc, false, null);
|
||||
cmsDoc.setIsHomepage(CmsConstants.TRUE);
|
||||
// 文章被设为精选,异步增加作者积分
|
||||
cmsAsyncService.addFeaturedDocPointsAsync(cmsDoc.getDeptId(), cmsDoc.getCreateBy(),
|
||||
cmsDoc.getId(), cmsDoc.getName());
|
||||
}
|
||||
return cmsDocMapper.updateCmsDoc(cmsDoc);
|
||||
}
|
||||
|
|
@ -1314,7 +1104,7 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
CmsDocSearchVo cmsDocSearch = new CmsDocSearchVo();
|
||||
cmsDocSearch.setDeptId(deptId);
|
||||
cmsDocSearch.setIsHomepage(CmsConstants.TRUE);
|
||||
List<CmsDoc> cmsDocList = cmsDocMapper.selectCmsDocListSetDefaultHeadImg(cmsDocSearch);
|
||||
List<CmsDoc> cmsDocList = cmsDocMapper.selectCmsDocList(cmsDocSearch);
|
||||
List<CmsDocBaseDto> cmsDocBaseDtoList = new ArrayList<>();
|
||||
for (CmsDoc cmsDoc : cmsDocList) {
|
||||
CmsDocBaseDto cmsDocBaseDto = cmsDoc.copyToCmsDocBaseDto();
|
||||
|
|
@ -1323,41 +1113,6 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
return cmsDocBaseDtoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CmsDocBaseDto> selectHomePageDocMergeList(Long zoneId, List<Long> topDocIds) {
|
||||
Long deptId = getDeptIdByZoneId(zoneId);
|
||||
Set<Long> addedDocIds = new HashSet<>();
|
||||
|
||||
// 1. 获取首页推荐文章列表
|
||||
List<CmsDocBaseDto> homePageDocs = selectHomePageDocList(deptId);
|
||||
List<CmsDocBaseDto> result = new ArrayList<>();
|
||||
|
||||
// 2. 批量查询置顶文章完整数据,按传入顺序放入结果头部
|
||||
if (topDocIds != null && !topDocIds.isEmpty()) {
|
||||
List<CmsDoc> topCmsDocs = cmsDocMapper.selectCmsDocByIds(topDocIds);
|
||||
Map<Long, CmsDoc> topDocMap = new HashMap<>();
|
||||
for (CmsDoc doc : topCmsDocs) {
|
||||
topDocMap.put(doc.getId(), doc);
|
||||
}
|
||||
for (Long docId : topDocIds) {
|
||||
CmsDoc doc = topDocMap.get(docId);
|
||||
if (doc != null) {
|
||||
result.add(doc.copyToCmsDocBaseDto());
|
||||
addedDocIds.add(docId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 追加首页推荐文章(跳过已在置顶列表中的)
|
||||
for (CmsDocBaseDto doc : homePageDocs) {
|
||||
if (!addedDocIds.contains(doc.getId())) {
|
||||
result.add(doc);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CmsDir initCmsDir(Long deptId, CmsDir cmsDirInput) {
|
||||
|
|
@ -1504,17 +1259,6 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
cmsAsyncService.updateCmsPublishDataByGitLink(cmsProject, cmsDoc, branchName);
|
||||
}
|
||||
|
||||
private int deleteCmsDir(CmsProject cmsProject, CmsDoc cmsDir) {
|
||||
if (!isNoAuditRequired(cmsDir.getDeptId()) || tokenService.hasDeptPerms(cmsDir.getDeptId(), UserConstants.CMS_PERMS_DOCS_AUDIT)) {
|
||||
boolean deleteResult = cmsAsyncService.deleteCmsDocForGitLink(cmsDir, cmsProject, CmsConstants.BRANCH_MASTER);
|
||||
if (deleteResult) {
|
||||
return cmsDocMapper.deleteCmsDocById(cmsDir.getId());
|
||||
}
|
||||
throw new ServiceException("栏目删除失败");
|
||||
}
|
||||
throw new ServiceException("无权限删除栏目");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteCmsDocById(Long id) {
|
||||
CmsDoc cmsDoc = cmsDocMapper.selectCmsDocById(id);
|
||||
|
|
@ -1524,42 +1268,22 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
checkCmsLockStatus(cmsDoc.getDeptId());
|
||||
//2、获取专区项目
|
||||
CmsProject cmsProject = cmsProjectService.selectCmsProjectByDeptId(cmsDoc.getDeptId());
|
||||
if (cmsDoc.getIsDir()) {
|
||||
return deleteCmsDir(cmsProject, cmsDoc);
|
||||
}
|
||||
|
||||
//删除待审核、审核未通过文章——删除临时分支,拒绝合并请求
|
||||
if (DocAuditStatus.TO_BE_AUDIT.getAuditCode().equals(cmsDoc.getAuditStatus())) {
|
||||
// 非仓库改动类型直接删除
|
||||
if (cmsDoc.getAuditType().contains(DocAndZoneOperation.OPERATION_NON_REPO_UPDATE.getOperationCode())) {
|
||||
return cmsDocMapper.deleteCmsDocById(cmsDoc.getId());
|
||||
}
|
||||
|
||||
//拒绝GitLink合并请求
|
||||
String gitLinkPullRequestNumber = cmsDoc.getAuditPrNumber().split("-")[0];
|
||||
gitLinkRequestHelper.doPost(
|
||||
CmsGitLinkRequestUrl.REFUSE_MERGE_PULL_REQUEST(cmsProject, gitLinkPullRequestNumber), null);
|
||||
gitLinkRequestHelper.doPost(CmsGitLinkRequestUrl.DELETE_BRANCH(cmsProject, cmsDoc.getAuditTmpBranchName()), null);
|
||||
return cmsDocMapper.deleteCmsDocById(cmsDoc.getId());
|
||||
if (DocAuditStatus.TO_BE_AUDIT.getAuditCode().equals(cmsDoc.getAuditStatus())
|
||||
|| DocAuditStatus.AUDIT_FAIL.getAuditCode().equals(cmsDoc.getAuditStatus())) {
|
||||
gitLinkRequestHelper.doDelete(CmsGitLinkRequestUrl.DELETE_BRANCH(cmsProject, cmsDoc.getAuditTmpBranchName()));
|
||||
cmsDocMapper.deleteCmsDocById(id);
|
||||
return 1;
|
||||
}
|
||||
if (DocAuditStatus.AUDIT_FAIL.getAuditCode().equals(cmsDoc.getAuditStatus())) {
|
||||
return cmsDocMapper.deleteCmsDocById(cmsDoc.getId());
|
||||
}
|
||||
// 判读当前用户是否拥有文章直接删除权限
|
||||
if (tokenService.hasDeptPerms(cmsDoc.getDeptId(), UserConstants.CMS_PERMS_DOCS_AUDIT) //当前用户为专区管理员
|
||||
if (isCurrentUserZoneAdmin(cmsDoc.getDeptId()) //当前用户为专区管理员
|
||||
|| isNoAuditRequired(cmsDoc.getDeptId()) //当前专区文章发布无需审核机制
|
||||
) {
|
||||
String branchName = CmsConstants.BRANCH_MASTER;
|
||||
boolean deleteResult = cmsAsyncService.deleteCmsDocForGitLink(cmsDoc, cmsProject, branchName);
|
||||
if (deleteResult) {
|
||||
// 拒绝相关合并请求并清理所有临时分支,同时删除所有临时申请
|
||||
List<CmsDoc> tmpDocList = getTmpDocList(cmsDoc);
|
||||
cmsAsyncService.clearTmpDoc(cmsProject, tmpDocList);
|
||||
cmsDoc.setAuditStatus(DocAuditStatus.AUDIT_FAIL.getAuditCode());
|
||||
cmsDoc.setRemark("管理员删除");
|
||||
return cmsDocMapper.updateCmsDoc(cmsDoc);
|
||||
return deleteCmsDocDatabaseById(cmsDoc.getId());
|
||||
}
|
||||
|
||||
} else {
|
||||
//1.创建一条auditType="delete-原文章id",audit_status=2,其余字段与待删除文章一致的新文章数据
|
||||
CmsDoc newDocWithAudit = insertDeletedDocWithAudit(cmsDoc, id);
|
||||
|
|
@ -1569,18 +1293,6 @@ public class CmsDocServiceImpl implements ICmsDocService {
|
|||
throw new ServiceException("文件删除失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CmsDoc> getTmpDocList(CmsDoc cmsDoc) {
|
||||
CmsDocSearchVo cmsDocSearchVo = new CmsDocSearchVo();
|
||||
cmsDocSearchVo.setName(cmsDoc.getName());
|
||||
cmsDocSearchVo.setDeptId(cmsDoc.getDeptId());
|
||||
cmsDocSearchVo.setIsDir(false);
|
||||
cmsDocSearchVo.setDirName(cmsDoc.getDirName());
|
||||
cmsDocSearchVo.setAuditStatus(DocAuditStatus.TO_BE_AUDIT.getAuditCode());
|
||||
// 拒绝相关合并请求并清理所有临时分支,同时删除所有临时申请
|
||||
return cmsDocMapper.selectCmsDocList(cmsDocSearchVo);
|
||||
}
|
||||
|
||||
public int deleteCmsDocDatabaseById(Long id) {
|
||||
CmsDoc cmsDoc = cmsDocMapper.selectCmsDocById(id);
|
||||
if (cmsDoc != null && !cmsDoc.getIsDir()) {
|
||||
|
|
|
|||
|
|
@ -49,16 +49,6 @@ public class CmsProjectController extends BaseController {
|
|||
return R.ok(changeRoleResult);
|
||||
}
|
||||
|
||||
@InnerAuth
|
||||
@PutMapping("/changeOrgRole/user/{userId}/operate/{operate}")
|
||||
@ApiOperation(value = "修改用户所在GItLink组织中的权限", hidden = true)
|
||||
public R<Boolean> changeUserOrgRole(@PathVariable("userId") Long userId, @PathVariable("operate") Long operate
|
||||
) {
|
||||
Boolean changeRoleResult = cmsProjectService.changeUserOrgRole(userId, operate);
|
||||
return R.ok(changeRoleResult);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询专区对应项目列表
|
||||
*/
|
||||
|
|
@ -105,12 +95,8 @@ public class CmsProjectController extends BaseController {
|
|||
@GetMapping("/getProjectByDeptId/{deptId}")
|
||||
public R<String> getProjectByDeptId(
|
||||
@ApiParam(name = "deptId", value = "组织Id") @PathVariable(value = "deptId") Long deptId) {
|
||||
CmsProject cmsProject = cmsProjectService.selectCmsProjectByDeptIdAndNoException(deptId);
|
||||
if (cmsProject == null) {
|
||||
return R.ok(null);
|
||||
} else {
|
||||
return R.ok(JSONObject.toJSONString(cmsProject));
|
||||
}
|
||||
CmsProject cmsProject = cmsProjectService.selectCmsProjectByDeptId(deptId);
|
||||
return R.ok(JSONObject.toJSONString(cmsProject));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -184,16 +170,4 @@ public class CmsProjectController extends BaseController {
|
|||
public R<Boolean> removeByDeptId(@PathVariable(value = "deptId") Long deptId) {
|
||||
return R.ok(cmsProjectService.deleteCmsProjectByDeptId(deptId) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化专区对应项目
|
||||
*/
|
||||
@RequiresPermissions("zone:project:add")
|
||||
@ApiOperation("初始化专区对应项目")
|
||||
@Log(title = "初始化专区对应项目", businessType = BusinessType.INSERT)
|
||||
@PostMapping("initCmsProject/dept/{deptId}")
|
||||
public AjaxResult initCmsProject(
|
||||
@ApiParam(name = "deptId", value = "组织Id") @PathVariable(value = "deptId") Long deptId) {
|
||||
return toAjax(cmsProjectService.initZoneCmsProjectByDept(deptId));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
package com.microservices.cms.project.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author otto
|
||||
*/
|
||||
@Data
|
||||
public class GitlinkOrganizationTeamVo implements Serializable {
|
||||
@ApiModelProperty(value = "团队权限")
|
||||
private String authorize;
|
||||
@ApiModelProperty(value = "团队Id")
|
||||
private Long id;
|
||||
@ApiModelProperty(value = "团队名称")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "团队昵称")
|
||||
private String nickname;
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@ package com.microservices.cms.project.mapper;
|
|||
|
||||
import com.microservices.cms.project.domain.CmsProject;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -65,25 +64,4 @@ public interface CmsProjectMapper {
|
|||
CmsProject selectCmsProjectByDeptId(Long deptId);
|
||||
|
||||
CmsProject selectCmsProjectByIdentifier(String identifier);
|
||||
|
||||
/**
|
||||
* 全局搜索 - 全文索引查询
|
||||
*
|
||||
* @param keyword 搜索关键词
|
||||
* @param deptId 组织ID(可选)
|
||||
* @param offset 偏移量
|
||||
* @param pageSize 每页数量
|
||||
* @return 搜索结果列表
|
||||
*/
|
||||
List<CmsProject> globalSearch(@Param("keyword") String keyword, @Param("deptId") Long deptId,
|
||||
@Param("offset") int offset, @Param("pageSize") int pageSize);
|
||||
|
||||
/**
|
||||
* 全局搜索结果计数
|
||||
*
|
||||
* @param keyword 搜索关键词
|
||||
* @param deptId 组织ID(可选)
|
||||
* @return 结果数量
|
||||
*/
|
||||
Long globalSearchCount(@Param("keyword") String keyword, @Param("deptId") Long deptId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,10 +78,4 @@ public interface ICmsProjectService {
|
|||
Boolean updateCmsProjectByDept(SysDept dept);
|
||||
|
||||
boolean operateProtectedBranchByZoneAuditSetting(String userName, String identifier, Long deptId, String operationType);
|
||||
|
||||
boolean initZoneCmsProjectByDept(Long deptId);
|
||||
|
||||
CmsProject selectCmsProjectByDeptIdAndNoException(Long deptId);
|
||||
|
||||
Boolean changeUserOrgRole(Long userId, Long operate);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,21 @@
|
|||
package com.microservices.cms.project.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.cms.doc.domain.*;
|
||||
import com.microservices.cms.doc.domain.CmsDir;
|
||||
import com.microservices.cms.doc.domain.CmsDocBaseDto;
|
||||
import com.microservices.cms.doc.domain.CmsDocSearchVo;
|
||||
import com.microservices.cms.doc.service.ICmsAsyncService;
|
||||
import com.microservices.cms.doc.service.ICmsDocService;
|
||||
import com.microservices.cms.project.domain.CmsProject;
|
||||
import com.microservices.cms.project.domain.GitlinkOrganizationTeamVo;
|
||||
import com.microservices.cms.project.mapper.CmsProjectMapper;
|
||||
import com.microservices.cms.project.service.ICmsProjectService;
|
||||
import com.microservices.cms.utils.CmsConstants;
|
||||
import com.microservices.cms.utils.CmsGitLinkRequestUrl;
|
||||
import com.microservices.common.core.constant.HttpStatus;
|
||||
import com.microservices.common.core.constant.SecurityConstants;
|
||||
import com.microservices.common.core.enums.SystemRole;
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.common.core.utils.PinYinStringUtils;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.datascope.annotation.DataScope;
|
||||
import com.microservices.common.httpClient.domain.GitLinkRequestUrl;
|
||||
import com.microservices.common.httpClient.util.GitLinkRequestHelper;
|
||||
import com.microservices.system.api.RemoteDeptService;
|
||||
import com.microservices.system.api.RemoteUserService;
|
||||
|
|
@ -26,7 +23,6 @@ import com.microservices.system.api.domain.SysDept;
|
|||
import com.microservices.system.api.domain.SysRole;
|
||||
import com.microservices.system.api.domain.SysUser;
|
||||
import com.microservices.system.api.utils.FeignUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
|
@ -41,7 +37,6 @@ import java.util.List;
|
|||
* @author otto
|
||||
* @date 2023-03-27
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CmsProjectServiceImpl implements ICmsProjectService {
|
||||
@Autowired
|
||||
|
|
@ -233,75 +228,6 @@ public class CmsProjectServiceImpl implements ICmsProjectService {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initZoneCmsProjectByDept(Long deptId) {
|
||||
boolean initResult = false;
|
||||
CmsProject cmsProject = cmsProjectMapper.selectCmsProjectByDeptId(deptId);
|
||||
if (cmsProject != null) {
|
||||
JSONObject project = null;
|
||||
try {
|
||||
project = gitLinkRequestHelper.doGet(CmsGitLinkRequestUrl.GET_PROJECT_DETAIL(cmsProject.getUsername(), cmsProject.getIdentifier()));
|
||||
} catch (ServiceException e) {
|
||||
if (!e.getCode().equals(HttpStatus.NOT_FOUND)) {
|
||||
throw new ServiceException(e.getCode(), e.getMessage());
|
||||
}
|
||||
}
|
||||
if (project != null) {
|
||||
throw new ServiceException("专区对应项目已存在,不能重复初始化");
|
||||
} else {
|
||||
Long organizationId = getOrganizationId();
|
||||
// 创建专区对应项目
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("user_id", organizationId);
|
||||
jsonObject.put("name", cmsProject.getName());
|
||||
jsonObject.put("repository_name", cmsProject.getIdentifier());
|
||||
jsonObject.put("description", cmsProject.getDescription());
|
||||
jsonObject.put("private", false);
|
||||
//调用GitLink接口创建项目
|
||||
JSONObject result = gitLinkRequestHelper.doPost(CmsGitLinkRequestUrl.CREATE_PROJECT(), jsonObject);
|
||||
initResult = result != null && cmsProject.getIdentifier().equals(result.getString("identifier"));
|
||||
}
|
||||
} else {
|
||||
Long projectId = insertZoneCmsProjectByDept(deptId);
|
||||
if (projectId != null && projectId > 0) {
|
||||
cmsProject = cmsProjectMapper.selectCmsProjectById(projectId);
|
||||
initResult = true;
|
||||
}
|
||||
}
|
||||
if (initResult) {
|
||||
// 批量创建文章对应代码库文件
|
||||
List<CmsDoc> cmsDocAndDirList = cmsDocService.selectCmsDocAndDirListByDept(deptId);
|
||||
if (cmsDocAndDirList == null || cmsDocAndDirList.isEmpty()) {
|
||||
return initResult;
|
||||
}
|
||||
JSONObject docCommitJson = new JSONObject();
|
||||
docCommitJson.put("branch", CmsConstants.BRANCH_MASTER);
|
||||
docCommitJson.put("message", "初始化专区文章对应代码库文件");
|
||||
JSONArray docFiles = new JSONArray();
|
||||
for (CmsDoc cmsDoc : cmsDocAndDirList) {
|
||||
JSONObject docFile = new JSONObject();
|
||||
docFile.put("action_type", "create");
|
||||
docFile.put("content", "");
|
||||
docFile.put("encoding", "text");
|
||||
docFile.put("file_path", cmsDoc.getFilePath());
|
||||
docFiles.add(docFile);
|
||||
}
|
||||
docCommitJson.put("files", docFiles);
|
||||
JSONObject result = gitLinkRequestHelper.doPost(
|
||||
CmsGitLinkRequestUrl.BATCH_COMMIT(cmsProject.getUsername(), cmsProject.getIdentifier())
|
||||
, docCommitJson);
|
||||
if (result == null) {
|
||||
throw new ServiceException("专区对应项目初始化成功,但专区文章在项目中创建失败");
|
||||
}
|
||||
JSONArray resultContents = result.getJSONArray("contents");
|
||||
for (int i = 0; i < resultContents.size(); i++) {
|
||||
JSONObject contentJson = resultContents.getJSONObject(i);
|
||||
cmsDocService.updateCmsDocShaByPathAndDeptId(contentJson.getString("sha"), contentJson.getString("path"), deptId);
|
||||
}
|
||||
}
|
||||
return initResult;
|
||||
}
|
||||
|
||||
|
||||
private String handleSpecialCharacters(String name) {
|
||||
return StringUtils.replace(name, " ", "-");
|
||||
|
|
@ -316,45 +242,6 @@ public class CmsProjectServiceImpl implements ICmsProjectService {
|
|||
return cmsProject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CmsProject selectCmsProjectByDeptIdAndNoException(Long deptId) {
|
||||
return cmsProjectMapper.selectCmsProjectByDeptId(deptId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean changeUserOrgRole(Long userId, Long operate) {
|
||||
Long gitlinkOrgId = getOrganizationId();
|
||||
SysUser sysUser = FeignUtils.getReturnData(remoteUserService.getSysUserByUserId(userId, SecurityConstants.INNER));
|
||||
if (sysUser == null) {
|
||||
return false;
|
||||
}
|
||||
List<GitlinkOrganizationTeamVo> gitlinkOrganizationTeamVoList = gitLinkRequestHelper.getAllDataByPage(
|
||||
CmsGitLinkRequestUrl.TEAMS_BY_ORGANIZATION_URL(gitlinkOrgId), "teams", GitlinkOrganizationTeamVo.class
|
||||
);
|
||||
GitlinkOrganizationTeamVo ownerTeam = gitlinkOrganizationTeamVoList.stream().filter(x -> "owner".equals(x.getAuthorize())).findFirst().orElse(null);
|
||||
if (ownerTeam == null) {
|
||||
return false;
|
||||
}
|
||||
if (operate == 1) {
|
||||
JSONObject addUserToTeam = new JSONObject();
|
||||
addUserToTeam.put("username", sysUser.getUserName());
|
||||
gitLinkRequestHelper.doPost(
|
||||
CmsGitLinkRequestUrl.ADD_USER_TO_ORGANIZATION_TEAM(gitLinkOrganization, ownerTeam.getId()), addUserToTeam);
|
||||
}
|
||||
if (operate == 3) {
|
||||
try {
|
||||
gitLinkRequestHelper.doDelete(CmsGitLinkRequestUrl.DELETE_USER_FROM_ORGANIZATION_TEAM(
|
||||
gitLinkOrganization,
|
||||
ownerTeam.getId(),
|
||||
sysUser.getUserName()
|
||||
));
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean changeUserRole(Long userId, Long oldDeptId, Long newDeptId, Long oldRoleId, Long newRoleId) {
|
||||
SysUser sysUser = FeignUtils.getReturnData(remoteUserService.getSysUserByUserId(userId, SecurityConstants.INNER));
|
||||
|
|
@ -373,10 +260,9 @@ public class CmsProjectServiceImpl implements ICmsProjectService {
|
|||
try {
|
||||
gitLinkRequestHelper.doDelete(CmsGitLinkRequestUrl.REMOVE_USER_FROM_PROJECT(oldCmsProject), requestBody);
|
||||
} catch (ServiceException e) {
|
||||
log.error("将用户从原项目中移除发生异常:{}", e.getMessage());
|
||||
// if (!e.getMessage().contains("用户为组织成员,请到组织下操作")||!e.getMessage().contains("还不是项目成员")) {
|
||||
// throw new ServiceException(e.getMessage());
|
||||
// }
|
||||
if (!e.getMessage().contains("用户为组织成员,请到组织下操作")) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
//将用户加入新的项目
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
package com.microservices.cms.search.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文章搜索请求对象
|
||||
*
|
||||
* @author microservices
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("文章搜索请求对象")
|
||||
public class DocSearchRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 搜索关键词
|
||||
*/
|
||||
@ApiModelProperty(value = "搜索关键词", required = true)
|
||||
private String keyword;
|
||||
|
||||
/**
|
||||
* 专区ID
|
||||
*/
|
||||
@ApiModelProperty(value = "专区ID")
|
||||
private Long zoneId;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
@ApiModelProperty(value = "页码")
|
||||
private Integer pageNum = 1;
|
||||
|
||||
/**
|
||||
* 每页数量
|
||||
*/
|
||||
@ApiModelProperty(value = "每页数量")
|
||||
private Integer pageSize = 20;
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
package com.microservices.cms.search.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 全局搜索响应对象
|
||||
*
|
||||
* @author microservices
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("文章搜索响应对象")
|
||||
public class DocSearchResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 总结果数
|
||||
*/
|
||||
@ApiModelProperty(value = "总结果数")
|
||||
private Long total;
|
||||
|
||||
/**
|
||||
* 搜索结果列表
|
||||
*/
|
||||
@ApiModelProperty(value = "搜索结果列表")
|
||||
private List<DocSearchResult> results;
|
||||
|
||||
/**
|
||||
* 各类型结果数量统计
|
||||
*/
|
||||
@ApiModelProperty(value = "各类型结果数量统计")
|
||||
private Map<String, Long> typeCounts;
|
||||
|
||||
/**
|
||||
* 搜索耗时(毫秒)
|
||||
*/
|
||||
@ApiModelProperty(value = "搜索耗时(毫秒)")
|
||||
private Long searchTime;
|
||||
|
||||
/**
|
||||
* 搜索关键词
|
||||
*/
|
||||
@ApiModelProperty(value = "搜索关键词")
|
||||
private String keyword;
|
||||
|
||||
/**
|
||||
* 当前页码
|
||||
*/
|
||||
@ApiModelProperty(value = "当前页码")
|
||||
private Integer pageNum;
|
||||
|
||||
/**
|
||||
* 每页数量
|
||||
*/
|
||||
@ApiModelProperty(value = "每页数量")
|
||||
private Integer pageSize;
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
package com.microservices.cms.search.dto;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 文章搜索结果对象
|
||||
*
|
||||
* @author microservices
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("文章搜索结果对象")
|
||||
public class DocSearchResult implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@ApiModelProperty(value = "ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@ApiModelProperty(value = "标题")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 内容摘要
|
||||
*/
|
||||
@ApiModelProperty(value = "内容摘要")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 组织ID
|
||||
*/
|
||||
@ApiModelProperty(value = "组织ID")
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 相关度评分
|
||||
*/
|
||||
@ApiModelProperty(value = "相关度评分")
|
||||
private Double score;
|
||||
|
||||
/**
|
||||
* 扩展数据(JSON格式)
|
||||
*/
|
||||
@ApiModelProperty(value = "扩展数据")
|
||||
private JSONObject extendData;
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package com.microservices.cms.search.service;
|
||||
|
||||
import com.microservices.cms.search.dto.DocSearchRequest;
|
||||
import com.microservices.cms.search.dto.DocSearchResponse;
|
||||
|
||||
/**
|
||||
* 全局搜索服务接口
|
||||
*
|
||||
* @author microservices
|
||||
*/
|
||||
public interface IGlobalSearchService {
|
||||
|
||||
/**
|
||||
* 全局搜索
|
||||
*
|
||||
* @param request 搜索请求
|
||||
* @return 搜索响应
|
||||
*/
|
||||
DocSearchResponse docSearch(DocSearchRequest request);
|
||||
}
|
||||
|
|
@ -1,215 +0,0 @@
|
|||
package com.microservices.cms.search.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.microservices.cms.doc.domain.CmsDoc;
|
||||
import com.microservices.cms.doc.domain.CmsDocWithScore;
|
||||
import com.microservices.cms.doc.mapper.CmsDocMapper;
|
||||
import com.microservices.cms.doc.service.ICmsDocService;
|
||||
import com.microservices.cms.search.service.IGlobalSearchService;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.redis.service.RedisService;
|
||||
import com.microservices.cms.search.dto.DocSearchRequest;
|
||||
import com.microservices.cms.search.dto.DocSearchResponse;
|
||||
import com.microservices.cms.search.dto.DocSearchResult;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.system.api.model.LoginUser;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 全局搜索服务实现
|
||||
*
|
||||
* @author microservices
|
||||
*/
|
||||
@Service
|
||||
public class GlobalSearchServiceImpl implements IGlobalSearchService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(GlobalSearchServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private CmsDocMapper cmsDocMapper;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
@Autowired
|
||||
private ICmsDocService cmsDocService;
|
||||
|
||||
private static final String SEARCH_CACHE_PREFIX = "search:cache:";
|
||||
private static final Long CACHE_EXPIRE_SECONDS = 300L; // 5分钟
|
||||
|
||||
@Override
|
||||
public DocSearchResponse docSearch(DocSearchRequest request) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
// 参数校验
|
||||
if (StringUtils.isEmpty(request.getKeyword())) {
|
||||
return buildEmptyResponse(request);
|
||||
}
|
||||
|
||||
// 1. 尝试从缓存获取(仅第一页)
|
||||
if (request.getPageNum() == 1) {
|
||||
String cacheKey = buildCacheKey(request);
|
||||
|
||||
DocSearchResponse cached = redisService.getCacheObject(SEARCH_CACHE_PREFIX + cacheKey);
|
||||
if (cached != null) {
|
||||
cached.setSearchTime(System.currentTimeMillis() - startTime);
|
||||
return cached;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 并行搜索各类型
|
||||
List<DocSearchResult> allResults = new ArrayList<>();
|
||||
Map<String, Long> typeCounts = new HashMap<>();
|
||||
|
||||
// 获取当前用户信息
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
|
||||
// 搜索CMS文章
|
||||
List<DocSearchResult> docResults = searchDocs(request);
|
||||
allResults.addAll(docResults);
|
||||
typeCounts.put("doc", (long) docResults.size());
|
||||
|
||||
// 3. 按相关度评分排序
|
||||
allResults.sort((a, b) -> {
|
||||
if (b.getScore() != null && a.getScore() != null) {
|
||||
return b.getScore().compareTo(a.getScore());
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
// 4. 分页
|
||||
int total = allResults.size();
|
||||
int start = (request.getPageNum() - 1) * request.getPageSize();
|
||||
int end = Math.min(start + request.getPageSize(), total);
|
||||
List<DocSearchResult> pagedResults = start < total ?
|
||||
allResults.subList(start, end) : new ArrayList<>();
|
||||
|
||||
// 5. 构建响应
|
||||
DocSearchResponse response = new DocSearchResponse();
|
||||
response.setTotal((long) total);
|
||||
response.setResults(pagedResults);
|
||||
response.setTypeCounts(typeCounts);
|
||||
response.setKeyword(request.getKeyword());
|
||||
response.setPageNum(request.getPageNum());
|
||||
response.setPageSize(request.getPageSize());
|
||||
response.setSearchTime(System.currentTimeMillis() - startTime);
|
||||
|
||||
// 6. 缓存结果(仅第一页)
|
||||
if (request.getPageNum() == 1) {
|
||||
String cacheKey = buildCacheKey(request);
|
||||
redisService.setCacheObject(SEARCH_CACHE_PREFIX + cacheKey, response, CACHE_EXPIRE_SECONDS, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
// 7. 记录搜索日志
|
||||
recordSearchLog(request, response, loginUser);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录搜索日志
|
||||
*/
|
||||
private void recordSearchLog(DocSearchRequest request, DocSearchResponse response, LoginUser loginUser) {
|
||||
Long userId = loginUser != null ? loginUser.getUserId() : null;
|
||||
String searchTypes = "文章";
|
||||
Long deptId = cmsDocService.getDeptIdByZoneId(request.getZoneId());
|
||||
logger.info("全局搜索 - 关键词: {}, 用户ID: {}, 耗时: {}ms, 结果数: {}, 类型: {}, 专区Id: {}, 组织ID: {}",
|
||||
request.getKeyword(),
|
||||
userId,
|
||||
response.getSearchTime(),
|
||||
response.getTotal(),
|
||||
searchTypes,
|
||||
request.getZoneId(),
|
||||
deptId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索CMS文章
|
||||
*/
|
||||
private List<DocSearchResult> searchDocs(DocSearchRequest request) {
|
||||
List<DocSearchResult> results = new ArrayList<>();
|
||||
try {
|
||||
// 使用部门ID参数
|
||||
Long deptId = cmsDocService.getDeptIdByZoneId(request.getZoneId());
|
||||
|
||||
// 使用新的带评分的查询方法
|
||||
List<CmsDocWithScore> docs = cmsDocMapper.globalSearchWithScore(
|
||||
request.getKeyword(),
|
||||
deptId,
|
||||
(request.getPageNum() - 1) * request.getPageSize(),
|
||||
request.getPageSize()
|
||||
);
|
||||
|
||||
for (CmsDocWithScore doc : docs) {
|
||||
DocSearchResult result = new DocSearchResult();
|
||||
result.setId(doc.getId());
|
||||
result.setTitle(highlightKeyword(doc.getName(), request.getKeyword()));
|
||||
result.setContent(highlightKeyword(doc.getSummary(), request.getKeyword()));
|
||||
result.setDeptId(doc.getDeptId());
|
||||
result.setCreateTime(doc.getCreateTime());
|
||||
|
||||
// 使用数据库返回的实际搜索评分
|
||||
Double score = doc.getSearchScore();
|
||||
if (score == null || score == 0.0) {
|
||||
// 对于 LIKE 匹配(无全文评分),赋予最小评分
|
||||
score = 0.1;
|
||||
}
|
||||
result.setScore(score);
|
||||
|
||||
JSONObject extendData = new JSONObject();
|
||||
extendData.put("visits", doc.getVisits());
|
||||
extendData.put("publishTime", doc.getPublishTime());
|
||||
result.setExtendData(extendData);
|
||||
results.add(result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 记录错误但继续处理其他类型
|
||||
System.err.println("搜索CMS文章失败: " + e.getMessage());
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建缓存键
|
||||
*/
|
||||
private String buildCacheKey(DocSearchRequest request) {
|
||||
Long deptId = cmsDocService.getDeptIdByZoneId(request.getZoneId());
|
||||
StringBuilder key = new StringBuilder(request.getKeyword());
|
||||
key.append(":").append(String.join(",", "Doc"));
|
||||
if (deptId != null) {
|
||||
key.append(":dept=").append(deptId);
|
||||
}
|
||||
return key.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建空响应
|
||||
*/
|
||||
private DocSearchResponse buildEmptyResponse(DocSearchRequest request) {
|
||||
DocSearchResponse response = new DocSearchResponse();
|
||||
response.setTotal(0L);
|
||||
response.setResults(new ArrayList<>());
|
||||
response.setTypeCounts(new HashMap<>());
|
||||
response.setKeyword(request.getKeyword());
|
||||
response.setPageNum(request.getPageNum());
|
||||
response.setPageSize(request.getPageSize());
|
||||
response.setSearchTime(0L);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将文本中的关键词用 <em> 标签包裹(不区分大小写)
|
||||
*/
|
||||
private String highlightKeyword(String text, String keyword) {
|
||||
if (StringUtils.isEmpty(text) || StringUtils.isEmpty(keyword)) {
|
||||
return text;
|
||||
}
|
||||
return text.replaceAll("(?i)(" + Pattern.quote(keyword) + ")", "<em>$1</em>");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.microservices.cms.service.impl;
|
||||
package com.microservices.cms.common.service.impl;
|
||||
|
||||
import com.microservices.cms.common.service.ISysUserService;
|
||||
import com.microservices.common.core.constant.SecurityConstants;
|
||||
|
|
|
|||
|
|
@ -25,24 +25,4 @@ public class CmsConstants {
|
|||
* 是
|
||||
*/
|
||||
public final static String TRUE = "1";
|
||||
|
||||
/**
|
||||
* 专区积分异步队列 Redis Key(与 Zone 模块保持一致)
|
||||
*/
|
||||
public final static String ZONE_POINTS_ASYNC_QUEUE_KEY = "zone:points:async:queue";
|
||||
|
||||
/**
|
||||
* 发布文章积分类型
|
||||
*/
|
||||
public final static String PUBLISH_DOC = "publishDoc";
|
||||
|
||||
/**
|
||||
* 浏览文章积分类型
|
||||
*/
|
||||
public final static String VISITS_DOC = "visitsDoc";
|
||||
|
||||
/**
|
||||
* 精选文章积分类型
|
||||
*/
|
||||
public final static String FEATURED_DOC = "featuredDoc";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,18 +12,6 @@ import java.util.Map;
|
|||
|
||||
public class CmsGitLinkRequestUrl extends GitLinkRequestUrl {
|
||||
|
||||
public static GitLinkRequestUrl ADD_USER_TO_ORGANIZATION_TEAM(String orgIdentifier, Long teamId) {
|
||||
return getAdminGitLinkRequestUrl(String.format("/api/organizations/%s/teams/%d/team_users.json", orgIdentifier, teamId));
|
||||
}
|
||||
|
||||
public static String TEAMS_BY_ORGANIZATION_URL(Long orgId) {
|
||||
return String.format("/api/organizations/%s/teams.json", orgId);
|
||||
}
|
||||
|
||||
public static GitLinkRequestUrl DELETE_USER_FROM_ORGANIZATION_TEAM(String orgIdentifier, Long teamId, String username) {
|
||||
return getAdminGitLinkRequestUrl(String.format("/api/organizations/%s/teams/%d/team_users/%s.json", orgIdentifier, teamId, username));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建项目
|
||||
*/
|
||||
|
|
@ -78,7 +66,7 @@ public class CmsGitLinkRequestUrl extends GitLinkRequestUrl {
|
|||
|
||||
public static GitLinkRequestUrl DELETE_BRANCH(CmsProject cmsProject, String branchName) {
|
||||
return getGitLinkRequestUrl(
|
||||
String.format("/api/v1/%s/%s/branches/delete.json?branch_name=%s", cmsProject.getUsername(), cmsProject.getIdentifier(), branchName)
|
||||
String.format("/api/v1/%s/%s/branches/%s.json", cmsProject.getUsername(), cmsProject.getIdentifier(), branchName)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -88,12 +76,6 @@ public class CmsGitLinkRequestUrl extends GitLinkRequestUrl {
|
|||
);
|
||||
}
|
||||
|
||||
public static GitLinkRequestUrl REOPEN_PULL_REQUEST(CmsProject cmsProject, String giteaPrNumber) {
|
||||
return getGitLinkRequestUrl(
|
||||
String.format("/api/v1/%s/%s/pulls/%s/reopen", cmsProject.getUsername(), cmsProject.getIdentifier(), giteaPrNumber)
|
||||
);
|
||||
}
|
||||
|
||||
public static GitLinkRequestUrl GET_PULL_REQUEST_DETAILS(CmsProject cmsProject, String giteaPrNumber) {
|
||||
return getGitLinkRequestUrl(
|
||||
String.format("/api/%s/%s/pulls/%s.json", cmsProject.getUsername(), cmsProject.getIdentifier(), giteaPrNumber)
|
||||
|
|
@ -119,7 +101,7 @@ public class CmsGitLinkRequestUrl extends GitLinkRequestUrl {
|
|||
}
|
||||
|
||||
public static GitLinkRequestUrl ADD_USER_FROM_PROJECT(CmsProject cmsProject) {
|
||||
return getAdminGitLinkRequestUrl(
|
||||
return getGitLinkRequestUrl(
|
||||
String.format("/api/%s/%s/collaborators.json", cmsProject.getUsername(), cmsProject.getIdentifier())
|
||||
);
|
||||
}
|
||||
|
|
@ -166,19 +148,19 @@ public class CmsGitLinkRequestUrl extends GitLinkRequestUrl {
|
|||
);
|
||||
}
|
||||
|
||||
public static GitLinkRequestUrl CREATE_PROTECTED_BRANCHES(String username, String identifier, Map<String, String> params, List<String> pushWhitelistUsernames) throws URISyntaxException {
|
||||
public static GitLinkRequestUrl CREATE_PROTECTED_BRANCHES(String username, String identifier, Map<String,String> params, List<String> pushWhitelistUsernames) throws URISyntaxException {
|
||||
String path = buildUri(String.format("/api/%s/%s/protected_branches.json", username, identifier), params);
|
||||
path = concatenateParametersAfterUrl(path, "push_whitelist_usernames[]", pushWhitelistUsernames);
|
||||
return getGitLinkRequestUrl(path);
|
||||
}
|
||||
|
||||
public static GitLinkRequestUrl UPDATE_PROTECTED_BRANCHES(String username, String identifier, Map<String, String> params, List<String> pushWhitelistUsernames) throws URISyntaxException {
|
||||
public static GitLinkRequestUrl UPDATE_PROTECTED_BRANCHES(String username, String identifier, Map<String,String> params, List<String> pushWhitelistUsernames) throws URISyntaxException {
|
||||
String path = buildUri(String.format("/api/%s/%s/protected_branches/master.json", username, identifier), params);
|
||||
path = concatenateParametersAfterUrl(path, "push_whitelist_usernames[]", pushWhitelistUsernames);
|
||||
return getGitLinkRequestUrl(path);
|
||||
}
|
||||
|
||||
public static GitLinkRequestUrl DELETE_PROTECTED_BRANCHES(String username, String identifier, Map<String, String> params, List<String> pushWhitelistUsernames) throws URISyntaxException {
|
||||
public static GitLinkRequestUrl DELETE_PROTECTED_BRANCHES(String username, String identifier, Map<String,String> params, List<String> pushWhitelistUsernames) throws URISyntaxException {
|
||||
String path = buildUri(String.format("/api/%s/%s/protected_branches/master.json", username, identifier), params);
|
||||
path = concatenateParametersAfterUrl(path, "push_whitelist_usernames[]", pushWhitelistUsernames);
|
||||
return getGitLinkRequestUrl(path);
|
||||
|
|
@ -215,12 +197,4 @@ public class CmsGitLinkRequestUrl extends GitLinkRequestUrl {
|
|||
public static String ZONE_DOC_URL(String gitlinkUrl, String zoneKey, Long docId) {
|
||||
return EscapeUtil.removeExtraSlashOfUrl(String.format("%s/zone/%s/newdetail/%d", gitlinkUrl, zoneKey, docId));
|
||||
}
|
||||
|
||||
public static GitLinkRequestUrl GET_PROJECT_DETAIL(String username, String identifier) {
|
||||
return getAdminGitLinkRequestUrl(String.format("/api/%s/%s/detail.json", username, identifier));
|
||||
}
|
||||
|
||||
public static GitLinkRequestUrl BATCH_COMMIT(String username, String identifier) {
|
||||
return getAdminGitLinkRequestUrl(String.format("/api/v1/%s/%s/contents/batch.json", username, identifier));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
package com.microservices.cms.utils;
|
||||
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.common.core.threadPool.ThreadPoolExecutorWrap;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 线程池工厂
|
||||
*
|
||||
* @author OTTO
|
||||
*/
|
||||
public class CustomExecutorFactory {
|
||||
/**
|
||||
* 创建线程池
|
||||
* 存在并发处理的情况,设置核心线程为2,设置有界队列长度为100,最大线程数为10
|
||||
* 当超出队列已满且达到最大线程数时抛出异常
|
||||
* Ncpu=CPU数量
|
||||
* Ucpu=目标CPU的使用率,0<=Ucpu<=1
|
||||
* W/C=任务等待时间与任务计算时间的比率
|
||||
* Nthreads =Ncpu*Ucpu*(1+W/C)
|
||||
*/
|
||||
public static ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutorWrap(
|
||||
5
|
||||
, 10
|
||||
, 10
|
||||
, TimeUnit.SECONDS
|
||||
, new ArrayBlockingQueue<>(100)
|
||||
, Executors.defaultThreadFactory()
|
||||
, (r, executor) -> {
|
||||
throw new ServiceException("目前处理的人太多了,请稍后再试");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -37,7 +37,6 @@
|
|||
<result property="auditTmpBranchName" column="audit_tmp_branch_name"/>
|
||||
<result property="auditPrNumber" column="audit_pr_number"/>
|
||||
<result property="keywords" column="keywords"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectCmsDocVo">
|
||||
|
|
@ -72,8 +71,7 @@
|
|||
audit_type,
|
||||
audit_tmp_branch_name,
|
||||
keywords,
|
||||
audit_pr_number,
|
||||
remark
|
||||
audit_pr_number
|
||||
from cms_doc
|
||||
</sql>
|
||||
|
||||
|
|
@ -105,103 +103,10 @@
|
|||
cd.is_homepage,
|
||||
cd.editor_type,
|
||||
cd.keywords,
|
||||
cd.is_dir,
|
||||
cd.audit_status,
|
||||
cd.audit_type,
|
||||
cd.audit_tmp_branch_name,
|
||||
cd.audit_pr_number,
|
||||
cd.remark
|
||||
cd.is_dir
|
||||
from cms_doc cd
|
||||
</sql>
|
||||
|
||||
<sql id="selectCmsDocWithScoreVo">
|
||||
select cd.id,
|
||||
cd.create_by,
|
||||
cd.create_time,
|
||||
cd.update_by,
|
||||
cd.update_time,
|
||||
cd.name,
|
||||
cd.file_name,
|
||||
cd.file_path,
|
||||
cd.file_sha,
|
||||
cd.file_size,
|
||||
cd.file_url,
|
||||
cd.html_url,
|
||||
cd.visits,
|
||||
cd.sort,
|
||||
cd.publish_time,
|
||||
cd.publish_user,
|
||||
cd.publish_user_image,
|
||||
cd.publish_user_url,
|
||||
cd.publish_user_nickname,
|
||||
cd.summary,
|
||||
cd.head_img,
|
||||
cd.dir_name,
|
||||
cd.dept_id,
|
||||
cd.issue_id,
|
||||
cd.is_homepage,
|
||||
cd.editor_type,
|
||||
cd.keywords,
|
||||
cd.is_dir,
|
||||
cd.audit_status,
|
||||
cd.audit_type,
|
||||
cd.audit_tmp_branch_name,
|
||||
cd.audit_pr_number,
|
||||
-- 计算全文搜索相关度评分
|
||||
MATCH(cd.name, cd.summary) AGAINST(#{keyword} IN NATURAL LANGUAGE MODE) AS search_score,
|
||||
cd.remark
|
||||
from cms_doc cd
|
||||
</sql>
|
||||
|
||||
<sql id="selectCmsDocAliasSetDefaultHeadImgVo">
|
||||
select cd.id,
|
||||
cd.create_by,
|
||||
cd.create_time,
|
||||
cd.update_by,
|
||||
cd.update_time,
|
||||
cd.name,
|
||||
cd.file_name,
|
||||
cd.file_path,
|
||||
cd.file_sha,
|
||||
cd.file_size,
|
||||
cd.file_url,
|
||||
cd.html_url,
|
||||
cd.visits,
|
||||
cd.sort,
|
||||
cd.publish_time,
|
||||
cd.publish_user,
|
||||
cd.publish_user_image,
|
||||
cd.publish_user_url,
|
||||
cd.publish_user_nickname,
|
||||
cd.summary,
|
||||
-- 处理文章和栏目头图为NULL或空字符串的情况
|
||||
CASE
|
||||
-- 文章头图不为空(非NULL且非空字符串)
|
||||
WHEN cd.head_img IS NOT NULL AND TRIM(cd.head_img) != '' THEN cd.head_img
|
||||
-- 栏目存在且头图不为空
|
||||
WHEN dir.head_img IS NOT NULL AND TRIM(dir.head_img) != '' THEN dir.head_img
|
||||
END AS head_img,
|
||||
cd.dir_name,
|
||||
cd.dept_id,
|
||||
cd.issue_id,
|
||||
cd.is_homepage,
|
||||
cd.editor_type,
|
||||
cd.keywords,
|
||||
cd.is_dir,
|
||||
cd.audit_status,
|
||||
cd.audit_type,
|
||||
cd.audit_tmp_branch_name,
|
||||
cd.audit_pr_number,
|
||||
cd.remark
|
||||
from cms_doc cd
|
||||
left join cms_doc dir on cd.dir_name = dir.name and cd.dept_id = dir.dept_id and dir.is_dir=1
|
||||
</sql>
|
||||
|
||||
<select id="selectCmsDocAndDirListByDept" resultMap="CmsDocResult">
|
||||
<include refid="selectCmsDocVo"/>
|
||||
where dept_id=#{deptId}
|
||||
</select>
|
||||
|
||||
<select id="selectCmsDocList" parameterType="com.microservices.cms.doc.domain.CmsDocSearchVo"
|
||||
resultMap="CmsDocResult">
|
||||
<include refid="selectCmsDocVo"/>
|
||||
|
|
@ -217,20 +122,10 @@
|
|||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectCmsDocByIds" resultMap="CmsDocResult">
|
||||
<include refid="selectCmsDocVo"/>
|
||||
where id in
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
and audit_status = '1'
|
||||
</select>
|
||||
|
||||
<select id="selectCmsDocByNameAndDeptId" resultMap="CmsDocResult">
|
||||
<include refid="selectCmsDocVo"/>
|
||||
<where>
|
||||
and name = #{name}
|
||||
and audit_status != 0
|
||||
and dept_id = #{deptId}
|
||||
<choose>
|
||||
<when test="dirName != null">
|
||||
|
|
@ -242,10 +137,6 @@
|
|||
</choose>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectCmsDocByNameAndDeptIdIgnoreDirName" resultMap="CmsDocResult">
|
||||
<include refid="selectCmsDocVo"/>
|
||||
where name = #{name} and dept_id = #{deptId} and is_dir = 0
|
||||
</select>
|
||||
<select id="selectCmsDocDirByNameAndDeptId" resultMap="CmsDocResult">
|
||||
<include refid="selectCmsDocVo"/>
|
||||
where name = #{name} and dept_id = #{deptId} and is_dir = 1
|
||||
|
|
@ -259,13 +150,13 @@
|
|||
where file_path = #{filePath} and dept_id = #{deptId} and is_dir = 0
|
||||
</select>
|
||||
<select id="selectHotCmsDocList" parameterType="com.microservices.cms.doc.domain.CmsDoc" resultMap="CmsDocResult">
|
||||
<include refid="selectCmsDocAliasSetDefaultHeadImgVo"/>
|
||||
<include refid="selectListWhereAlias"/>
|
||||
<include refid="selectCmsDocVo"/>
|
||||
<include refid="selectListWhere"/>
|
||||
ORDER BY
|
||||
cd.visits DESC,
|
||||
cd.sort DESC,
|
||||
cd.update_time DESC,
|
||||
cd.create_time DESC
|
||||
visits DESC,
|
||||
sort DESC,
|
||||
update_time DESC,
|
||||
create_time DESC
|
||||
|
||||
</select>
|
||||
<select id="selectCmsDocCount" resultType="java.lang.Integer">
|
||||
|
|
@ -286,24 +177,6 @@
|
|||
<if test="auditStatus != null and auditStatus != '-1' ">and audit_status = #{auditStatus}</if>
|
||||
<if test="auditStatus == null ">and audit_status = '1'</if>
|
||||
<if test="createBy != null and createBy != '' ">and create_by = #{createBy}</if>
|
||||
<if test="excludeId != null ">and id != #{excludeId}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<sql id="selectListWhereAlias">
|
||||
<where>
|
||||
<if test="name != null and name != ''">and cd.name like concat('%', #{name}, '%')</if>
|
||||
<if test="keywords != null and keywords != ''">and cd.keywords like concat('%', #{keywords}, '%')</if>
|
||||
<if test="fileName != null and fileName != ''">and cd.file_name like concat('%', #{fileName}, '%')</if>
|
||||
<if test="filePath != null and filePath != ''">and cd.file_path = #{filePath}</if>
|
||||
<if test="publishTime != null ">and cd.publish_time = #{publishTime}</if>
|
||||
<if test="isDir != null ">and cd.is_dir = #{isDir}</if>
|
||||
<if test="dirName != null ">and cd.dir_name = #{dirName}</if>
|
||||
<if test="deptId != null ">and cd.dept_id = #{deptId}</if>
|
||||
<if test="isHomepage != null ">and cd.is_homepage = #{isHomepage}</if>
|
||||
<if test="auditStatus != null and auditStatus != '-1' ">and cd.audit_status = #{auditStatus}</if>
|
||||
<if test="auditStatus == null ">and cd.audit_status = '1'</if>
|
||||
<if test="createBy != null and createBy != '' ">and cd.create_by = #{createBy}</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
|
|
@ -410,15 +283,6 @@
|
|||
from cms_doc
|
||||
where dept_id = #{deptId};
|
||||
</select>
|
||||
<select id="selectCmsDocListSetDefaultHeadImg" parameterType="com.microservices.cms.doc.domain.CmsDocSearchVo"
|
||||
resultMap="CmsDocResult">
|
||||
<include refid="selectCmsDocAliasSetDefaultHeadImgVo"/>
|
||||
<include refid="selectListWhereAlias"/>
|
||||
ORDER BY
|
||||
cd.sort DESC,
|
||||
cd.update_time DESC,
|
||||
cd.create_time DESC
|
||||
</select>
|
||||
|
||||
<insert id="insertCmsDoc" parameterType="com.microservices.cms.doc.domain.CmsDoc" useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
|
|
@ -524,7 +388,6 @@
|
|||
<if test="auditTmpBranchName != null">audit_tmp_branch_name = #{auditTmpBranchName},</if>
|
||||
<if test="auditPrNumber != null">audit_pr_number = #{auditPrNumber},</if>
|
||||
<if test="keywords != null">keywords = #{keywords},</if>
|
||||
<if test="remark != null">remark = #{remark},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
|
@ -542,12 +405,6 @@
|
|||
and dept_id = #{deptId}
|
||||
and is_dir = #{isDir};
|
||||
</update>
|
||||
<update id="updateCmsDocShaByPathAndDeptId">
|
||||
update cms_doc
|
||||
set file_sha=#{sha}
|
||||
where file_path=#{filePath}
|
||||
and dept_id=#{deptId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteCmsDocById" parameterType="Long">
|
||||
delete
|
||||
|
|
@ -561,70 +418,4 @@
|
|||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 全局搜索 - 全文索引查询(含 LIKE 后备搜索) -->
|
||||
<select id="globalSearch" resultMap="CmsDocResult">
|
||||
<include refid="selectCmsDocAliasVo"/>
|
||||
WHERE
|
||||
cd.is_dir = 0
|
||||
AND cd.audit_status = '1'
|
||||
AND (
|
||||
MATCH(cd.name, cd.summary) AGAINST(#{keyword} IN BOOLEAN MODE)
|
||||
OR cd.name LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR cd.summary LIKE CONCAT('%', #{keyword}, '%')
|
||||
)
|
||||
<if test="deptId != null">
|
||||
AND cd.dept_id = #{deptId}
|
||||
</if>
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN MATCH(cd.name, cd.summary) AGAINST(#{keyword} IN BOOLEAN MODE) > 0 THEN 1
|
||||
ELSE 2
|
||||
END,
|
||||
cd.update_time DESC
|
||||
LIMIT #{offset}, #{pageSize}
|
||||
</select>
|
||||
|
||||
<select id="globalSearchCount" resultType="java.lang.Long">
|
||||
SELECT COUNT(*)
|
||||
FROM cms_doc cd
|
||||
WHERE
|
||||
cd.is_dir = 0
|
||||
AND cd.audit_status = '1'
|
||||
AND (
|
||||
MATCH(cd.name, cd.summary) AGAINST(#{keyword} IN BOOLEAN MODE)
|
||||
OR cd.name LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR cd.summary LIKE CONCAT('%', #{keyword}, '%')
|
||||
)
|
||||
<if test="deptId != null">
|
||||
AND cd.dept_id = #{deptId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- ResultMap for CmsDocWithScore -->
|
||||
<resultMap type="com.microservices.cms.doc.domain.CmsDocWithScore" id="CmsDocWithScoreResult" extends="CmsDocResult">
|
||||
<result property="searchScore" column="search_score"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 全局搜索 - 带评分的全文索引查询 -->
|
||||
<select id="globalSearchWithScore" resultMap="CmsDocWithScoreResult">
|
||||
<include refid="selectCmsDocWithScoreVo"/>
|
||||
WHERE
|
||||
cd.is_dir = 0
|
||||
AND cd.audit_status = '1'
|
||||
AND (
|
||||
MATCH(cd.name, cd.summary) AGAINST(#{keyword} IN BOOLEAN MODE)
|
||||
OR cd.name LIKE CONCAT('%', #{keyword}, '%')
|
||||
OR cd.summary LIKE CONCAT('%', #{keyword}, '%')
|
||||
)
|
||||
<if test="deptId != null">
|
||||
AND cd.dept_id = #{deptId}
|
||||
</if>
|
||||
ORDER BY
|
||||
-- 主要排序:按相关度评分降序
|
||||
search_score DESC,
|
||||
-- 次要排序:更新时间降序
|
||||
cd.update_time DESC
|
||||
LIMIT #{offset}, #{pageSize}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -159,38 +159,4 @@
|
|||
item="id" collection="array" open="(" separator="," close=")">#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 全局搜索 - 全文索引查询 -->
|
||||
<select id="globalSearch" resultMap="CmsProjectResult">
|
||||
SELECT id,
|
||||
name,
|
||||
description,
|
||||
user_id,
|
||||
dept_id,
|
||||
identifier,
|
||||
username,
|
||||
create_by,
|
||||
create_time,
|
||||
update_time
|
||||
FROM cms_project cp
|
||||
WHERE
|
||||
MATCH(cp.name) AGAINST(#{keyword} IN NATURAL LANGUAGE MODE)
|
||||
<if test="deptId != null">
|
||||
AND cp.dept_id = #{deptId}
|
||||
</if>
|
||||
ORDER BY
|
||||
MATCH(cp.name) AGAINST(#{keyword} IN NATURAL LANGUAGE MODE) DESC,
|
||||
cp.update_time DESC
|
||||
LIMIT #{offset}, #{pageSize}
|
||||
</select>
|
||||
|
||||
<select id="globalSearchCount" resultType="java.lang.Long">
|
||||
SELECT COUNT(*)
|
||||
FROM cms_project cp
|
||||
WHERE
|
||||
MATCH(cp.name) AGAINST(#{keyword} IN NATURAL LANGUAGE MODE)
|
||||
<if test="deptId != null">
|
||||
AND cp.dept_id = #{deptId}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -87,10 +87,18 @@
|
|||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-swagger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-log</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.microservices</groupId>
|
||||
<artifactId>microservices-common-core</artifactId>
|
||||
|
|
@ -122,11 +130,6 @@
|
|||
<artifactId>similarity</artifactId>
|
||||
<version>1.1.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hankcs</groupId>
|
||||
<artifactId>hanlp</artifactId>
|
||||
<version>portable-1.8.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
|
|
|
|||
|
|
@ -222,29 +222,12 @@ public class AchievementsController extends BaseController {
|
|||
return success(achievementsService.get7AddClickById(id,clickType));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("根据专家id,获取近7日成果点击数量(折线图)")
|
||||
@GetMapping("/getExpert7AddClickById")
|
||||
public AjaxResult getExpert7AddClickById(String id,@RequestParam(value = "clickType",required = false, defaultValue = "Experts")
|
||||
String clickType) {
|
||||
return success(achievementsService.get7AddClickById(id,clickType));
|
||||
}
|
||||
|
||||
@ApiOperation("根据成果ID,获取成果的相关行为数据统计(点击量、搜索量、附件下载量、收藏、关注)")
|
||||
@GetMapping("/getActDataStatisticById")
|
||||
public AjaxResult getActDataStatisticById(Long id) {
|
||||
return success(achievementsService.getActDataStatisticById(id));
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("根据领域来源、领域分类名称,获取领域相关数据")
|
||||
@GetMapping("/getAllAreas")
|
||||
public AjaxResult getAllAreas(String areaName) {
|
||||
return success(achievementsService.getAllAreas(areaName));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation("根据领域,将成果数据进行分类")
|
||||
@GetMapping("/getAreaStatistic")
|
||||
public AjaxResult getAreaStatistic(String areaKey)
|
||||
|
|
@ -255,9 +238,9 @@ public class AchievementsController extends BaseController {
|
|||
|
||||
@ApiOperation("根据领域获取领域详情")
|
||||
@GetMapping("/getAreaDetail")
|
||||
public AjaxResult getAreaDetail(String areaKey,String kyxmSum,String source)
|
||||
public AjaxResult getAreaDetail(String areaKey,String kyxm)
|
||||
{
|
||||
return success(achievementsService.getAreaDetail(areaKey,kyxmSum,source));
|
||||
return success(achievementsService.getAreaDetail(areaKey,kyxm));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ public class BlockChainController extends BaseController {
|
|||
@GetMapping("/userDataList")
|
||||
@ApiOperation(value = "入链user列表")
|
||||
public TableDataInfo userDataList(BlockchainListQueryVo queryVo) {
|
||||
startPage();
|
||||
List<Map> list = blockChainService.userDataList(queryVo);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
|
@ -85,7 +86,6 @@ public class BlockChainController extends BaseController {
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/InBlockchainDataList")
|
||||
@ApiOperation(value = "查询区块链数据入链列表")
|
||||
public TableDataInfo list(InBlockchainData inBlockchainData) {
|
||||
|
|
@ -106,10 +106,4 @@ public class BlockChainController extends BaseController {
|
|||
return blockChainService.getUserTokenByProjectId(type,userName,tokenName);
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户对应的所有项目token")
|
||||
@GetMapping("/getUserAllProjectToken")
|
||||
public AjaxResult getUserAllProjectToken (String userName) {
|
||||
return blockChainService.getUserAllProjectToken(userName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package com.microservices.dms.achievementLibrary.controller;
|
||||
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
import com.microservices.common.core.utils.poi.ExcelUtil;
|
||||
import com.microservices.common.core.web.controller.BaseController;
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
|
|
@ -83,10 +82,6 @@ public class SchoolEnterpriseAchievementsController extends BaseController
|
|||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SchoolEnterpriseAchievements schoolEnterpriseAchievements)
|
||||
{
|
||||
|
||||
if (!schoolEnterpriseAchievementsService.getCheckSchoolAchName(schoolEnterpriseAchievements)) {
|
||||
return error("新增校企成果'" + schoolEnterpriseAchievements.getAchievementName() + "'失败,成果名称已存在");
|
||||
}
|
||||
return AjaxResult.success(schoolEnterpriseAchievementsService.insertSchoolEnterpriseAchievements(schoolEnterpriseAchievements));
|
||||
}
|
||||
|
||||
|
|
@ -97,9 +92,6 @@ public class SchoolEnterpriseAchievementsController extends BaseController
|
|||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SchoolEnterpriseAchievements schoolEnterpriseAchievements)
|
||||
{
|
||||
// if (!schoolEnterpriseAchievementsService.getCheckSchoolAchName(schoolEnterpriseAchievements)) {
|
||||
// return error("修改校企成果'" + schoolEnterpriseAchievements.getAchievementName() + "'失败,成果名称已存在");
|
||||
// }
|
||||
return AjaxResult.success(schoolEnterpriseAchievementsService.updateSchoolEnterpriseAchievements(schoolEnterpriseAchievements));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@ public class AchDetailVo {
|
|||
private long dockSum;
|
||||
private long favoriteSum;
|
||||
private long watcherSum;
|
||||
private String remark;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,15 +15,6 @@ public class AreaStatisticVo {
|
|||
private Long kfjsSum;
|
||||
//校企成果汇总
|
||||
private Long xqcgSum;
|
||||
private String source;
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public String getAreaName() {
|
||||
return areaName;
|
||||
|
|
|
|||
|
|
@ -146,8 +146,8 @@ public class SchoolEnterpriseAchievements extends BaseEntity {
|
|||
/**
|
||||
* 成果审核时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "成果审核时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "成果审核时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date reviewDate;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ public class TokenListVo {
|
|||
|
||||
private Long id; // 项目ID
|
||||
private String name; // 项目名称
|
||||
private String userId;//用户id
|
||||
private Long totalToken; // 项目总Token
|
||||
private String createBy; // 创建人
|
||||
private Long issueToken;//issueToken
|
||||
|
|
@ -20,5 +19,4 @@ public class TokenListVo {
|
|||
private Long applyToken;//已分配token
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createdOn; // 项目创建时间
|
||||
private Long ableApplyToken;//责任人可分配token
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
|
|||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.PropertyValues;
|
||||
|
||||
/**
|
||||
* 成果Mapper接口
|
||||
|
|
@ -125,7 +124,7 @@ public interface AchievementsMapper {
|
|||
|
||||
List<Long> getAllId();
|
||||
|
||||
List<AreaStatisticVo> getAreaStatistic(@Param("source")String source,@Param("areaKey") String areaKey);
|
||||
List<AreaStatisticVo> getAreaStatistic(@Param("areaKey") String areaKey);
|
||||
|
||||
List<AchRelatedVo> getRelatedAch(@Param("id")Long id, @Param("sourceId") List<Long> sourceId, @Param("paramYear")String paramYear);
|
||||
|
||||
|
|
@ -161,14 +160,4 @@ public interface AchievementsMapper {
|
|||
List<Map<String, Object>> getDockingUserInfo(@Param("id") Long id);
|
||||
|
||||
List<Achievements> selectAchievementsByArea(AchQueryVo achQueryVo);
|
||||
|
||||
List<KeyValVo<String, Long>> getExperts(@Param("s") Date s, @Param("e") Date e);
|
||||
|
||||
List<KeyValueVo> getAllAreas(@Param("areaName") String areaName);
|
||||
|
||||
void updateRelationAchievements(@Param("source") String source,@Param("sourceId") Long sourceId);
|
||||
|
||||
List<Map<String, Object>> getDockingUserInfoList(@Param("id") Long id);
|
||||
|
||||
String getField1RemarkByParam(@Param("source")String source,@Param("areaKey") String areaKey);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,12 +5,8 @@ import java.util.Map;
|
|||
|
||||
import com.microservices.common.datasource.annotation.Slave;
|
||||
import com.microservices.dms.achievementLibrary.domain.BlockchainListQueryVo;
|
||||
import com.microservices.dms.achievementLibrary.domain.KeyValueVo;
|
||||
import com.microservices.dms.achievementLibrary.domain.blockchain.InBlockchainData;
|
||||
import com.microservices.dms.common.vo.CommitCreateVo;
|
||||
import com.microservices.dms.common.vo.CommitResultVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 区块链数据入链Mapper接口
|
||||
|
|
@ -75,8 +71,4 @@ public interface InBlockchainDataMapper
|
|||
List<Map<String, Object>> commitDataList(BlockchainListQueryVo queryVo);
|
||||
|
||||
List<Map<String, Object>> prDataList(BlockchainListQueryVo queryVo);
|
||||
|
||||
List<String> getNeedToBlockCommitList();
|
||||
|
||||
List<CommitResultVo> getCommitListById(@Param("projectId") String projectId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import java.util.List;
|
|||
import com.microservices.common.datasource.annotation.Slave;
|
||||
import com.microservices.dms.achievementLibrary.domain.SchoolEnterpriseAchievements;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 校企成果Mapper接口
|
||||
|
|
@ -66,6 +65,4 @@ public interface SchoolEnterpriseAchievementsMapper
|
|||
public int deleteSchoolEnterpriseAchievementsByIds(Long[] ids);
|
||||
|
||||
Long topStatistic(SchoolEnterpriseAchievements schoolEnterpriseAchievements);
|
||||
|
||||
SchoolEnterpriseAchievements selectSchoolEnterpriseAchievementsByName(@Param("achievementName") String achievementName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,17 +21,14 @@ public class BigScreenStatisticService {
|
|||
private final CompetitionResourceLibraryMapper competitionResourceLibraryMapper;
|
||||
|
||||
public Map<String, Object> getAchievementTopStatistic(String source) {
|
||||
//获取本周(近7天)的数据
|
||||
Date[] days = DateUtil.getDays(0, 6);
|
||||
Map<String, Long> m = achievementsMapper.getAchievement(days[0], days[1], source)
|
||||
.stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV));
|
||||
List<String> dateStr = DateUtil.getDateStrMMDD(days[0], days[1]);
|
||||
//获取上周(7-14天前)的数据
|
||||
Date[] lastDays = DateUtil.getDays(7, 13);
|
||||
long lastSum = Optional.ofNullable(achievementsMapper.countAchievementBySource(lastDays[0], lastDays[1], source)).orElse(0L);
|
||||
long sum = Optional.ofNullable(achievementsMapper.countAchievementBySource(null, null, source)).orElse(0L);
|
||||
long cSum = m.values().stream().mapToLong(Long::longValue).sum();
|
||||
//计算本周/上周增长%
|
||||
double rate;
|
||||
if (lastSum == 0) rate = 100D;
|
||||
else {
|
||||
|
|
@ -186,7 +183,6 @@ public class BigScreenStatisticService {
|
|||
return competitionResourceLibraryMapper.getCompetitionHot();
|
||||
}
|
||||
|
||||
|
||||
public List<KeyValVo<String, Long>> getCompetitionYearlyPaperAdd() {
|
||||
Date[] currentYear = DateUtil.getLast12Months();
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@ import com.microservices.common.core.utils.DateUtils;
|
|||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
import com.microservices.common.httpClient.service.HttpAPIService;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.dms.achievementLibrary.domain.Achievements;
|
||||
import com.microservices.dms.achievementLibrary.domain.BlockchainListQueryVo;
|
||||
import com.microservices.dms.achievementLibrary.domain.KeyValueVo;
|
||||
import com.microservices.dms.achievementLibrary.domain.TokenListVo;
|
||||
import com.microservices.dms.achievementLibrary.domain.blockchain.InBlockchainData;
|
||||
import com.microservices.dms.achievementLibrary.domain.blockchain.InLinkProjectVo;
|
||||
|
|
@ -16,11 +14,9 @@ import com.microservices.dms.achievementLibrary.domain.blockchain.UserProjectTra
|
|||
import com.microservices.dms.achievementLibrary.domain.blockchain.UserVo;
|
||||
import com.microservices.dms.achievementLibrary.mapper.InBlockchainDataMapper;
|
||||
import com.microservices.dms.achievementLibrary.mapper.UserProjectTransferRecordsMapper;
|
||||
import com.microservices.dms.behaviorImage.domain.AchievementImageVo;
|
||||
import com.microservices.dms.common.vo.*;
|
||||
import com.microservices.dms.referral.mapper.TalentReferralMapper;
|
||||
import com.microservices.dms.resourceLibrary.mapper.ProjectResourceLibraryMapper;
|
||||
import com.microservices.dms.utils.DateUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
//import org.fisco.bcos.sdk.client.Client;
|
||||
|
|
@ -28,7 +24,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||
//import org.fisco.bcos.sdk.client.protocol.response.BcosTransaction;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -38,9 +33,7 @@ import java.time.format.DateTimeFormatter;
|
|||
import java.util.*;
|
||||
|
||||
import static com.microservices.common.core.utils.DateUtils.YYYY_MM_DD_HH_MM_SS;
|
||||
import static com.microservices.common.core.utils.PageUtils.startPage;
|
||||
import static com.microservices.dms.constant.BlockChainFunConstants.*;
|
||||
import static com.microservices.dms.utils.DateUtil.formatLocalDateTimePlusH;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
|
|
@ -72,40 +65,16 @@ public class BlockChainService {
|
|||
if(param != null) {
|
||||
Long issueTokenSum = projectResourceLibraryMapper.sumProjectIssueToken(v.getId());
|
||||
v.setIssueToken(issueTokenSum);
|
||||
long totalToken = Long.parseLong(param.getString("total_supply"));//总token
|
||||
long totalToken = Long.parseLong(param.getString("total_supply"));
|
||||
v.setTotalToken(totalToken);
|
||||
//根据创建人login,获取对应的用户id
|
||||
String userName = v.getUserId();
|
||||
//根据创建人、项目Id,获取创建人拥有token
|
||||
String tokenName = param.getString("token_name");
|
||||
Long applyToken= getUserBlanaceProjectId("userSingleInfo",userName,tokenName);
|
||||
long applyToken = Long.parseLong(param.getString("cur_supply"));
|
||||
v.setApplyToken(applyToken);
|
||||
v.setCurrentToken(totalToken - applyToken);
|
||||
v.setCurrentToken(totalToken - issueTokenSum-v.getApplyToken());
|
||||
}
|
||||
v.setCreatedOn(DateUtil.plusHours(v.getCreatedOn(), 8));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Long getUserBlanaceProjectId(String type,String userName,String tokenName) {
|
||||
JSONObject params = new JSONObject();
|
||||
if(type.equals(USER_SINGLE_INFO)){
|
||||
params.put(REQUEST_TYPE, USER_SINGLE_REPO);
|
||||
params.put("token_name", tokenName);
|
||||
params.put("username", userName);
|
||||
}else if(type.equals(USER_ALL_INFO)){
|
||||
params.put(REQUEST_TYPE, USER_ALL_REPOS);
|
||||
params.put("username", userName);
|
||||
}
|
||||
Map<String, String> p = convertParams(params);
|
||||
params = JSONObject.from(p);
|
||||
JSONObject rsp = queryFiscobcos(params);
|
||||
if (rsp != null) {
|
||||
return Long.parseLong(rsp.getString("balance"));
|
||||
}
|
||||
return -1L;
|
||||
}
|
||||
|
||||
private JSONObject queryProjectInfo(TokenListVo v) {
|
||||
JSONObject param = new JSONObject();
|
||||
param.put(REQUEST_TYPE, QUERY_REPO);
|
||||
|
|
@ -168,27 +137,23 @@ public class BlockChainService {
|
|||
}
|
||||
|
||||
public AjaxResult projectTokenDistribute(InLinkProjectVo vo) {
|
||||
//根据项目ID,获取用户ID
|
||||
//根据项目id获取项目创建人
|
||||
String userId = projectResourceLibraryMapper.getProjectUserIdById(vo.getProjectId());
|
||||
validTokenCount(vo.getProjectId(), vo.getAmount(),userId);
|
||||
validTokenCount(vo.getProjectId(), vo.getAmount());
|
||||
JSONObject params = new JSONObject();
|
||||
params.put(REQUEST_TYPE, TRANSFER_AMOUNT);
|
||||
params.put(REQUEST_TYPE, ADD_USER_BALANCE);
|
||||
params.put("token_name", vo.getProjectId());
|
||||
params.put("amount", vo.getAmount());
|
||||
params.put("payee", vo.getUserId());
|
||||
params.put("payer", userId);
|
||||
params.put("username", vo.getUserId());
|
||||
JSONObject rsp = queryFiscobcos(params);
|
||||
if (rsp != null) {
|
||||
String txHash = rsp.getString(TX_HASH);
|
||||
// insert to db 4、将3入链成功的数据存入表 :用户/项目转账信息记录表 (type:project、 payer_id:username)
|
||||
if (StringUtils.isNotEmpty(txHash)) {
|
||||
UserProjectTransferRecords records = new UserProjectTransferRecords();
|
||||
records.setPayerId(params.getString("payer"));//转账人
|
||||
records.setPayeeId(params.getString("payee"));//收款人
|
||||
records.setPayerId(String.valueOf(SecurityUtils.getGitlinkUserId()));
|
||||
records.setPayeeId(vo.getUserId());
|
||||
records.setProjectId(vo.getProjectId());
|
||||
records.setToken(BigDecimal.valueOf(vo.getAmount()));
|
||||
records.setType("projectApply");//项目分配
|
||||
records.setType("project");
|
||||
records.setCreateTime(DateUtils.getNowDate());
|
||||
records.setTxHash(txHash);
|
||||
records.setCreateBy(SecurityUtils.getUsername());
|
||||
|
|
@ -200,13 +165,23 @@ public class BlockChainService {
|
|||
}
|
||||
|
||||
public AjaxResult userCreate(UserCreateVo userCreateVo) {
|
||||
//根据项目id获取项目创建人
|
||||
String userId = projectResourceLibraryMapper.getUserIdBYLogin(userCreateVo.getPayee());//收款人ID
|
||||
userCreateVo.setPayee(userId);
|
||||
String payerId = projectResourceLibraryMapper.getUserIdBYLogin(userCreateVo.getPayer());//转账人ID
|
||||
userCreateVo.setPayer(payerId);
|
||||
JSONObject params = JSONObject.from(userCreateVo);
|
||||
UserProjectTransferRecords records = new UserProjectTransferRecords();
|
||||
records.setPayerId(params.getString("payer"));
|
||||
records.setPayeeId(params.getString("payee"));
|
||||
records.setProjectId(params.getString("token_name"));
|
||||
records.setToken(params.getBigDecimal("amount"));
|
||||
records.setType("userTransfer");//用户转账
|
||||
records.setReserve1(userCreateVo.getTypeId());
|
||||
records.setCreateTime(DateUtils.getNowDate());
|
||||
records.setCreateBy(SecurityUtils.getUsername());
|
||||
userProjectTransferRecordsMapper.insertUserProjectTransferRecords(records);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
public AjaxResult userCreateTmp(UserCreateVo userCreateVo) {
|
||||
//转账人token充足
|
||||
validUserTokenCount(userCreateVo);
|
||||
validUserTokenCount(userCreateVo);
|
||||
//进行转账
|
||||
JSONObject params = JSONObject.from(userCreateVo);
|
||||
params.put(REQUEST_TYPE, TRANSFER_AMOUNT);
|
||||
|
|
@ -252,20 +227,20 @@ public class BlockChainService {
|
|||
}
|
||||
|
||||
//判断项目剩余token是否还支持分配
|
||||
private void validTokenCount(String tokenName, Long amount,String userName) {
|
||||
private void validTokenCount(String tokenName, Long amount) {
|
||||
TokenListVo v = new TokenListVo();
|
||||
if(StringUtils.isEmpty(tokenName)) {
|
||||
throw new ServiceException("项目ID不能为空");
|
||||
}
|
||||
v.setId(Long.parseLong(Optional.ofNullable(tokenName).orElse("-1")));
|
||||
Long issueTokenSum = projectResourceLibraryMapper.sumProjectIssueToken(v.getId());
|
||||
v.setIssueToken(issueTokenSum);
|
||||
//根据创建人、项目Id,获取创建人拥有token
|
||||
Long applyToken= getUserBlanaceProjectId("userSingleInfo",userName,tokenName);
|
||||
v.setApplyToken(applyToken);
|
||||
long curToken = applyToken - issueTokenSum;
|
||||
if (curToken < amount) {
|
||||
throw new ServiceException("token数量不足");
|
||||
JSONObject c = queryProjectInfo(v);
|
||||
if(c != null) {
|
||||
Long issueTokenSum = projectResourceLibraryMapper.sumProjectIssueToken(v.getId());
|
||||
v.setIssueToken(issueTokenSum);
|
||||
long totalToken = Long.parseLong(c.getString("total_supply"));
|
||||
v.setTotalToken(totalToken);
|
||||
long applyToken = Long.parseLong(c.getString("cur_supply"));
|
||||
long curToken = totalToken - issueTokenSum-applyToken;
|
||||
if (curToken < amount) {
|
||||
throw new ServiceException("token数量不足");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -284,7 +259,29 @@ public class BlockChainService {
|
|||
return -1L;
|
||||
}
|
||||
|
||||
|
||||
public AjaxResult commitCreate(CommitCreateVo commitCreateVo) {
|
||||
Map<String, Object> res = projectResourceLibraryMapper.selectCommitInfo(commitCreateVo.getCommit_id());
|
||||
JSONObject params = JSONObject.from(res);
|
||||
params.put(REQUEST_TYPE, CREATE_COMMIT);
|
||||
Map<String, String> p = convertParams(params);
|
||||
params = JSONObject.from(p);
|
||||
JSONObject rsp = queryFiscobcos(params);
|
||||
if (rsp != null) {
|
||||
String txHash = rsp.getString(TX_HASH);
|
||||
// insert to db 4、 :数据入链表(id,type,type_id,tx_hash,create_time) (type:issue,type_id:issue_id)
|
||||
if (StringUtils.isNotEmpty(txHash)) {
|
||||
InBlockchainData inBlockchainData = new InBlockchainData();
|
||||
inBlockchainData.setType("commit");
|
||||
inBlockchainData.setTxHash(txHash);
|
||||
inBlockchainData.setTypeId(commitCreateVo.getCommit_id());
|
||||
inBlockchainData.setCreateTime(DateUtils.getNowDate());
|
||||
inBlockchainData.setCreateBy(SecurityUtils.getUsername());
|
||||
inBlockchainDataMapper.insertInBlockchainData(inBlockchainData);
|
||||
return AjaxResult.success(rsp);
|
||||
}
|
||||
}
|
||||
return AjaxResult.error();
|
||||
}
|
||||
|
||||
public AjaxResult prCreate(PrCreateVo prCreateVo) {
|
||||
Map<String, Object> res = projectResourceLibraryMapper.selectPrInfo(prCreateVo.getPr_id());
|
||||
|
|
@ -349,121 +346,23 @@ public class BlockChainService {
|
|||
}
|
||||
|
||||
public List<Map<String, Object>> issueDataList(BlockchainListQueryVo queryVo) {
|
||||
List<Map<String, Object>> maps = inBlockchainDataMapper.issueDataList(queryVo);
|
||||
handleForgeDate(maps);
|
||||
return maps;
|
||||
}
|
||||
|
||||
private void handleForgeDate(List<Map<String, Object>> maps){
|
||||
for (Map<String, Object> m : maps) {
|
||||
LocalDateTime updatedAt = (LocalDateTime) m.get("updated_at");
|
||||
LocalDateTime createdAt = (LocalDateTime) m.get("created_at");
|
||||
m.put("updated_at",formatLocalDateTimePlusH(updatedAt,8));
|
||||
m.put("created_at",formatLocalDateTimePlusH(createdAt,8));
|
||||
|
||||
if (m.containsKey("committer_time")) {
|
||||
LocalDateTime committer_time = (LocalDateTime) m.get("committer_time");
|
||||
m.put("committer_time",formatLocalDateTimePlusH(committer_time,8));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//定时任务,将commit数据入链
|
||||
// @Scheduled(cron = "${cron.commitPushBlock}")
|
||||
public void commitPushBlock() {
|
||||
//先查询需要入链的数据
|
||||
List<String> commitIdList = inBlockchainDataMapper.getNeedToBlockCommitList();
|
||||
if(commitIdList!=null && commitIdList.size()>0) {
|
||||
//遍历数据入区块链
|
||||
for(String commitId : commitIdList) {
|
||||
CommitCreateVo commitCreateVo = new CommitCreateVo();
|
||||
commitCreateVo.setCommit_id(commitId);
|
||||
commitCreate(commitCreateVo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AjaxResult commitCreate(CommitCreateVo commitCreateVo) {
|
||||
List<CommitResultVo> CommitCreateVoList = new ArrayList<>();
|
||||
if(StringUtils.isEmpty(commitCreateVo.getCommit_id())) {
|
||||
String projectId = commitCreateVo.getProject_id();
|
||||
if (StringUtils.isNotEmpty(projectId)) {
|
||||
CommitCreateVoList = inBlockchainDataMapper.getCommitListById(projectId);
|
||||
}
|
||||
}else{
|
||||
CommitResultVo resultVo = new CommitResultVo();
|
||||
resultVo.setCommitId(commitCreateVo.getCommit_id());
|
||||
resultVo.setCommitDiff(commitCreateVo.getCommit_diff());
|
||||
CommitCreateVoList.add(resultVo);
|
||||
}
|
||||
if(CommitCreateVoList!=null && CommitCreateVoList.size()>0) {
|
||||
for(CommitResultVo commit : CommitCreateVoList) {
|
||||
commitDataTnBlock(commit);
|
||||
|
||||
//判断代码合并的时候issue
|
||||
String issue_id = commitCreateVo.getIssue_id();
|
||||
if(StringUtils.isNotEmpty(issue_id)) {
|
||||
//根据issue_id获取,判断是否要进行token转让
|
||||
UserProjectTransferRecords records = projectResourceLibraryMapper.selectIssueEndInfo(issue_id);
|
||||
if (Objects.nonNull(records)) {
|
||||
records.setType("issuePr");//pr合并关闭issue
|
||||
records.setTxHash("txHash");
|
||||
records.setCreateTime(DateUtils.getNowDate());
|
||||
records.setCreateBy(SecurityUtils.getUsername());
|
||||
userProjectTransferRecordsMapper.insertUserProjectTransferRecords(records);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
private AjaxResult commitDataTnBlock(CommitResultVo commitCreateVo) {
|
||||
String commitId = commitCreateVo.getCommitId();
|
||||
//根据项目id,查询对应的需要入链的commit
|
||||
Map<String, Object> res = projectResourceLibraryMapper.selectCommitInfo(commitId,commitCreateVo.getCommitDiff());
|
||||
JSONObject params = JSONObject.from(res);
|
||||
params.put(REQUEST_TYPE, CREATE_COMMIT);
|
||||
Map<String, String> p = convertParams(params);
|
||||
params = JSONObject.from(p);
|
||||
JSONObject rsp = queryFiscobcos(params);
|
||||
if (rsp != null) {
|
||||
String txHash = rsp.getString(TX_HASH);
|
||||
// insert to db 4、 :数据入链表(id,type,type_id,tx_hash,create_time) (type:issue,type_id:issue_id)
|
||||
if (StringUtils.isNotEmpty(txHash)) {
|
||||
InBlockchainData inBlockchainData = new InBlockchainData();
|
||||
inBlockchainData.setType("commit");
|
||||
inBlockchainData.setTxHash(txHash);
|
||||
inBlockchainData.setTypeId(commitId);
|
||||
inBlockchainData.setCreateTime(DateUtils.getNowDate());
|
||||
inBlockchainData.setCreateBy(SecurityUtils.getUsername());
|
||||
inBlockchainDataMapper.insertInBlockchainData(inBlockchainData);
|
||||
return AjaxResult.success(rsp);
|
||||
}
|
||||
}
|
||||
return AjaxResult.error();
|
||||
return inBlockchainDataMapper.issueDataList(queryVo);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> commitDataList(BlockchainListQueryVo queryVo) {
|
||||
List<Map<String, Object>> maps = inBlockchainDataMapper.commitDataList(queryVo);
|
||||
handleForgeDate(maps);
|
||||
return maps;
|
||||
return inBlockchainDataMapper.commitDataList(queryVo);
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> prDataList(BlockchainListQueryVo queryVo) {
|
||||
List<Map<String, Object>> maps = inBlockchainDataMapper.prDataList(queryVo);
|
||||
handleForgeDate(maps);
|
||||
return maps;
|
||||
return inBlockchainDataMapper.prDataList(queryVo);
|
||||
}
|
||||
//产权转让
|
||||
|
||||
public List<Map> userDataList(BlockchainListQueryVo queryVo) {
|
||||
Long gitlinkUserId = SecurityUtils.getGitlinkUserId();
|
||||
Map<String, Object> stringObjectMap = Optional.ofNullable(talentReferralMapper.selectUsersById(gitlinkUserId)).orElse(new HashMap<>());
|
||||
if (!Objects.equals(stringObjectMap.get("admin"), "1")) {
|
||||
queryVo.setUserId(gitlinkUserId);
|
||||
}
|
||||
|
||||
startPage();
|
||||
return userProjectTransferRecordsMapper.userDataList(queryVo);
|
||||
}
|
||||
|
||||
|
|
@ -595,20 +494,4 @@ public class BlockChainService {
|
|||
}
|
||||
return AjaxResult.error();
|
||||
}
|
||||
|
||||
//
|
||||
public AjaxResult getUserAllProjectToken(String userName) {
|
||||
JSONObject params = new JSONObject();
|
||||
params.put(REQUEST_TYPE, USER_ALL_REPOS);
|
||||
params.put("username", userName);
|
||||
Map<String, String> p = convertParams(params);
|
||||
params = JSONObject.from(p);
|
||||
JSONObject rsp = queryFiscobcos(params);
|
||||
if (rsp != null) {
|
||||
return AjaxResult.success(rsp);
|
||||
}
|
||||
return AjaxResult.error();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,10 +118,5 @@ public interface IAchievementsService {
|
|||
|
||||
List<CompetitionResourceLibrary> getRelatedAchCompetitionOfExpert(Long id);
|
||||
|
||||
AchDetailVo getAreaDetail(String areaKey,String kyxmSum, String source);
|
||||
|
||||
List<KeyValVo<String, Long>> get7DayAddExport(AchQueryVo achQueryVo);
|
||||
|
||||
List<KeyValueVo> getAllAreas(String areaName);
|
||||
|
||||
AchDetailVo getAreaDetail(String areaKey, String kyxm);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,4 @@ public interface ISchoolEnterpriseAchievementsService
|
|||
Long topStatistic(SchoolEnterpriseAchievements schoolEnterpriseAchievements);
|
||||
|
||||
List<SchoolEnterpriseAchievements> listFront(SchoolEnterpriseAchievements schoolEnterpriseAchievements);
|
||||
|
||||
boolean getCheckSchoolAchName(SchoolEnterpriseAchievements schoolEnterpriseAchievements);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import com.microservices.common.core.utils.StringUtils;
|
|||
import com.microservices.common.httpClient.service.HttpAPIService;
|
||||
import com.microservices.common.security.utils.SecurityUtils;
|
||||
import com.microservices.dms.achievementLibrary.domain.*;
|
||||
import com.microservices.dms.achievementLibrary.mapper.SchoolEnterpriseAchievementsMapper;
|
||||
import com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo;
|
||||
import com.microservices.dms.behaviorImage.domain.AchievementImageVo;
|
||||
import com.microservices.dms.behaviorImage.service.IBehaviorImageService;
|
||||
|
|
@ -20,13 +19,11 @@ import com.microservices.dms.resourceLibrary.domain.CompetitionResourceLibrary;
|
|||
import com.microservices.dms.resourceLibrary.domain.Searcher;
|
||||
import com.microservices.dms.resourceLibrary.domain.TaskResourceLibrary;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
|
||||
import com.microservices.dms.resourceLibrary.mapper.CompetitionResourceLibraryMapper;
|
||||
import com.microservices.dms.resourceLibrary.mapper.ExpertResourceLibraryMapper;
|
||||
import com.microservices.dms.resourceLibrary.mapper.ProjectResourceLibraryMapper;
|
||||
import com.microservices.dms.resourceLibrary.mapper.TaskResourceLibraryMapper;
|
||||
import com.microservices.dms.utils.DateUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.checkerframework.checker.units.qual.K;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
|
|
@ -55,12 +52,11 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
@Autowired
|
||||
private ExpertResourceLibraryMapper expertResourceLibraryMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
private IBehaviorImageService behaviorImageService;
|
||||
|
||||
@Value("${makerSpaceUrl}")
|
||||
public String makerSpaceUrl;
|
||||
@Value("${markerSpaceUrl}")
|
||||
public String markerSpaceUrl;
|
||||
|
||||
@Value("${http.gitLinkUrl}")
|
||||
public String gitLinkUrl;
|
||||
|
|
@ -129,7 +125,7 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
a.setAttachments(buildFileInfoByIdents(a.getAttachments(), a.getSource()));
|
||||
|
||||
//拼接对接的用户信息
|
||||
List<Map<String,Object>> dockingUserInfo = achievementsMapper.getDockingUserInfoList(a.getId());
|
||||
List<Map<String,Object>> dockingUserInfo = achievementsMapper.getDockingUserInfo(a.getId());
|
||||
a.setDockingUserInfo(dockingUserInfo);
|
||||
}
|
||||
return list;
|
||||
|
|
@ -192,14 +188,6 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
*/
|
||||
@Override
|
||||
public int deleteAchievementsById(Long id) {
|
||||
//根据id,获取数据仓库该数据信息
|
||||
Achievements achievements = achievementsMapper.selectAchievementsById(id);
|
||||
if(achievements != null){
|
||||
String source = achievements.getSource();
|
||||
if(StringUtils.isNotEmpty(source)) {
|
||||
achievementsMapper.updateRelationAchievements(source,achievements.getSourceId());
|
||||
}
|
||||
}
|
||||
return achievementsMapper.deleteAchievementsById(id);
|
||||
}
|
||||
|
||||
|
|
@ -217,7 +205,7 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
}
|
||||
|
||||
if (Objects.equals(source, "2")) {
|
||||
concatUrl(list, makerSpaceUrl);
|
||||
concatUrl(list, markerSpaceUrl);
|
||||
}
|
||||
|
||||
if (Objects.equals(source, "4")) {
|
||||
|
|
@ -346,24 +334,6 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KeyValVo<String, Long>> get7DayAddExport(AchQueryVo achQueryVo) {
|
||||
Date[] days = DateUtil.getDays(0, 6);
|
||||
Map<String, Long> w = achievementsMapper.getExperts(days[0], days[1])
|
||||
.stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV));
|
||||
|
||||
List<String> dateStr = DateUtil.getDateStrMMDD(days[0], days[1]);
|
||||
List<KeyValVo<String, Long>> res = new ArrayList<>();
|
||||
|
||||
for (String s : dateStr) {
|
||||
Long a = w.getOrDefault(s, 0L);
|
||||
KeyValVo<String, Long> k1 = new KeyValVo<>();
|
||||
k1.setK(s);
|
||||
k1.setV(a);
|
||||
res.add(k1);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@Override
|
||||
public Map<String, Long> indexProjectStatistic() {
|
||||
Map<String, Long> res = achievementsMapper.indexProjectStatistic();
|
||||
|
|
@ -400,10 +370,6 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页专家数据统计
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Long> indexExpertStatistic() {
|
||||
Map<String, Long> res = new HashMap<>();
|
||||
|
|
@ -474,19 +440,7 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
|
||||
@Override
|
||||
public List<AreaStatisticVo> getAreaStatistic(String areaKey) {
|
||||
List<AreaStatisticVo> areaStatisticVoList = new ArrayList<>();
|
||||
if(StringUtils.isNotEmpty(areaKey)) {
|
||||
//根据逗号进行分割
|
||||
String[] res =areaKey.split(",");
|
||||
for (String s : res) {
|
||||
String[] ss = s.split("_");
|
||||
List<AreaStatisticVo> tmpList = achievementsMapper.getAreaStatistic(ss[1],ss[0]);
|
||||
areaStatisticVoList.addAll(tmpList);
|
||||
}
|
||||
return areaStatisticVoList;
|
||||
}else{
|
||||
return achievementsMapper.getAreaStatistic(null,areaKey);
|
||||
}
|
||||
return achievementsMapper.getAreaStatistic(areaKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -494,17 +448,15 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
List<AchRelatedResult> relatedResultList = new ArrayList<>();
|
||||
//想根据开源项目id,获取对应的年度信息
|
||||
List<Long> allSourceId = achievementsMapper.getAllSourceId(id, sourceId);
|
||||
if(allSourceId != null && allSourceId.size() > 0) {
|
||||
List<String> allYear = achievementsMapper.getDistinctYear(id, allSourceId);
|
||||
if (StringUtils.isNotNull(allYear)) {
|
||||
//遍历年度信息,获取年度成果数据
|
||||
for (String paramYear : allYear) {
|
||||
AchRelatedResult relatedResult = new AchRelatedResult();
|
||||
relatedResult.setYear(paramYear);
|
||||
List<AchRelatedVo> tmpList = achievementsMapper.getRelatedAch(id, allSourceId, paramYear);
|
||||
relatedResult.setAchRelatedVoList(tmpList);
|
||||
relatedResultList.add(relatedResult);
|
||||
}
|
||||
List<String> allYear = achievementsMapper.getDistinctYear(id, allSourceId);
|
||||
if (StringUtils.isNotNull(allYear)) {
|
||||
//遍历年度信息,获取年度成果数据
|
||||
for (String paramYear : allYear) {
|
||||
AchRelatedResult relatedResult = new AchRelatedResult();
|
||||
relatedResult.setYear(paramYear);
|
||||
List<AchRelatedVo> tmpList = achievementsMapper.getRelatedAch(id, allSourceId, paramYear);
|
||||
relatedResult.setAchRelatedVoList(tmpList);
|
||||
relatedResultList.add(relatedResult);
|
||||
}
|
||||
}
|
||||
return relatedResultList;
|
||||
|
|
@ -598,14 +550,16 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public AchDetailVo getAreaDetail(String areaKey,String kyxmSum, String source) {
|
||||
public AchDetailVo getAreaDetail(String areaKey, String kyxm) {
|
||||
AchDetailVo achDetailVo = new AchDetailVo();
|
||||
AchQueryVo achQueryVo = new AchQueryVo();
|
||||
achQueryVo.setAreaQuery(areaKey);
|
||||
achQueryVo.setSource(source);
|
||||
//根据kye,和source,查询领域描述
|
||||
String remark = achievementsMapper.getField1RemarkByParam(source,areaKey);
|
||||
achDetailVo.setRemark(remark);
|
||||
if(StringUtils.isNotNull(kyxm)) {
|
||||
long kyxmLong = Long.parseLong(kyxm);
|
||||
if(kyxmLong>0) {
|
||||
achQueryVo.setSource("1");
|
||||
}
|
||||
}
|
||||
List<Achievements> achievementsList = achievementsMapper.selectAchievementsByArea(achQueryVo);
|
||||
if(achievementsList!=null && achievementsList.size()>0) {
|
||||
achDetailVo.setAchievementsList(achievementsList);
|
||||
|
|
@ -621,12 +575,4 @@ public class AchievementsServiceImpl implements IAchievementsService {
|
|||
return achDetailVo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<KeyValueVo> getAllAreas(String areaName) {
|
||||
List<KeyValueVo> resultVal = achievementsMapper.getAllAreas(areaName);
|
||||
return resultVal;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.microservices.dms.achievementLibrary.service.impl;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.microservices.common.core.constant.UserConstants;
|
||||
import com.microservices.common.core.exception.ServiceException;
|
||||
import com.microservices.common.core.utils.DateUtils;
|
||||
import com.microservices.common.core.utils.StringUtils;
|
||||
|
|
@ -13,7 +12,6 @@ import com.microservices.dms.achievementLibrary.domain.Achievements;
|
|||
import com.microservices.dms.achievementLibrary.mapper.AchievementTeamMapper;
|
||||
import com.microservices.dms.achievementLibrary.mapper.AchievementsMapper;
|
||||
import com.microservices.dms.achievementLibrary.service.IAchievementsService;
|
||||
import com.microservices.system.api.domain.SysUser;
|
||||
import com.microservices.system.api.model.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -112,19 +110,6 @@ public class SchoolEnterpriseAchievementsServiceImpl implements ISchoolEnterpris
|
|||
return schoolEnterpriseAchievements.getId();
|
||||
}
|
||||
|
||||
//先判断是否存在名称一致的成果,存在则抛异常,已存在名称一样的成果
|
||||
@Override
|
||||
public boolean getCheckSchoolAchName(SchoolEnterpriseAchievements schoolEnterpriseAchievements) {
|
||||
Long achId = StringUtils.isNull(schoolEnterpriseAchievements.getId()) ? -1L : schoolEnterpriseAchievements.getId();
|
||||
SchoolEnterpriseAchievements info =schoolEnterpriseAchievementsMapper.selectSchoolEnterpriseAchievementsByName(schoolEnterpriseAchievements.getAchievementName());
|
||||
if (StringUtils.isNotNull(info) && info.getId().longValue() != achId.longValue())
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改校企成果
|
||||
*
|
||||
|
|
@ -135,13 +120,6 @@ public class SchoolEnterpriseAchievementsServiceImpl implements ISchoolEnterpris
|
|||
public int updateSchoolEnterpriseAchievements(SchoolEnterpriseAchievements schoolEnterpriseAchievements)
|
||||
{
|
||||
schoolEnterpriseAchievements.setUpdateTime(DateUtils.getNowDate());
|
||||
String status = schoolEnterpriseAchievements.getStatus();
|
||||
if(StringUtils.isNotEmpty(status)){
|
||||
schoolEnterpriseAchievements.setReviewDate(DateUtils.getNowDate());
|
||||
if (SecurityUtils.getLoginUser() != null) {
|
||||
schoolEnterpriseAchievements.setReviewer(SecurityUtils.getLoginUser().getUsername());
|
||||
}
|
||||
}
|
||||
return schoolEnterpriseAchievementsMapper.updateSchoolEnterpriseAchievements(schoolEnterpriseAchievements);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ public class BehaviorImageServiceImpl implements IBehaviorImageService {
|
|||
if(StringUtils.isNotNull(clickSum) && clickSum > 0) {
|
||||
Long click = behaviorImageMapper.getClickSumByAchievementId(id, BehaviorContant.ACHIEVEMENTS_IMAGE);
|
||||
if (StringUtils.isNotNull(click)) {
|
||||
// clickResult = click * weight / clickSum ;
|
||||
clickResult = click * weight / 100 ;
|
||||
clickResult = click * weight / clickSum ;
|
||||
}
|
||||
}
|
||||
} else if (bhavior.equals(BehaviorContant.FAVORITE_BEHAVIOR)) {//收藏
|
||||
|
|
@ -50,8 +49,7 @@ public class BehaviorImageServiceImpl implements IBehaviorImageService {
|
|||
if(StringUtils.isNotNull(favoriteSum) && favoriteSum > 0) {
|
||||
Long favorite = behaviorImageMapper.getFavoriteSumByAchievementId(id,BehaviorContant.ACHIEVEMENTS_IMAGE);
|
||||
if (StringUtils.isNotNull(favorite)) {
|
||||
// favoriteResult = favorite *weight / favoriteSum ;
|
||||
favoriteResult = favorite *weight / 100 ;
|
||||
favoriteResult = favorite *weight / favoriteSum ;
|
||||
}
|
||||
}
|
||||
} else if (bhavior.equals(BehaviorContant.SEARCH_BEHAVIOR)) {//搜索
|
||||
|
|
@ -60,8 +58,7 @@ public class BehaviorImageServiceImpl implements IBehaviorImageService {
|
|||
if(StringUtils.isNotNull(searchSum) && searchSum > 0) {
|
||||
Long search = behaviorImageMapper.getSearchSumByAchievementId(id, BehaviorContant.ACHIEVEMENTS_IMAGE);
|
||||
if (StringUtils.isNotNull(search)) {
|
||||
// searchResult = search *weight / searchSum;
|
||||
searchResult = search *weight / 100;
|
||||
searchResult = search *weight / searchSum;
|
||||
}
|
||||
}
|
||||
} else if (bhavior.equals(BehaviorContant.WATCH_BEHAVIOR)) {//关注
|
||||
|
|
@ -70,8 +67,7 @@ public class BehaviorImageServiceImpl implements IBehaviorImageService {
|
|||
if(StringUtils.isNotNull( watchSum) && watchSum > 0) {
|
||||
Long watch = behaviorImageMapper.getWatchSumByAchievementId(id,BehaviorContant.ACHIEVEMENTS_IMAGE);
|
||||
if (StringUtils.isNotNull( watch) ) {
|
||||
// watchResult = watch *weight / watchSum;
|
||||
watchResult = watch *weight / 100;
|
||||
watchResult = watch *weight / watchSum;
|
||||
}
|
||||
}
|
||||
} else if (bhavior.equals(BehaviorContant.FILE_DOWNLOAD_BEHAVIOR)) {//文件下载
|
||||
|
|
@ -80,8 +76,7 @@ public class BehaviorImageServiceImpl implements IBehaviorImageService {
|
|||
if(StringUtils.isNotNull(fileDownloadSum) && fileDownloadSum > 0) {
|
||||
Long fileDownload = behaviorImageMapper.getFileDownloadSumByAchievementId(id, BehaviorContant.ACHIEVEMENTS_IMAGE);
|
||||
if (StringUtils.isNotNull(fileDownload)) {
|
||||
// fileDownloadResult = fileDownload *weight / fileDownloadSum ;
|
||||
fileDownloadResult = fileDownload *weight / 100 ;
|
||||
fileDownloadResult = fileDownload *weight / fileDownloadSum ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,11 +125,6 @@ public class OpenController extends BaseController {
|
|||
return success(achievementsService.get7DayAdd(achQueryVo));
|
||||
}
|
||||
|
||||
@ApiOperation("七日新增专家")
|
||||
@GetMapping("/achievements/get7DayAddExpert")
|
||||
public AjaxResult get7DayAddExport(AchQueryVo achQueryVo) {
|
||||
return success(achievementsService.get7DayAddExport(achQueryVo));
|
||||
}
|
||||
|
||||
@ApiOperation("首页项目统计")
|
||||
@GetMapping("/achievements/indexProjectStatistic")
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
package com.microservices.dms.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CommitCreateVo {
|
||||
private String commit_id;
|
||||
|
||||
private String project_id;
|
||||
public String getCommit_id() {
|
||||
return commit_id;
|
||||
}
|
||||
|
||||
private String commit_diff;
|
||||
|
||||
private String issue_id;
|
||||
}
|
||||
public void setCommit_id(String commit_id) {
|
||||
this.commit_id = commit_id;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
package com.microservices.dms.common.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CommitResultVo {
|
||||
private String commitId;
|
||||
|
||||
private String commitDiff;
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ public class TalentReferralService {
|
|||
// 获取项目贡献者数量
|
||||
JSONArray contributorsArray = dmsRequestHelper.getAllDataByPage(DmsGitLinkRequestUrl.CONTRIBUTORS(projectFullName), "list", "total_count");
|
||||
|
||||
return contributorsArray.stream().map(o -> (JSONObject) o).map(s -> s.getString("id")).filter(StringUtils::isNotBlank).mapToLong(Long::parseLong).boxed().collect(Collectors.toSet());
|
||||
return contributorsArray.stream().map(o -> (JSONObject) o).map(s -> s.getString("contributions")).filter(StringUtils::isNotBlank).mapToLong(Long::parseLong).boxed().collect(Collectors.toSet());
|
||||
|
||||
} catch (ServiceException e) {
|
||||
logger.error("【{}】获取项目贡献者数量失败:{}", projectFullName, e.getMessage());
|
||||
|
|
@ -116,7 +116,6 @@ public class TalentReferralService {
|
|||
IssuesVo vo = new IssuesVo();
|
||||
vo.setProjectId(projectId);
|
||||
vo.setStatusIds(Lists.newArrayList(ReferralConstant.ISSUE_CLOSED, ReferralConstant.ISSUE_RESOLVED));
|
||||
vo.setIssueClassify("issue");
|
||||
List<IssuesVo> issuesVos = talentReferralMapper.selectIssuesCondition(vo);
|
||||
Map<Long, Double> userFractionMap = new HashMap<>();
|
||||
// 计算与解决issue的相似度, 标题+描述
|
||||
|
|
@ -141,9 +140,7 @@ public class TalentReferralService {
|
|||
List<Map.Entry<Long, Double>> entryList = new ArrayList<>(userFractionMap.entrySet());
|
||||
entryList.sort((entry1, entry2) -> Double.compare(entry2.getValue(), entry1.getValue()));
|
||||
|
||||
// Set<Long> contributors = getContributorsByProjectId(projectId);
|
||||
// 贡献者改为项目成员
|
||||
Set<Long> contributors = getCollaboratorsByProjectId(projectId);
|
||||
Set<Long> contributors = getContributorsByProjectId(projectId);
|
||||
if (!contributors.isEmpty() && !entryList.isEmpty()) {
|
||||
entryList.removeIf(s -> !contributors.contains(s.getKey()));
|
||||
}
|
||||
|
|
@ -377,9 +374,6 @@ public class TalentReferralService {
|
|||
*/
|
||||
public Object competitionExpertTalentReferral(Long competitionId) {
|
||||
TaskVo task = talentReferralMapper.selectCompetitionById(competitionId);
|
||||
if (task == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<KeyValueVo> categories = new ArrayList<>();
|
||||
List<TaskVo> completedTasks = talentReferralMapper.selectCompetitionIdByStatus();
|
||||
List<ExpertVo> allExperts = talentReferralMapper.selectExpertsBy(new ExpertVo());
|
||||
|
|
@ -396,12 +390,12 @@ public class TalentReferralService {
|
|||
|
||||
|
||||
List<KeyValVo<Long, String>> allTaskWithExpertIds = talentReferralMapper.allTaskWithExpertIds("2");
|
||||
Map<String, String> t2e = allTaskWithExpertIds.stream().collect(Collectors.toMap(e->String.valueOf(e.getK()), KeyValVo::getV, (o, n) -> n));
|
||||
Map<Long, String> t2e = allTaskWithExpertIds.stream().collect(Collectors.toMap(KeyValVo::getK, KeyValVo::getV, (o, n) -> n));
|
||||
for (TaskVo t2 : completedTasks) {
|
||||
double subjectFraction = SimilarityService.sentence(task.getName(), t2.getName());
|
||||
double descFraction = SimilarityService.text(t2.getDescription(), task.getDescription());
|
||||
|
||||
String[] split = t2e.getOrDefault(String.valueOf(t2.getId()), "").split(",");
|
||||
String[] split = t2e.getOrDefault(t2.getId(), "").split(",");
|
||||
for (String s : split) {
|
||||
if (StringUtils.isNotBlank(s)) {
|
||||
step2Map.put(Long.parseLong(s), (subjectFraction + descFraction) * 100.0D);
|
||||
|
|
|
|||
|
|
@ -13,5 +13,4 @@ public class IssuesVo {
|
|||
private Long statusId;
|
||||
private List<Long> statusIds;
|
||||
private Long num;
|
||||
private String issueClassify;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import com.microservices.common.core.web.domain.AjaxResult;
|
|||
import com.microservices.common.core.web.page.TableDataInfo;
|
||||
import com.microservices.common.log.annotation.Log;
|
||||
import com.microservices.common.log.enums.BusinessType;
|
||||
import com.microservices.dms.achievementLibrary.domain.AchQueryVo;
|
||||
import com.microservices.dms.resourceLibrary.domain.ExpertResourceLibrary;
|
||||
import com.microservices.dms.resourceLibrary.service.IExpertResourceLibraryService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
|
@ -139,5 +138,4 @@ public class ExpertResourceLibraryController extends BaseController
|
|||
public AjaxResult getActDataStatisticById(Long id) {
|
||||
return success(expertResourceLibraryService.getActDataStatisticById(id));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,10 @@
|
|||
package com.microservices.dms.resourceLibrary.domain;
|
||||
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.microservices.common.core.annotation.Excel;
|
||||
import com.microservices.common.core.web.domain.BaseEntity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 专家资源库对象 expert_resource_library
|
||||
*
|
||||
|
|
@ -52,7 +48,7 @@ public class ExpertResourceLibrary extends BaseEntity {
|
|||
private String expertDomain;
|
||||
|
||||
private String titleRank;
|
||||
//准入状态
|
||||
|
||||
private Long status;
|
||||
//评审领域1
|
||||
private String reviewAreaOne;
|
||||
|
|
@ -82,26 +78,6 @@ public class ExpertResourceLibrary extends BaseEntity {
|
|||
private String userNickName;
|
||||
private String otherAttachments;
|
||||
|
||||
private String fullFileIds;
|
||||
|
||||
private List<KeyValVo<String, String>> attachmentList = new ArrayList<>();
|
||||
|
||||
public List<KeyValVo<String, String>> getAttachmentList() {
|
||||
return attachmentList;
|
||||
}
|
||||
|
||||
public void setAttachmentList(List<KeyValVo<String, String>> attachmentList) {
|
||||
this.attachmentList = attachmentList;
|
||||
}
|
||||
|
||||
public String getFullFileIds() {
|
||||
return fullFileIds;
|
||||
}
|
||||
|
||||
public void setFullFileIds(String fullFileIds) {
|
||||
this.fullFileIds = fullFileIds;
|
||||
}
|
||||
|
||||
public String getOtherAttachments() {
|
||||
return otherAttachments;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,5 +131,4 @@ public interface ExpertResourceLibraryMapper
|
|||
|
||||
List<KeyValueVo> getAddMemoStatistic(@Param("s") Date s, @Param("e") Date e);
|
||||
|
||||
List<KeyValVo<String, String>> getAttachments(@Param("fullFileIds") String fullFileIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.microservices.dms.resourceLibrary.mapper;
|
|||
|
||||
import com.microservices.common.datasource.annotation.Slave;
|
||||
import com.microservices.dms.achievementLibrary.domain.TokenListVo;
|
||||
import com.microservices.dms.achievementLibrary.domain.blockchain.UserProjectTransferRecords;
|
||||
import com.microservices.dms.common.vo.PrCreateQueryVo;
|
||||
import com.microservices.dms.resourceLibrary.domain.ProjectResourceLibrary;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
|
||||
|
|
@ -60,17 +59,9 @@ public interface ProjectResourceLibraryMapper {
|
|||
|
||||
Long sumProjectIssueToken(@Param("id") Long id);
|
||||
|
||||
Map<String, Object> selectCommitInfo(@Param("commitId") String commitId,@Param("commitDiff") String commitDiff);
|
||||
Map<String, Object> selectCommitInfo(@Param("commitId") String commitId);
|
||||
|
||||
Map<String, Object> selectPrInfo(@Param("prId") String prId);
|
||||
|
||||
Map<String, Object> selectIssueInfo(@Param("issueId") String issueId);
|
||||
|
||||
String getProjectUserIdById(@Param("tokenName")String tokenName);
|
||||
|
||||
Long getUsedApplyToken(@Param("tokenName")String tokenName,@Param("userName") String userName);
|
||||
|
||||
String getUserIdBYLogin(@Param("userId")String userId);
|
||||
|
||||
UserProjectTransferRecords selectIssueEndInfo(@Param("issueId") String issueId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
|
|||
import com.microservices.dms.resourceLibrary.mapper.CompetitionResourceLibraryMapper;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.UserActionDataVo;
|
||||
import com.microservices.dms.resourceLibrary.mapper.TaskResourceLibraryMapper;
|
||||
import com.microservices.dms.utils.DateUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
|
@ -72,7 +71,6 @@ public class CompetitionResourceLibraryService {
|
|||
a.setV(String.format(PROJECT_DOWNLOAD_API, gitLinkUrl, v));
|
||||
}
|
||||
l.setAttachmentList(attachments);
|
||||
l.setSubmissionTime(DateUtil.plusHours(l.getSubmissionTime(), 8));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@ import static com.microservices.dms.constant.TaskConstant.MARKER_SPACE_DOWNLOAD_
|
|||
public class TaskResourceLibraryService {
|
||||
private final TaskResourceLibraryMapper taskResourceLibraryMapper;
|
||||
|
||||
@Value("${makerSpaceUrl}")
|
||||
public String makerSpaceUrl;
|
||||
@Value("${markerSpaceUrl}")
|
||||
public String markerSpaceUrl;
|
||||
|
||||
public int addClick(Clicker click) {
|
||||
click.setCreatedAt(DateUtils.getNowDate());
|
||||
|
|
@ -104,7 +104,7 @@ public class TaskResourceLibraryService {
|
|||
List<KeyValVo<String, String>> attachments = taskResourceLibraryMapper.getAttachments(l.getPaperId());
|
||||
for (KeyValVo<String, String> a : attachments) {
|
||||
Object v = a.getV();
|
||||
a.setV(String.format(MARKER_SPACE_DOWNLOAD_API_BY_ID, makerSpaceUrl, v));
|
||||
a.setV(String.format(MARKER_SPACE_DOWNLOAD_API_BY_ID, markerSpaceUrl, v));
|
||||
}
|
||||
l.setAttachmentList(attachments);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import com.microservices.common.core.utils.StringUtils;
|
|||
import com.microservices.dms.behaviorImage.domain.AchievementBehaviorSumVo;
|
||||
import com.microservices.dms.resourceLibrary.domain.ExpertResourceLibrary;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.ExpertAttachmentVo;
|
||||
import com.microservices.dms.resourceLibrary.domain.vo.KeyValVo;
|
||||
import com.microservices.dms.resourceLibrary.mapper.ExpertResourceLibraryMapper;
|
||||
import com.microservices.dms.resourceLibrary.service.IExpertResourceLibraryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -18,8 +17,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import static com.microservices.dms.constant.TaskConstant.MARKER_SPACE_DOWNLOAD_API_BY_ID;
|
||||
import static com.microservices.dms.constant.TaskConstant.PROJECT_DOWNLOAD_API;
|
||||
import static com.microservices.dms.utils.UrlUtil.getUrlPath;
|
||||
|
||||
/**
|
||||
* 专家资源库Service业务层处理
|
||||
|
|
@ -32,8 +29,8 @@ public class ExpertResourceLibraryServiceImpl implements IExpertResourceLibraryS
|
|||
@Autowired
|
||||
private ExpertResourceLibraryMapper expertResourceLibraryMapper;
|
||||
|
||||
@Value("${makerSpaceUrl}")
|
||||
public String makerSpaceUrl;
|
||||
@Value("${markerSpaceUrl}")
|
||||
public String markerSpaceUrl;
|
||||
/**
|
||||
* 查询专家资源库
|
||||
*
|
||||
|
|
@ -77,12 +74,10 @@ public class ExpertResourceLibraryServiceImpl implements IExpertResourceLibraryS
|
|||
private void buildFullUrl(Map<String, Object> map) {
|
||||
if (map != null && map.containsKey("id") && map.get("id") != null) {
|
||||
String id = map.get("id").toString();
|
||||
map.put("url", String.format(MARKER_SPACE_DOWNLOAD_API_BY_ID, makerSpaceUrl, id));
|
||||
map.put("url", String.format(MARKER_SPACE_DOWNLOAD_API_BY_ID, markerSpaceUrl, id));
|
||||
}
|
||||
}
|
||||
|
||||
@Value("${http.gitLinkUrl}")
|
||||
public String gitLinkUrl;
|
||||
/**
|
||||
* 查询专家资源库列表
|
||||
*
|
||||
|
|
@ -93,31 +88,6 @@ public class ExpertResourceLibraryServiceImpl implements IExpertResourceLibraryS
|
|||
public List<ExpertResourceLibrary> selectExpertResourceLibraryList(ExpertResourceLibrary expertResourceLibrary) {
|
||||
List<ExpertResourceLibrary> expertResourceLibraryList = expertResourceLibraryMapper.selectExpertResourceLibraryList(expertResourceLibrary);
|
||||
for (ExpertResourceLibrary a : expertResourceLibraryList) {
|
||||
//附件组装
|
||||
String fullFileIds = a.getFullFileIds();
|
||||
if(StringUtils.isNotEmpty(fullFileIds)){
|
||||
List<KeyValVo<String, String>> attachments = expertResourceLibraryMapper.getAttachments(fullFileIds);
|
||||
for (KeyValVo<String, String> f: attachments) {
|
||||
String v = String.valueOf(f.getV());
|
||||
if (StringUtils.isNotEmpty(v)) {
|
||||
if (v.startsWith("http")) {
|
||||
String urlPath = getUrlPath(v);
|
||||
if (StringUtils.isNotEmpty(urlPath)) {
|
||||
if (urlPath.startsWith("/api")) {
|
||||
f.setV(gitLinkUrl + urlPath);
|
||||
}else {
|
||||
f.setV(gitLinkUrl +"/api"+ urlPath);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
f.setV(String.format(MARKER_SPACE_DOWNLOAD_API_BY_ID, gitLinkUrl, v));
|
||||
}
|
||||
}
|
||||
}
|
||||
a.setAttachmentList(attachments);
|
||||
a.setAttachments(JSON.toJSONString(attachments));
|
||||
}
|
||||
//头像组装
|
||||
String gender = a.getGender();
|
||||
String img = "images/avatars/User/boy.jpg";
|
||||
if(StringUtils.isNotEmpty(gender) && gender.equals("1")){
|
||||
|
|
|
|||
|
|
@ -112,28 +112,4 @@ public class DateUtil {
|
|||
LocalDateTime s = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
return Date.from(s.plusHours(plusHours).atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
public static String formatLocalDateTimePlusH(LocalDateTime dateTime,long h) {
|
||||
if (dateTime == null) {return null;}
|
||||
|
||||
LocalDateTime localDateTime8 = dateTime.plusHours(h);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
return formatter.format(localDateTime8);
|
||||
}
|
||||
|
||||
|
||||
public Date addHoursToDate(Date date, int hours) {
|
||||
if (date == null) {return null;}
|
||||
// 转换为LocalDateTime
|
||||
LocalDateTime localDateTime = date.toInstant()
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalDateTime();
|
||||
|
||||
// 增加小时
|
||||
localDateTime = localDateTime.plusHours(hours);
|
||||
|
||||
// 转回Date
|
||||
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,185 +0,0 @@
|
|||
package com.microservices.dms.utils;
|
||||
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ExportWordUtil extends Component {
|
||||
|
||||
public static void exportToWord(String outputPath, List<Object[]> data) throws IOException {
|
||||
// 1. 从classpath加载模板文件
|
||||
// ClassLoader classLoader = ExportWordUtilCopy.class.getClassLoader();
|
||||
// try (InputStream is = classLoader.getResourceAsStream("template.docx");
|
||||
// XWPFDocument document = is != null ? new XWPFDocument(is) : null) {
|
||||
XWPFDocument document = new XWPFDocument();
|
||||
// 检查模板是否加载成功
|
||||
if (document == null) {
|
||||
throw new FileNotFoundException("模板文件未找到: template.docx");
|
||||
}
|
||||
// 添加5.1.1项目标题
|
||||
addTitle(document, "5.1.1项目", 1);
|
||||
// 添加迭代标题
|
||||
addTitle(document, "5.1.1.1迭代", 2);
|
||||
// 添加描述段落
|
||||
addParagraph(document, "迭代测试项共包含" + data.size() + "个测试用例,相关用例概述如表5-2所示。");
|
||||
// 设置表格标题
|
||||
setTableCaption(document, "表5-2 迭代功能测试用例概述表");
|
||||
// 创建表格-填充测试用例数据
|
||||
// setStyledTable(document,data);
|
||||
// 保存文档
|
||||
saveDocument(document, outputPath);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private static void saveDocument(XWPFDocument document,String outputPath) throws IOException {
|
||||
File outputFile = new File(outputPath);
|
||||
try (FileOutputStream out = new FileOutputStream(outputFile)) {
|
||||
document.write(out);
|
||||
System.out.println("文件保存成功: " + outputFile.getAbsolutePath());
|
||||
System.out.println("文件大小: " + outputFile.length() + " bytes");
|
||||
}
|
||||
document.close();
|
||||
}
|
||||
|
||||
// 添加标题
|
||||
private static void addTitle(XWPFDocument document, String text, int level) {
|
||||
XWPFParagraph paragraph = document.createParagraph();
|
||||
paragraph.setStyle("Heading" + level);
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(text);
|
||||
run.setBold(true);
|
||||
run.setFontSize(20 - level * 2);
|
||||
}
|
||||
|
||||
// 添加普通段落
|
||||
private static void addParagraph(XWPFDocument document, String text) {
|
||||
XWPFParagraph paragraph = document.createParagraph();
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(text);
|
||||
}
|
||||
|
||||
// 设置表格标题
|
||||
private static void setTableCaption(XWPFDocument document, String caption) {
|
||||
XWPFParagraph paragraph = document.createParagraph();
|
||||
paragraph.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(caption);
|
||||
run.setItalic(true);
|
||||
}
|
||||
|
||||
// 创建带样式的表格
|
||||
private static void setStyledTable(XWPFDocument document, List<Object[]> dataRows) throws IOException {
|
||||
// 3. 添加表格(保留模板样式)
|
||||
if (!dataRows.isEmpty()) {
|
||||
// 获取模板中的表格(假设第一个表格是模板)
|
||||
XWPFTable table = document.getTables().isEmpty() ?
|
||||
document.createTable() : document.getTables().get(0);
|
||||
|
||||
// 清空模板中原有的示例数据行(保留表头和样式行)
|
||||
while (table.getNumberOfRows() > 1) {
|
||||
table.removeRow(1);
|
||||
}
|
||||
|
||||
// 获取样式模板行(通常是第一行)
|
||||
XWPFTableRow styleRow = table.getRow(0);
|
||||
|
||||
// 添加数据行(保留样式)
|
||||
for (Object[] rowData : dataRows) {
|
||||
addStyledTableRow(table, styleRow, rowData);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 添加带样式的表格行
|
||||
private static void addStyledTableRow(XWPFTable table,
|
||||
XWPFTableRow styleRow,
|
||||
Object[] rowData) {
|
||||
// 创建新行
|
||||
XWPFTableRow newRow = table.createRow();
|
||||
|
||||
// 复制样式行的格式
|
||||
if (styleRow != null) {
|
||||
deepCopyStyle(styleRow, newRow);
|
||||
}
|
||||
|
||||
// 填充数据
|
||||
for (int i = 0; i < rowData.length; i++) {
|
||||
XWPFTableCell cell = newRow.getCell(i);
|
||||
if (cell == null) {
|
||||
cell = newRow.addNewTableCell();
|
||||
}
|
||||
|
||||
// 清空原有内容但保留样式
|
||||
cell.removeParagraph(0);
|
||||
XWPFParagraph para = cell.addParagraph();
|
||||
para.setAlignment(ParagraphAlignment.CENTER);
|
||||
|
||||
// 添加数据
|
||||
XWPFRun run = para.createRun();
|
||||
run.setText(rowData[i] != null ? rowData[i].toString() : "");
|
||||
run.setFontSize(10);
|
||||
run.setFontFamily("宋体");
|
||||
}
|
||||
}
|
||||
|
||||
// 深度复制样式(解决部分样式丢失问题)
|
||||
private static void deepCopyStyle(XWPFTableRow source, XWPFTableRow target) {
|
||||
CTRow ctSourceRow = source.getCtRow();
|
||||
CTRow ctTargetRow = target.getCtRow();
|
||||
|
||||
// 复制行属性
|
||||
if (ctSourceRow.getTrPr() != null) {
|
||||
ctTargetRow.setTrPr((CTTrPr) ctSourceRow.getTrPr().copy());
|
||||
}
|
||||
|
||||
// 复制单元格属性
|
||||
for (int i = 0; i < source.getTableCells().size(); i++) {
|
||||
CTTc sourceTc = source.getCell(i).getCTTc();
|
||||
CTTc targetTc = target.getCell(i).getCTTc();
|
||||
|
||||
// 复制单元格属性
|
||||
if (sourceTc.getTcPr() != null) {
|
||||
targetTc.setTcPr((CTTcPr) sourceTc.getTcPr().copy());
|
||||
}
|
||||
|
||||
// 复制段落样式
|
||||
if (!source.getCell(i).getParagraphs().isEmpty()) {
|
||||
XWPFParagraph sourcePara = source.getCell(i).getParagraphs().get(0);
|
||||
XWPFParagraph targetPara = target.getCell(i).getParagraphs().get(0);
|
||||
targetPara.getCTP().setPPr(sourcePara.getCTP().getPPr());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 填充表头
|
||||
private static void fillTableHeader(XWPFTable table, String[] headers) {
|
||||
XWPFTableRow headerRow = table.getRow(0);
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
XWPFTableCell cell = headerRow.getCell(i);
|
||||
cell.removeParagraph(0);
|
||||
XWPFParagraph para = cell.addParagraph();
|
||||
para.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun run = para.createRun();
|
||||
run.setText(headers[i]);
|
||||
run.setBold(true);
|
||||
|
||||
// 设置表头背景色
|
||||
CTShd shd = cell.getCTTc().addNewTcPr().addNewShd();
|
||||
shd.setFill("D3D3D3");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void setCellText(XWPFTableRow row, int col, String text) {
|
||||
XWPFTableCell cell = row.getCell(col);
|
||||
cell.removeParagraph(0);
|
||||
XWPFParagraph para = cell.addParagraph();
|
||||
para.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun run = para.createRun();
|
||||
run.setText(text);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,347 +0,0 @@
|
|||
package com.microservices.dms.utils;
|
||||
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTcPr;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTrPr;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ExportWordUtilCopy extends Component {
|
||||
|
||||
public static void exportToWord(String outputPath,
|
||||
List<Object[]> dataRows) throws Exception {
|
||||
// 1. 从classpath加载模板文件
|
||||
ClassLoader classLoader = ExportWordUtilCopy.class.getClassLoader();
|
||||
try (InputStream is = classLoader.getResourceAsStream("template.docx");
|
||||
XWPFDocument document = is != null ? new XWPFDocument(is) : null) {
|
||||
|
||||
// 检查模板是否加载成功
|
||||
if (document == null) {
|
||||
throw new FileNotFoundException("模板文件未找到: template.docx");
|
||||
}
|
||||
|
||||
// 添加5.1.1项目标题
|
||||
addTitle(document, "5.1.1项目", 1);
|
||||
// 添加迭代标题
|
||||
addTitle(document, "5.1.1.1迭代", 2);
|
||||
// 添加描述段落
|
||||
addParagraph(document, "迭代测试项共包含" + dataRows.size() + "个测试用例,相关用例概述如表5-2所示。");
|
||||
// 设置表格标题
|
||||
setTableCaption(document, "表5-2 迭代功能测试用例概述表");
|
||||
|
||||
// 3. 添加表格(保留模板样式)
|
||||
if (!dataRows.isEmpty()) {
|
||||
// 获取模板中的表格(假设第一个表格是模板)
|
||||
XWPFTable table = document.getTables().isEmpty() ?
|
||||
document.createTable() : document.getTables().get(0);
|
||||
|
||||
// 清空模板中原有的示例数据行(保留表头和样式行)
|
||||
while (table.getNumberOfRows() > 1) {
|
||||
table.removeRow(1);
|
||||
}
|
||||
|
||||
// 获取样式模板行(通常是第一行)
|
||||
XWPFTableRow styleRow = table.getRow(0);
|
||||
|
||||
// 添加数据行(保留样式)
|
||||
for (Object[] rowData : dataRows) {
|
||||
addStyledTableRow(table, styleRow, rowData);
|
||||
}
|
||||
}
|
||||
//5.添加表尾
|
||||
addFooter(document);
|
||||
// 4. 保存文档
|
||||
saveDocument(document, outputPath);
|
||||
}
|
||||
System.out.println("导出完成: " + outputPath);
|
||||
}
|
||||
|
||||
// 设置表格标题
|
||||
private static void setTableCaption(XWPFDocument document, String caption) {
|
||||
XWPFParagraph paragraph = document.createParagraph();
|
||||
paragraph.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(caption);
|
||||
run.setItalic(true);
|
||||
}
|
||||
|
||||
// 添加普通段落
|
||||
private static void addParagraph(XWPFDocument document, String text) {
|
||||
XWPFParagraph paragraph = document.createParagraph();
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(text);
|
||||
}
|
||||
|
||||
// 添加带样式的表格行
|
||||
private static void addStyledTableRow(XWPFTable table,
|
||||
XWPFTableRow styleRow,
|
||||
Object[] rowData) {
|
||||
// 创建新行
|
||||
XWPFTableRow newRow = table.createRow();
|
||||
|
||||
// 复制样式行的格式
|
||||
if (styleRow != null) {
|
||||
deepCopyStyle(styleRow, newRow);
|
||||
}
|
||||
|
||||
// 填充数据
|
||||
for (int i = 0; i < rowData.length; i++) {
|
||||
XWPFTableCell cell = newRow.getCell(i);
|
||||
if (cell == null) {
|
||||
cell = newRow.addNewTableCell();
|
||||
}
|
||||
|
||||
// 清空原有内容但保留样式
|
||||
cell.removeParagraph(0);
|
||||
XWPFParagraph para = cell.addParagraph();
|
||||
para.setAlignment(ParagraphAlignment.CENTER);
|
||||
|
||||
// 添加数据
|
||||
XWPFRun run = para.createRun();
|
||||
run.setText(rowData[i] != null ? rowData[i].toString() : "");
|
||||
run.setFontSize(10);
|
||||
run.setFontFamily("宋体");
|
||||
}
|
||||
}
|
||||
|
||||
// 深度复制样式(解决部分样式丢失问题)
|
||||
private static void deepCopyStyle(XWPFTableRow source, XWPFTableRow target) {
|
||||
CTRow ctSourceRow = source.getCtRow();
|
||||
CTRow ctTargetRow = target.getCtRow();
|
||||
|
||||
// 复制行属性
|
||||
if (ctSourceRow.getTrPr() != null) {
|
||||
ctTargetRow.setTrPr((CTTrPr) ctSourceRow.getTrPr().copy());
|
||||
}
|
||||
|
||||
// 复制单元格属性
|
||||
for (int i = 0; i < source.getTableCells().size(); i++) {
|
||||
CTTc sourceTc = source.getCell(i).getCTTc();
|
||||
CTTc targetTc = target.getCell(i).getCTTc();
|
||||
|
||||
// 复制单元格属性
|
||||
if (sourceTc.getTcPr() != null) {
|
||||
targetTc.setTcPr((CTTcPr) sourceTc.getTcPr().copy());
|
||||
}
|
||||
|
||||
// 复制段落样式
|
||||
if (!source.getCell(i).getParagraphs().isEmpty()) {
|
||||
XWPFParagraph sourcePara = source.getCell(i).getParagraphs().get(0);
|
||||
XWPFParagraph targetPara = target.getCell(i).getParagraphs().get(0);
|
||||
targetPara.getCTP().setPPr(sourcePara.getCTP().getPPr());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addNoDataRow(XWPFTable table) {
|
||||
XWPFTableRow newRow = table.createRow();
|
||||
XWPFTableCell cell = newRow.getCell(0);
|
||||
if (cell == null) return;
|
||||
|
||||
cell.removeParagraph(0);
|
||||
XWPFParagraph para = cell.addParagraph();
|
||||
XWPFRun run = para.createRun();
|
||||
run.setText("查询结果为空");
|
||||
run.setBold(true);
|
||||
run.setColor("FF0000");
|
||||
}
|
||||
|
||||
// 复制行样式
|
||||
private static void copyRowStyle(XWPFTableRow source, XWPFTableRow target) {
|
||||
// 复制行属性
|
||||
if (source.getCtRow().getTrPr() != null) {
|
||||
target.getCtRow().setTrPr((CTTrPr) source.getCtRow().getTrPr().copy());
|
||||
}
|
||||
|
||||
// 复制单元格属性
|
||||
for (int i = 0; i < source.getTableCells().size(); i++) {
|
||||
XWPFTableCell sourceCell = source.getCell(i);
|
||||
XWPFTableCell targetCell = target.getCell(i);
|
||||
|
||||
if (sourceCell != null && targetCell != null) {
|
||||
// 复制单元格属性
|
||||
if (sourceCell.getCTTc().getTcPr() != null) {
|
||||
targetCell.getCTTc().setTcPr((CTTcPr) sourceCell.getCTTc().getTcPr().copy());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addDataRow(XWPFTable table, XWPFTableRow templateRow,
|
||||
Object[] rowData, int rowIndex) {
|
||||
XWPFTableRow newRow = table.createRow();
|
||||
|
||||
// 复制基础行样式
|
||||
if (templateRow.getCtRow().getTrPr() != null) {
|
||||
newRow.getCtRow().setTrPr(templateRow.getCtRow().getTrPr());
|
||||
}
|
||||
|
||||
// 确保单元格数量足够
|
||||
while (newRow.getTableCells().size() < rowData.length) {
|
||||
newRow.addNewTableCell();
|
||||
}
|
||||
|
||||
// 填充数据
|
||||
for (int i = 0; i < rowData.length; i++) {
|
||||
XWPFTableCell cell = newRow.getCell(i);
|
||||
if (cell == null) continue;
|
||||
|
||||
cell.removeParagraph(0);
|
||||
XWPFParagraph para = cell.addParagraph();
|
||||
para.setAlignment(ParagraphAlignment.CENTER);
|
||||
|
||||
XWPFRun run = para.createRun();
|
||||
run.setText(rowData[i] != null ? rowData[i].toString() : "NULL");
|
||||
run.setFontSize(10);
|
||||
// run.setFontFamily("宋体");
|
||||
// 特殊格式处理
|
||||
if (i == 0) {
|
||||
run.setBold(true); // 首列加粗
|
||||
}
|
||||
}
|
||||
// 进度提示
|
||||
if ((rowIndex + 1) % 100 == 0) {
|
||||
System.out.println("已处理 " + (rowIndex + 1) + " 行数据");
|
||||
}
|
||||
}
|
||||
|
||||
private static void saveDocument(XWPFDocument document,String outputPath) throws Exception {
|
||||
File outputFile = new File(outputPath);
|
||||
try (FileOutputStream out = new FileOutputStream(outputFile)) {
|
||||
document.write(out);
|
||||
System.out.println("文件保存成功: " + outputFile.getAbsolutePath());
|
||||
System.out.println("文件大小: " + outputFile.length() + " bytes");
|
||||
}
|
||||
}
|
||||
private static void addDataTable(XWPFDocument document,
|
||||
List<Object[]> dataRows) {
|
||||
// 获取模板中的表格(假设第一个表格是模板)
|
||||
XWPFTable table = document.getTables().isEmpty() ?
|
||||
document.createTable() : document.getTables().get(0);
|
||||
|
||||
// 清空模板中原有的示例数据行(保留表头和样式行)
|
||||
while (table.getNumberOfRows() > 1) {
|
||||
table.removeRow(1);
|
||||
}
|
||||
|
||||
// 3. 获取模板行(第一行)
|
||||
XWPFTableRow templateRow = table.getRow(0);
|
||||
if (templateRow == null) {
|
||||
throw new RuntimeException("模板行获取失败");
|
||||
}
|
||||
// 4. 处理数据
|
||||
System.out.println("待处理数据行数: " + dataRows.size());
|
||||
if (dataRows.isEmpty()) {
|
||||
System.out.println("警告: 无数据,添加提示行");
|
||||
addNoDataRow(table);
|
||||
} else {
|
||||
for (int i = 0; i < dataRows.size(); i++) {
|
||||
addDataRow(table, templateRow, dataRows.get(i), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加标题
|
||||
private static void addTitle(XWPFDocument document, String text, int level) {
|
||||
XWPFParagraph paragraph = document.createParagraph();
|
||||
paragraph.setStyle("Heading" + level);
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(text);
|
||||
run.setBold(true);
|
||||
run.setFontSize(20 - level * 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 模拟数据库数据
|
||||
public static List<Object[]> mockData() {
|
||||
List<Object[]> data = new ArrayList<>();
|
||||
data.add(new Object[]{1, "GN_RJGC_XM_DD_XJDDGLQX", "新建迭代关联缺陷", "关联缺陷","正常"});
|
||||
data.add(new Object[]{2, "GN_RJGC_XM_DD_XJDDGLRW", "新建迭代关联任务", "关联任务","正常"});
|
||||
data.add(new Object[]{3, "GN_RJGC_XM_DD_XJDDGLXQ", "新建迭代关联需求", "关联需求","正常"});
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
private File getExportDirectory(String locationType) {
|
||||
String userHome = System.getProperty("user.home");
|
||||
File exportDir;
|
||||
|
||||
switch (locationType) {
|
||||
case "用户文档目录":
|
||||
exportDir = new File(userHome, "Documents");
|
||||
break;
|
||||
case "桌面":
|
||||
exportDir = new File(userHome, "Desktop");
|
||||
break;
|
||||
case "临时目录":
|
||||
exportDir = new File(System.getProperty("java.io.tmpdir"));
|
||||
break;
|
||||
case "自定义路径":
|
||||
default:
|
||||
JFileChooser chooser = new JFileChooser();
|
||||
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
int result = chooser.showSaveDialog(this);
|
||||
if (result == JFileChooser.APPROVE_OPTION) {
|
||||
exportDir = chooser.getSelectedFile();
|
||||
} else {
|
||||
exportDir = new File(userHome);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// 确保目录存在
|
||||
if (!exportDir.exists()) {
|
||||
exportDir.mkdirs();
|
||||
}
|
||||
|
||||
return exportDir;
|
||||
}
|
||||
|
||||
private File getUniqueFile(File file) {
|
||||
if (!file.exists()) {
|
||||
return file;
|
||||
}
|
||||
|
||||
String name = file.getName();
|
||||
String baseName = name.substring(0, name.lastIndexOf('.'));
|
||||
String extension = name.substring(name.lastIndexOf('.'));
|
||||
|
||||
int counter = 1;
|
||||
File newFile;
|
||||
do {
|
||||
newFile = new File(file.getParentFile(), baseName + "(" + counter + ")" + extension);
|
||||
counter++;
|
||||
} while (newFile.exists());
|
||||
|
||||
return newFile;
|
||||
}
|
||||
|
||||
|
||||
private static void addFooter(XWPFDocument document) {
|
||||
// 添加空行
|
||||
document.createParagraph();
|
||||
|
||||
// 创建页脚段落
|
||||
XWPFParagraph footerPara = document.createParagraph();
|
||||
footerPara.setAlignment(ParagraphAlignment.CENTER);
|
||||
|
||||
XWPFRun footerRun = footerPara.createRun();
|
||||
footerRun.setText("© 2023 数据导出系统 | 自动生成报告");
|
||||
footerRun.setFontSize(9);
|
||||
footerRun.setFontFamily("宋体");
|
||||
footerRun.setColor("7F7F7F");
|
||||
footerRun.setItalic(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,166 +0,0 @@
|
|||
package com.microservices.dms.utils;
|
||||
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
import org.openxmlformats.schemas.wordprocessingml.x2006.main.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ExportWordUtilCopy001 extends Component {
|
||||
|
||||
public static void exportToWord(String outputPath,List<TestCase> testCases) throws Exception {
|
||||
XWPFDocument document = new XWPFDocument();
|
||||
// 添加5.1.1项目标题
|
||||
addTitle(document, "5.1.1项目", 1);
|
||||
|
||||
// 添加迭代标题
|
||||
addTitle(document, "5.1.1.1迭代", 2);
|
||||
|
||||
// 添加描述段落
|
||||
addParagraph(document, "迭代测试项共包含" + testCases.size() + "个测试用例,相关用例概述如表5-2所示。");
|
||||
|
||||
// 创建表格
|
||||
XWPFTable table = createStyledTable(document, testCases.size() + 1, 4); // 行数=用例数+表头
|
||||
|
||||
// 设置表格标题
|
||||
setTableCaption(document, "表5-2 迭代功能测试用例概述表");
|
||||
|
||||
// 填充表头
|
||||
fillTableHeader(table, new String[]{"序号", "测试用例标识", "测试用例名称", "测试用例说明", "正常/异常用例"});
|
||||
|
||||
// 填充测试用例数据
|
||||
fillTestCases(table, testCases);
|
||||
|
||||
// 保存文档
|
||||
try (FileOutputStream out = new FileOutputStream(outputPath)) {
|
||||
document.write(out);
|
||||
}
|
||||
|
||||
document.close();
|
||||
}
|
||||
|
||||
// 添加标题
|
||||
private static void addTitle(XWPFDocument document, String text, int level) {
|
||||
XWPFParagraph paragraph = document.createParagraph();
|
||||
paragraph.setStyle("Heading" + level);
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(text);
|
||||
run.setBold(true);
|
||||
run.setFontSize(20 - level * 2);
|
||||
}
|
||||
|
||||
// 添加普通段落
|
||||
private static void addParagraph(XWPFDocument document, String text) {
|
||||
XWPFParagraph paragraph = document.createParagraph();
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(text);
|
||||
}
|
||||
|
||||
// 设置表格标题
|
||||
private static void setTableCaption(XWPFDocument document, String caption) {
|
||||
XWPFParagraph paragraph = document.createParagraph();
|
||||
paragraph.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun run = paragraph.createRun();
|
||||
run.setText(caption);
|
||||
run.setItalic(true);
|
||||
}
|
||||
|
||||
// 创建带样式的表格
|
||||
private static XWPFTable createStyledTable(XWPFDocument document, int rows, int cols) {
|
||||
XWPFTable table = document.createTable(rows, cols);
|
||||
// 表格宽度设置
|
||||
CTTblPr tblPr = table.getCTTbl().getTblPr();
|
||||
CTTblWidth tblWidth = tblPr.addNewTblW();
|
||||
tblWidth.setW(BigInteger.valueOf(9000));
|
||||
tblWidth.setType(STTblWidth.DXA);
|
||||
|
||||
// 表格边框
|
||||
CTTblBorders borders = tblPr.addNewTblBorders();
|
||||
setBorder(borders.addNewTop(), STBorder.SINGLE, 4, "auto");
|
||||
setBorder(borders.addNewLeft(), STBorder.SINGLE, 4, "auto");
|
||||
setBorder(borders.addNewBottom(), STBorder.SINGLE, 4, "auto");
|
||||
setBorder(borders.addNewRight(), STBorder.SINGLE, 4, "auto");
|
||||
setBorder(borders.addNewInsideH(), STBorder.SINGLE, 2, "auto");
|
||||
setBorder(borders.addNewInsideV(), STBorder.SINGLE, 2, "auto");
|
||||
|
||||
// 表格对齐
|
||||
tblPr.addNewJc().setVal(STJc.CENTER);
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
private static void setBorder(CTBorder border, STBorder.Enum style, int size, String color) {
|
||||
border.setVal(style);
|
||||
border.setSz(BigInteger.valueOf(size));
|
||||
border.setColor(color);
|
||||
}
|
||||
|
||||
// 填充表头
|
||||
private static void fillTableHeader(XWPFTable table, String[] headers) {
|
||||
XWPFTableRow headerRow = table.getRow(0);
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
XWPFTableCell cell = headerRow.getCell(i);
|
||||
|
||||
// 清除单元格原有内容
|
||||
for (int k = cell.getParagraphs().size() - 1; k >= 0; k--) {
|
||||
cell.removeParagraph(k);
|
||||
}
|
||||
|
||||
// 创建新段落和文本
|
||||
XWPFParagraph para = cell.addParagraph();
|
||||
para.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun run = para.createRun();
|
||||
run.setText(headers[i]);
|
||||
run.setBold(true);
|
||||
|
||||
// 设置表头背景色 - 更兼容的写法
|
||||
if (cell.getCTTc().getTcPr() == null) {
|
||||
cell.getCTTc().addNewTcPr();
|
||||
}
|
||||
CTShd shd = cell.getCTTc().getTcPr().isSetShd() ?
|
||||
cell.getCTTc().getTcPr().getShd() :
|
||||
cell.getCTTc().getTcPr().addNewShd();
|
||||
shd.setFill("D3D3D3");
|
||||
shd.setVal(STShd.CLEAR); // 设置填充模式
|
||||
}
|
||||
}
|
||||
|
||||
// 填充测试用例数据
|
||||
private static void fillTestCases(XWPFTable table, List<TestCase> testCases) {
|
||||
for (int i = 0; i < testCases.size(); i++) {
|
||||
TestCase testCase = testCases.get(i);
|
||||
XWPFTableRow row = table.getRow(i + 1); // 第一行是表头
|
||||
|
||||
// 序号
|
||||
setCellText(row, 0, String.valueOf(i + 1));
|
||||
|
||||
// 测试用例标识
|
||||
setCellText(row, 1, testCase.getIdentifier());
|
||||
|
||||
// 测试用例名称
|
||||
setCellText(row, 2, testCase.getName());
|
||||
|
||||
// 测试用例说明
|
||||
setCellText(row, 3, testCase.getDescription());
|
||||
|
||||
// 正常/异常用例
|
||||
setCellText(row, 4, testCase.getType());
|
||||
}
|
||||
}
|
||||
|
||||
private static void setCellText(XWPFTableRow row, int col, String text) {
|
||||
XWPFTableCell cell = row.getCell(col);
|
||||
cell.removeParagraph(0);
|
||||
XWPFParagraph para = cell.addParagraph();
|
||||
para.setAlignment(ParagraphAlignment.CENTER);
|
||||
XWPFRun run = para.createRun();
|
||||
run.setText(text);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package com.microservices.dms.utils;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TestCase {
|
||||
private String id;
|
||||
private String identifier;
|
||||
private String name;
|
||||
private String description;
|
||||
private String type;
|
||||
|
||||
public TestCase(String id, String identifier, String name, String description, String type) {
|
||||
this.id = id;
|
||||
this.identifier = identifier;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="selectAchievementsById" parameterType="Long" resultType="com.microservices.dms.achievementLibrary.domain.Achievements">
|
||||
select a.id,IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName",a.achievement_name,a.hot_rank,a.field_1,a.field_2,a.field_3,a.attachment_count,
|
||||
a.is_expert_audit,a.achievement_type,a.source,a.source_id,a.ext1,a.ext2,a.ext3
|
||||
a.is_expert_audit,a.achievement_type,a.source,a.source_id,a.ext1,a.ext2,a.ext3,
|
||||
,u.login as "userLogin",IFNULL(u.nickname,owner_name) as "userNickName",ue.gender as "gender",
|
||||
a.source_link,a.tags,a.summary,a.publishing_unit,a.address,a.is_featured,a.contact_person,a.contact_number,a.owner_id,a.owner_name, a.status,a.details,
|
||||
a.reviewer,a.review_date,a.review_comments, a.images,a.attachments,a.create_by,a.create_time,a.update_by,a.update_time
|
||||
|
|
@ -251,19 +251,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="getTjByAreas" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
|
||||
select r.name as "name",count(1) as "value" from (
|
||||
select c.name,a.source, a.field_1,c.remark
|
||||
from achievements a
|
||||
left join project_categories c on a.field_1 = c.id
|
||||
where a.source='1' and a.status='1' and a.field_1 is not null and a.field_1 !=""
|
||||
union all
|
||||
select c.name, a.source, a.field_1, c.remark
|
||||
from achievements a
|
||||
left join categories c on a.field_1 = c.id
|
||||
where a.source in ('2','3','4') and a.status='1' and a.field_1 is not null and a.field_1 !=""
|
||||
)r
|
||||
group by r.name
|
||||
order by count(1) desc
|
||||
select c.id as "key", c.name as "name", f.value as "value"
|
||||
from (select a.domain_value as "name", sum(a.countResult) as "value"
|
||||
from (select 'field_1' as domain_type, field_1 as domain_value, count(field_1) as countResult
|
||||
from achievements
|
||||
group by field_1
|
||||
union all
|
||||
select 'field_2' as domain_type, field_2 as domain_value, count(field_2) as countResult
|
||||
from achievements
|
||||
group by field_2
|
||||
union all
|
||||
select 'field_3' as domain_type, field_3 as domain_value, count(field_3) as countResult
|
||||
from achievements
|
||||
group by field_3) a
|
||||
group by a.domain_value
|
||||
order by sum(a.countResult) desc) f
|
||||
right join categories c on c.id = f.name
|
||||
limit 0,5
|
||||
</select>
|
||||
|
||||
|
|
@ -338,24 +341,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
<select id="getaWatcher" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
|
||||
select DATE_FORMAT(created_at, '%m-%d') as 'k', count(*) as 'v'
|
||||
from watchers w
|
||||
inner join achievements a on w.watchable_id = a.id
|
||||
from watchers
|
||||
where created_at >= #{s}
|
||||
and created_at <= #{e}
|
||||
and watchable_type = #{t}
|
||||
and a.status='1'
|
||||
group by DATE_FORMAT(created_at, '%m-%d')
|
||||
order by DATE_FORMAT(created_at, '%m-%d')
|
||||
</select>
|
||||
|
||||
<select id="getFavorite" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
|
||||
select DATE_FORMAT(created_at, '%m-%d') as 'k', count(*) as 'v'
|
||||
from favorites f
|
||||
inner join achievements a on f.favorite_id = a.id
|
||||
from favorites
|
||||
where created_at >= #{s}
|
||||
and created_at <= #{e}
|
||||
and favorite_type = #{t}
|
||||
and a.status='1'
|
||||
group by DATE_FORMAT(created_at, '%m-%d')
|
||||
order by DATE_FORMAT(created_at, '%m-%d')
|
||||
</select>
|
||||
|
|
@ -384,17 +383,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
from achievements
|
||||
where create_time >= #{s}
|
||||
and create_time <= #{e}
|
||||
and source = #{t} and status='1'
|
||||
group by DATE_FORMAT(create_time, '%m-%d')
|
||||
order by DATE_FORMAT(create_time, '%m-%d')
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getExperts" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
|
||||
select DATE_FORMAT(create_time, '%m-%d') as 'k', count(*) as 'v'
|
||||
from expert_resource_library
|
||||
where create_time >= #{s}
|
||||
and create_time <= #{e} and status='1'
|
||||
and source = #{t}
|
||||
group by DATE_FORMAT(create_time, '%m-%d')
|
||||
order by DATE_FORMAT(create_time, '%m-%d')
|
||||
</select>
|
||||
|
|
@ -402,8 +391,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<select id="indexProjectStatistic" resultType="java.util.Map">
|
||||
select COUNT(*) as projectAchievementCount,
|
||||
IFNULL(SUM(attachment_count), 0) as attachmentCount,
|
||||
(select count(1) from clickers c inner join achievements a ON a.id = c.click_id where click_type = 'Achievements' and a.source='1' and a.status='1') as clickCount,
|
||||
(select count(distinct a.source_id) from achievements a join project_resource_library prl on a.source_id = prl.id where a.source='1' and a.status='1') as projectCount
|
||||
(select count(1) from clickers c inner join achievements a ON a.id = c.click_id where click_type = 'Achievements' and a.source='1' and a.status=1) as clickCount,
|
||||
(select COUNT(distinct project_id) from project_resource_library) as projectCount
|
||||
from achievements
|
||||
where source = '1' and status='1'
|
||||
</select>
|
||||
|
|
@ -534,20 +523,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="getAchievementDomain" resultType="java.util.Map">
|
||||
select r.name as "name",count(1) as "value" from (
|
||||
select
|
||||
c.name,a.source, a.field_1,c.remark
|
||||
from achievements a
|
||||
left join project_categories c on a.field_1 = c.id
|
||||
where a.source='1' and a.field_1 is not null and a.field_1 !=""
|
||||
union all
|
||||
select
|
||||
c.name, a.source, a.field_1, c.remark
|
||||
from achievements a
|
||||
left join categories c on a.field_1 = c.id
|
||||
where a.source in ('2','3','4') and a.field_1 is not null and a.field_1 !=""
|
||||
)r
|
||||
group by r.name
|
||||
select c.id as "key", c.name as "name", f.value as "value"
|
||||
from (select a.domain_value as "name", sum(a.countResult) as "value"
|
||||
from (select 'field_1' as domain_type, field_1 as domain_value, count(field_1) as countResult
|
||||
from achievements
|
||||
group by field_1
|
||||
union all
|
||||
select 'field_2' as domain_type, field_2 as domain_value, count(field_2) as countResult
|
||||
from achievements
|
||||
group by field_2
|
||||
union all
|
||||
select 'field_3' as domain_type, field_3 as domain_value, count(field_3) as countResult
|
||||
from achievements
|
||||
group by field_3) a
|
||||
group by a.domain_value
|
||||
order by sum(a.countResult) desc) f
|
||||
right join categories c on c.id = f.name where f.value is not null
|
||||
|
||||
</select>
|
||||
|
||||
<select id="getAchievementAddYearly" resultType="java.util.Map">
|
||||
|
|
@ -557,7 +549,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
order by DATE_FORMAT(create_time, '%Y')
|
||||
</select>
|
||||
<select id="getAchievementHotRank" resultType="java.util.Map">
|
||||
select IFNULL(show_ach_name,achievement_name) as name, create_time as reelaseTime, hot_rank from achievements
|
||||
select achievement_name as name, create_time as reelaseTime, hot_rank from achievements
|
||||
order by hot_rank desc
|
||||
</select>
|
||||
|
||||
|
|
@ -566,117 +558,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="getAreaStatistic" resultType="com.microservices.dms.achievementLibrary.domain.AreaStatisticVo">
|
||||
<if test="source == '' or source == null">
|
||||
select
|
||||
z.name as "areaName",
|
||||
z.field_1 as "areaKey",
|
||||
z.remark as "remark",
|
||||
z.source as "source",
|
||||
sum(z.kyxm) as "kyxmSum",
|
||||
sum(z.ckrw) as "ckrwSum",
|
||||
sum(z.kfjs) as "kfjsSum",
|
||||
sum(z.xqcg) as "xqcgSum"
|
||||
select
|
||||
z.name as "areaName",
|
||||
z.field_1 as "areaKey",
|
||||
z.remark as "remark",
|
||||
sum(z.kyxm) as "kyxmSum",
|
||||
sum(z.ckrw) as "ckrwSum",
|
||||
sum(z.kfjs) as "kfjsSum",
|
||||
sum(z.xqcg) as "xqcgSum"
|
||||
from (
|
||||
select r.name,
|
||||
r.field_1,
|
||||
r.remark,
|
||||
case when r.source = 1 then tmp else 0 end as "kyxm",
|
||||
case when r.source = 2 then tmp else 0 end as "ckrw",
|
||||
case when r.source = 3 then tmp else 0 end as "kfjs",
|
||||
case when r.source = 4 then tmp else 0 end as "xqcg"
|
||||
from (
|
||||
select
|
||||
r.name,
|
||||
r.field_1,
|
||||
r.remark,
|
||||
r.sorceType as "source",
|
||||
case when r.source = 1 then tmp else 0 end as "kyxm",
|
||||
case when r.source = 2 then tmp else 0 end as "ckrw",
|
||||
case when r.source = 3 then tmp else 0 end as "kfjs",
|
||||
case when r.source = 4 then tmp else 0 end as "xqcg"
|
||||
select t.name,t.source,count(1) as "tmp",t.field_1,t.remark
|
||||
from (
|
||||
select
|
||||
t.name,t.source,count(1) as "tmp",t.field_1,t.remark,t.sorceType
|
||||
from (
|
||||
select c.name,a.source, a.field_1,c.remark,"1" as sorceType
|
||||
from achievements a
|
||||
left join project_categories c on a.field_1 = c.id where a.source='1' and c.name is not null
|
||||
union all
|
||||
select c.name, a.source, a.field_1, c.remark,"2" as sorceType
|
||||
from achievements a
|
||||
left join categories c on a.field_1 = c.id where a.source in ('2','3','4') and c.name is not null
|
||||
)t
|
||||
where t.field_1 is not null and t.field_1 !=""
|
||||
group by t.name, t.source, t.field_1, t.remark,t.sorceType
|
||||
) r
|
||||
) z
|
||||
<where>
|
||||
<if test="areaKey != null and areaKey != ''">
|
||||
and z.field_1 = #{areaKey}
|
||||
</if>
|
||||
</where>
|
||||
group by z.name, z.field_1, z.remark, z.source
|
||||
</if>
|
||||
<if test='source=="1"'>
|
||||
select
|
||||
z.name as "areaName",
|
||||
z.field_1 as "areaKey",
|
||||
z.remark as "remark",
|
||||
sum(z.kyxm) as "kyxmSum",
|
||||
sum(z.ckrw) as "ckrwSum",
|
||||
sum(z.kfjs) as "kfjsSum",
|
||||
sum(z.xqcg) as "xqcgSum",
|
||||
"1" as source
|
||||
from (
|
||||
select
|
||||
r.name,
|
||||
r.field_1,
|
||||
r.remark,
|
||||
case when r.source = 1 then tmp else 0 end as "kyxm",
|
||||
case when r.source = 2 then tmp else 0 end as "ckrw",
|
||||
case when r.source = 3 then tmp else 0 end as "kfjs",
|
||||
case when r.source = 4 then tmp else 0 end as "xqcg"
|
||||
from (
|
||||
select c.name,a.source, a.field_1,c.remark,count(1) as "tmp"
|
||||
select c.name,a.source, a.field_1,c.remark
|
||||
from achievements a
|
||||
left join project_categories c on a.field_1 = c.id
|
||||
where a.source='1' and a.field_1 is not null and a.field_1 !=""
|
||||
group by c.name, a.source, a.field_1, c.remark
|
||||
) r
|
||||
) z
|
||||
<where>
|
||||
<if test="areaKey != null and areaKey != ''">
|
||||
and z.field_1 = #{areaKey}
|
||||
</if>
|
||||
</where>
|
||||
group by z.name, z.field_1, z.remark
|
||||
</if>
|
||||
<if test='source=="2" or source=="3" or source=="4" '>
|
||||
select
|
||||
z.name as "areaName",
|
||||
z.field_1 as "areaKey",
|
||||
z.remark as "remark",
|
||||
sum(z.kyxm) as "kyxmSum",
|
||||
sum(z.ckrw) as "ckrwSum",
|
||||
sum(z.kfjs) as "kfjsSum",
|
||||
sum(z.xqcg) as "xqcgSum",
|
||||
"2" as source
|
||||
from (
|
||||
select
|
||||
r.name,
|
||||
r.field_1,
|
||||
r.remark,
|
||||
case when r.source = 1 then tmp else 0 end as "kyxm",
|
||||
case when r.source = 2 then tmp else 0 end as "ckrw",
|
||||
case when r.source = 3 then tmp else 0 end as "kfjs",
|
||||
case when r.source = 4 then tmp else 0 end as "xqcg"
|
||||
from (
|
||||
select c.name, a.source, a.field_1, c.remark,count(1) as tmp
|
||||
from achievements a
|
||||
left join categories c on a.field_1 = c.id
|
||||
where a.source in ('2','3','4') and a.field_1 is not null and a.field_1 !=""
|
||||
group by c.name, a.source, a.field_1, c.remark
|
||||
) r
|
||||
) z
|
||||
<where>
|
||||
<if test="areaKey != null and areaKey != ''">
|
||||
and z.field_1 = #{areaKey}
|
||||
</if>
|
||||
</where>
|
||||
group by z.name, z.field_1, z.remark
|
||||
</if>
|
||||
left join project_categories c on a.field_1 = c.id where a.source='1'
|
||||
union all
|
||||
select c.name, a.source, a.field_1, c.remark
|
||||
from achievements a
|
||||
left join categories c on a.field_1 = c.id where a.source in ('2','3','4')
|
||||
)t
|
||||
where t.field_1 is not null and t.field_1 !=""
|
||||
group by t.name, t.source, t.field_1, t.remark
|
||||
) r
|
||||
) z
|
||||
<where>
|
||||
<if test="areaKey != null and areaKey != ''">
|
||||
and z.field_1 = #{areaKey}
|
||||
</if>
|
||||
</where>
|
||||
group by z.name, z.field_1, z.remark
|
||||
</select>
|
||||
|
||||
<select id="getAllSourceId" resultType="java.lang.Long">
|
||||
|
|
@ -717,7 +635,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
show_ach_name as "showAchievementName",
|
||||
#{paramYear} as resultYear
|
||||
from achievements
|
||||
where summary is not null and source_id in
|
||||
where source_id in
|
||||
<foreach item="fileId" collection="sourceId" open="(" separator="," close=")">
|
||||
#{fileId}
|
||||
</foreach>
|
||||
|
|
@ -785,15 +703,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getField1RemarkByParam" resultType="String">
|
||||
<if test='source != null and source == "1"'>
|
||||
select remark from project_categories where id=#{areaKey}
|
||||
</if>
|
||||
<if test='source != null and source == "2"'>
|
||||
select remark from categories where id =#{areaKey}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getAchievementAddYearlyData" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
|
||||
select DATE_FORMAT(create_time, '%Y-%m') as 'k', count(*) as 'v'
|
||||
from achievements
|
||||
|
|
@ -829,14 +738,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
from users u
|
||||
inner join entities e on u.id = e.user_id
|
||||
inner join personalities p on e.id = p.entity_id
|
||||
inner join (select created_at, user_id from clickers where click_id = #{id} and click_type ='userDocking' ) c on u.id = c.user_id
|
||||
inner join (select created_at, user_id from clickers where click_id = #{id} and click_type ='userDocking' order by created_at desc limit 1) c on u.id = c.user_id
|
||||
where u.authentication='1'
|
||||
union all
|
||||
select u.id,u.login,u.nickname,u.lastname,u.phone,en.name as "company_name",u.mail,en.credit_code as "idNumber",e.entity_type,DATE_FORMAT(c.created_at,'%Y-%m-%d %H:%i:%s') as created_at
|
||||
from users u
|
||||
inner join entities e on u.id = e.user_id
|
||||
inner join enterprises en on e.id = en.entity_id
|
||||
inner join (select created_at,user_id from clickers where click_id = #{id} and click_type ='userDocking') c on u.id = c.user_id
|
||||
inner join (select created_at,user_id from clickers where click_id = #{id} and click_type ='userDocking' order by created_at desc limit 1) c on u.id = c.user_id
|
||||
where u.enterprise_certification='1') t
|
||||
order by t.created_at
|
||||
</select>
|
||||
|
|
@ -844,7 +753,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
|
||||
<select id="selectAchievementsByArea" parameterType="com.microservices.dms.achievementLibrary.domain.AchQueryVo" resultType="com.microservices.dms.achievementLibrary.domain.Achievements">
|
||||
<if test='source=="2"'>
|
||||
<if test="source == '' or source == null">
|
||||
select a.id, IFNULL(a.show_ach_name,a.achievement_name) as "showAchievementName", a.achievement_name, a.summary, a.create_time, a.owner_name, a.tags, a.field_1, a.field_2, a.field_3, a.source, a.source_id,
|
||||
c.name as "field1Name",u.login as "userLogin",
|
||||
IFNULL(u.nickname,a.owner_name) as "userNickName",
|
||||
|
|
@ -858,9 +767,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
left join user_extensions ue on u.id = ue.user_id
|
||||
left join categories c on a.field_1 = c.id
|
||||
<where>
|
||||
and a.source !='1'
|
||||
and a.status='1'
|
||||
<if test="achievementName != null and achievementName != ''"> and a.achievement_name like concat('%', #{achievementName}, '%')</if>
|
||||
<if test="showAchievementName != null and showAchievementName != ''"> and a.show_ach_name like concat('%', #{showAchievementName}, '%')</if>
|
||||
<if test="source != null and source != ''"> and a.source = #{source}</if>
|
||||
<if test='areaQuery != null and areaQuery != "" '>
|
||||
and (a.field_1 = #{areaQuery} or a.field_2 = #{areaQuery} or a.field_3 = #{areaQuery})
|
||||
</if>
|
||||
|
|
@ -881,6 +791,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
left join user_extensions ue on u.id = ue.user_id
|
||||
left join project_categories c on a.field_1 = c.id
|
||||
<where>
|
||||
and a.status='1'
|
||||
<if test="achievementName != null and achievementName != ''"> and a.achievement_name like concat('%', #{achievementName}, '%')</if>
|
||||
<if test="showAchievementName != null and showAchievementName != ''"> and a.show_ach_name like concat('%', #{showAchievementName}, '%')</if>
|
||||
<if test="source != null and source != ''"> and a.source = #{source}</if>
|
||||
|
|
@ -891,40 +802,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
order by create_time desc
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getAllAreas" resultType="com.microservices.dms.achievementLibrary.domain.KeyValueVo">
|
||||
select r.name as "name",GROUP_CONCAT( r.source SEPARATOR ',') as "result"
|
||||
from (
|
||||
select name,CONCAT(id, '_', '2')as source from categories
|
||||
union all
|
||||
select name,CONCAT(id, '_', '1') as source from project_categories
|
||||
)r
|
||||
<where>
|
||||
<if test="areaName != null and areaName != ''">and r.name = #{areaName}</if></where>
|
||||
GROUP BY r.name
|
||||
</select>
|
||||
|
||||
<update id="updateRelationAchievements">
|
||||
<if test='source != null and source == "1"'>
|
||||
update project_resource_library set is_transferred_to_achievement='0' ,transfer_date=null where id = #{sourceId}
|
||||
</if>
|
||||
<if test='source != null and source == "2"'>
|
||||
update task_resource_library set is_transferred_to_results_library='0' ,transfer_to_results_date=null where id = #{sourceId}
|
||||
</if>
|
||||
<if test='source != null and source == "3"'>
|
||||
update competition_resource_library set is_transferred_to_result_library='0' ,transferred_to_result_library_time=null where id = #{sourceId}
|
||||
</if>
|
||||
<if test='source != null and source == "4"'>
|
||||
update school_enterprise_achievements set status=null ,review_comments=null,review_date=null,reviewer=null where id = #{sourceId}
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<select id="getDockingUserInfoList" resultType="java.util.Map">
|
||||
select u.id,u.login,u.nickname,p.name as "lastname,",u.phone,u.company_name,u.mail,p.card as "idNumber",e.entity_type,DATE_FORMAT(ck.created_at,'%Y-%m-%d %H:%i:%s') as created_at
|
||||
from clickers ck
|
||||
inner join users u on ck.user_id = u.id
|
||||
left join entities e on u.id = e.user_id
|
||||
left join personalities p on e.id = p.entity_id
|
||||
where click_type='userDocking' and click_id = #{id}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -139,56 +139,24 @@
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectActivityUserLibraryListAll" resultType="com.microservices.dms.behaviorImage.domain.ActivityUserLibrary" parameterType="com.microservices.dms.behaviorImage.domain.ActivityUserLibrary">
|
||||
SELECT
|
||||
u.id AS userId,
|
||||
u.login AS loginName,
|
||||
u.nickname AS userName,
|
||||
u.is_expert AS isExpert,
|
||||
u.authentication AS isAuth,
|
||||
IFNULL(t.relatedTask, 0) AS relatedTask,
|
||||
IFNULL(c.relatedCompetition, 0) AS relatedCompetition,
|
||||
IFNULL(p1.p1,0) + IFNULL(p2.p2,0) + IFNULL(p3.p3,0) AS relatedProject
|
||||
FROM users u
|
||||
LEFT JOIN (
|
||||
SELECT user_id, COUNT(*) AS relatedTask
|
||||
FROM tasks
|
||||
WHERE is_delete = '0' AND status BETWEEN 3 AND 8
|
||||
GROUP BY user_id
|
||||
) t ON u.id = t.user_id
|
||||
LEFT JOIN (
|
||||
SELECT cu.user_id, COUNT(*) AS relatedCompetition
|
||||
FROM competition_users cu
|
||||
INNER JOIN competition_infos ci ON ci.id = cu.competition_info_id
|
||||
GROUP BY cu.user_id
|
||||
) c ON u.id = c.user_id
|
||||
LEFT JOIN (
|
||||
SELECT user_id, COUNT(*) AS p1
|
||||
FROM projects
|
||||
GROUP BY user_id
|
||||
) p1 ON u.id = p1.user_id
|
||||
LEFT JOIN (
|
||||
SELECT m.user_id, COUNT(*) AS p2
|
||||
FROM members m
|
||||
INNER JOIN projects p ON m.project_id = p.id AND p.user_id != m.user_id
|
||||
GROUP BY m.user_id
|
||||
) p2 ON u.id = p2.user_id
|
||||
LEFT JOIN (
|
||||
SELECT tu.user_id, COUNT(DISTINCT tp.project_id) AS p3
|
||||
FROM team_users tu
|
||||
INNER JOIN teams tm ON tu.team_id = tm.id
|
||||
INNER JOIN team_projects tp ON tm.id = tp.team_id
|
||||
INNER JOIN projects p ON tp.project_id = p.id
|
||||
GROUP BY tu.user_id
|
||||
) p3 ON u.id = p3.user_id
|
||||
WHERE (
|
||||
IFNULL(c.relatedCompetition, 0) > 0
|
||||
OR IFNULL(t.relatedTask, 0) > 0
|
||||
OR (IFNULL(p1.p1,0) + IFNULL(p2.p2,0) + IFNULL(p3.p3,0)) > 0
|
||||
)
|
||||
<if test="userName != null and userName != ''">
|
||||
AND u.nickname like concat('%', #{userName}, '%')
|
||||
</if>
|
||||
<select id="selectActivityUserLibraryListAll" resultType="com.microservices.dms.behaviorImage.domain.ActivityUserLibrary">
|
||||
select res.userId,res.loginName,res.userName,res.isExpert,res.isAuth,res.relatedCompetition,res.relatedTask,res.p1+res.p2+res.p3 as "relatedProject" from (
|
||||
select u.id as "userId",u.login as "loginName",u.nickname as "userName",u.is_expert as "isExpert",u.authentication as "isAuth",
|
||||
(select count(1) as "value" from tasks where is_delete='0' and status between 3 and 8 and user_id =u.id) as "relatedTask",
|
||||
(select count(1) from competition_infos ci inner join competition_users cu on ci.id = cu.competition_info_id where cu.user_id =u.id) as "relatedCompetition",
|
||||
(SELECT count(1) as "pCount" FROM `projects` WHERE id != 0 AND user_id =u.id) as p1,
|
||||
( SELECT count(1) as "pCount"
|
||||
FROM `projects`
|
||||
INNER JOIN `members` ON `members`.`project_id` = `projects`.`id`
|
||||
WHERE `projects`.`id` != 0 AND `projects`.`user_id` !=u.id AND `members`.`user_id` =u.id) as p2,
|
||||
(SELECT count(1) as "pCount"
|
||||
FROM `projects`
|
||||
INNER JOIN `team_projects` ON `team_projects`.`project_id` = `projects`.`id`
|
||||
INNER JOIN `teams` ON `teams`.`id` = `team_projects`.`team_id`
|
||||
INNER JOIN `team_users` ON `team_users`.`team_id` = `teams`.`id`
|
||||
WHERE `projects`.`id` != 0 AND `team_users`.`user_id` =u.id) as p3
|
||||
from users u) res
|
||||
where res.relatedCompetition >0 or res.relatedTask >0 or res.p1+res.p2+res.p3>0
|
||||
</select>
|
||||
|
||||
<select id="getrelatedProjectCount" resultType="long">
|
||||
|
|
@ -339,47 +307,23 @@
|
|||
</select>
|
||||
|
||||
<select id="getActivityStatistic" resultType="com.microservices.dms.behaviorImage.domain.ActivityUserTotal">
|
||||
SELECT
|
||||
COUNT(*) AS totalUser,
|
||||
SUM(u.is_expert) AS totalExpert,
|
||||
SUM(u.authentication + u.enterprise_certification) AS authTotal
|
||||
FROM users u
|
||||
LEFT JOIN (
|
||||
SELECT user_id, COUNT(*) AS relatedTask
|
||||
FROM tasks
|
||||
WHERE is_delete = '0' AND status BETWEEN 3 AND 8
|
||||
GROUP BY user_id
|
||||
) t ON u.id = t.user_id
|
||||
LEFT JOIN (
|
||||
SELECT cu.user_id, COUNT(*) AS relatedCompetition
|
||||
FROM competition_users cu
|
||||
INNER JOIN competition_infos ci ON ci.id = cu.competition_info_id
|
||||
GROUP BY cu.user_id
|
||||
) c ON u.id = c.user_id
|
||||
LEFT JOIN (
|
||||
SELECT user_id, COUNT(*) AS p1
|
||||
FROM projects
|
||||
GROUP BY user_id
|
||||
) p1 ON u.id = p1.user_id
|
||||
LEFT JOIN (
|
||||
SELECT m.user_id, COUNT(*) AS p2
|
||||
FROM members m
|
||||
INNER JOIN projects p ON m.project_id = p.id AND p.user_id != m.user_id
|
||||
GROUP BY m.user_id
|
||||
) p2 ON u.id = p2.user_id
|
||||
LEFT JOIN (
|
||||
SELECT tu.user_id, COUNT(DISTINCT tp.project_id) AS p3
|
||||
FROM team_users tu
|
||||
INNER JOIN teams tm ON tu.team_id = tm.id
|
||||
INNER JOIN team_projects tp ON tm.id = tp.team_id
|
||||
INNER JOIN projects p ON tp.project_id = p.id
|
||||
GROUP BY tu.user_id
|
||||
) p3 ON u.id = p3.user_id
|
||||
WHERE (
|
||||
IFNULL(c.relatedCompetition, 0) > 0
|
||||
OR IFNULL(t.relatedTask, 0) > 0
|
||||
OR (IFNULL(p1.p1, 0) + IFNULL(p2.p2, 0) + IFNULL(p3.p3, 0)) > 0
|
||||
)
|
||||
select count(1) as "totalUser",sum(r.isExpert) as "totalExpert",sum(r.enterprise_certification+r.authentication) as "authTotal" from (
|
||||
select res.userId,res.loginName,res.userName,res.isExpert,res.authentication,res.enterprise_certification,res.relatedCompetition,res.relatedTask,res.p1+res.p2+res.p3 as "relatedProject" from (
|
||||
select u.id as "userId",u.login as "loginName",u.nickname as "userName",u.is_expert as "isExpert",u.authentication,u.enterprise_certification,
|
||||
(select count(1) as "value" from tasks where is_delete='0' and status between 3 and 8 and user_id =u.id) as "relatedTask",
|
||||
(select count(1) from competition_infos ci inner join competition_users cu on ci.id = cu.competition_info_id where cu.user_id =u.id) as "relatedCompetition",
|
||||
(SELECT count(1) as "pCount" FROM `projects` WHERE id != 0 AND user_id =u.id) as p1,
|
||||
( SELECT count(1) as "pCount"
|
||||
FROM `projects` INNER JOIN `members` ON `members`.`project_id` = `projects`.`id`
|
||||
WHERE `projects`.`id` != 0 AND `projects`.`user_id` !=u.id AND `members`.`user_id` =u.id) as p2,
|
||||
(SELECT count(1) as "pCount"
|
||||
FROM `projects`
|
||||
INNER JOIN `team_projects` ON `team_projects`.`project_id` = `projects`.`id`
|
||||
INNER JOIN `teams` ON `teams`.`id` = `team_projects`.`team_id`
|
||||
INNER JOIN `team_users` ON `team_users`.`team_id` = `teams`.`id`
|
||||
WHERE `projects`.`id` != 0 AND `team_users`.`user_id` =u.id) as p3
|
||||
from users u) res
|
||||
where res.relatedCompetition >0 or res.relatedTask >0 or res.p1+res.p2+res.p3>0 )r
|
||||
</select>
|
||||
|
||||
<select id="getUserBehaviorSum" resultType="com.microservices.dms.behaviorImage.domain.UserTypeTotalVo">
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@
|
|||
ci.status as competition_status,
|
||||
cu.works_name as competition_submission_name,
|
||||
cu.created_at as submission_time,
|
||||
IFNULL(cu.leader,us.nickname) as submitter,
|
||||
cu.leader as submitter,
|
||||
submission_type,
|
||||
cu.org_name as submitting_unit,
|
||||
IFNULL(crl.submission_summary,cu.sub_item) as submission_summary,
|
||||
|
|
@ -151,7 +151,6 @@
|
|||
ci.is_expert_audit
|
||||
from competition_infos ci
|
||||
join (select * from competition_users where `status` = 3) cu on ci.id = cu.competition_info_id
|
||||
inner join users us on cu.user_id=us.id
|
||||
left join competition_resource_library crl on crl.competition_user_id = cu.id
|
||||
<where>
|
||||
<if test="openCompetitionId != null ">and open_competition_id = #{openCompetitionId}</if>
|
||||
|
|
@ -190,7 +189,7 @@
|
|||
<if test="image != null and image != ''">and image = #{image}</if>
|
||||
<if test="attachment != null and attachment != ''">and attachment = #{attachment}</if>
|
||||
</where>
|
||||
order by is_transferred_to_result_library,create_time desc,submission_time desc
|
||||
order by is_transferred_to_result_library
|
||||
</select>
|
||||
|
||||
<select id="selectCompetitionResourceLibraryById" parameterType="Long" resultMap="CompetitionResourceLibraryResult">
|
||||
|
|
@ -254,9 +253,9 @@
|
|||
</select>
|
||||
|
||||
<select id="getCompetitionTransferCount" resultType="java.lang.Long">
|
||||
select count(1) from competition_users cu
|
||||
inner join competition_infos ci on cu.competition_info_id = ci.id
|
||||
inner join attachments at on cu.id=at.container_id
|
||||
select COUNT(*)
|
||||
from achievements
|
||||
where source = '3'
|
||||
</select>
|
||||
|
||||
<select id="getCompetitionNeedAuditCount" resultType="java.lang.Long">
|
||||
|
|
@ -275,12 +274,11 @@
|
|||
select t.title as name, achievementCount, enrollCount, paperCount, t.id as `id`,(achievementCount+enrollCount+paperCount) as total
|
||||
from (select c.title,
|
||||
c.id,
|
||||
c.updated_at,
|
||||
(select count(*) from achievements a where source='3' and a.source_id = c.id ) as achievementCount,
|
||||
(select count(*) from competition_users cu where cu.competition_info_id = c.id) as enrollCount,
|
||||
(select count(*) from (select * from competition_users) cu inner join attachments on container_type = 'CompetitionUser' and container_id=cu.id where cu.competition_info_id=c.id) as paperCount
|
||||
from competition_infos c ) as t
|
||||
order by total desc,updated_at desc
|
||||
order by total desc
|
||||
limit 0,10
|
||||
</select>
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,6 @@
|
|||
u.nickname as "userNickName", IFNULL(erl.gender, ue.gender) as "gender",
|
||||
e.id_number,images, attachments,
|
||||
e.major, e.workplace, e.phone,
|
||||
CONCAT_WS(',',resume, title_certificate,academic_achievements,honors) AS fullFileIds,
|
||||
e.workplace_type, e.expert_email, erl.expert_summary, erl.expert_detail, e.professional_title, e.expert_type,
|
||||
expert_domain,u.authentication as expertAuth,
|
||||
e.title_rank, erl.status, e.review_area_one, e.review_area_two, e.review_area_three, e.is_delete, erl.create_by,
|
||||
|
|
@ -137,7 +136,6 @@
|
|||
left join users u on e.user_id = u.id
|
||||
left join user_extensions ue on u.id = ue.user_id
|
||||
<where>
|
||||
and erl.status ='1'
|
||||
<if test="userId != null ">and user_id = #{userId}</if>
|
||||
<if test="expertName != null and expertName != ''">and erl.expert_name like concat('%', #{expertName}, '%')
|
||||
</if>
|
||||
|
|
@ -163,7 +161,6 @@
|
|||
</if>
|
||||
<if test="isDelete != null ">and erl.is_delete = #{isDelete}</if>
|
||||
</where>
|
||||
order by erl.sort_no
|
||||
</select>
|
||||
|
||||
<select id="selectExpertResourceLibraryById" parameterType="Long" resultMap="ExpertResourceLibraryResult">
|
||||
|
|
@ -177,7 +174,7 @@
|
|||
(select COUNT(distinct container_id)
|
||||
from task_expert
|
||||
where expert_id = e.id
|
||||
and container_type = 2 and `status` in (1,2)) as competitionAuditCount
|
||||
and container_type = 2 and `status` in (1,2)) as competitionAuditCount
|
||||
from experts e where is_delete = '0' and status = 1) tmp
|
||||
where tmp.taskAuditCount > 0
|
||||
OR tmp.competitionAuditCount > 0
|
||||
|
|
@ -201,11 +198,10 @@
|
|||
join
|
||||
(select expert_id from task_expert where container_type = 2 and `status` in (1,2) group by expert_id having count(*) > 0) as tmp
|
||||
on erl.expert_id = tmp.expert_id
|
||||
where erl.status='1'
|
||||
</select>
|
||||
<select id="expertResourceCount" resultType="java.lang.Long">
|
||||
select count(*)
|
||||
from expert_resource_library where status='1'
|
||||
from expert_resource_library
|
||||
</select>
|
||||
<select id="auditTaskAuditExpertCount" resultType="java.lang.Long">
|
||||
select count(*)
|
||||
|
|
@ -213,7 +209,6 @@
|
|||
join
|
||||
(select expert_id from task_expert where container_type = 1 and `status` in (1,2) group by expert_id having count(*) > 0) as tmp
|
||||
on erl.expert_id = tmp.expert_id
|
||||
where erl.status='1'
|
||||
</select>
|
||||
|
||||
<insert id="insertExpertResourceLibrary" parameterType="ExpertResourceLibrary" useGeneratedKeys="true"
|
||||
|
|
@ -432,14 +427,14 @@
|
|||
tmp.taskAuditCount as "taskAuditSum",
|
||||
tmp.competitionAuditCount as "competitionAuditSum",
|
||||
(tmp.taskAuditCount + tmp.competitionAuditCount) as "total"
|
||||
from (select e.expert_name,e.created_on,
|
||||
from (select e.expert_name,
|
||||
(select COUNT(distinct container_id) from task_expert where expert_id = e.id and container_type = 1 and `status` in (1,2)) as taskAuditCount,
|
||||
(select COUNT(distinct container_id) from task_expert where expert_id = e.id and container_type = 2 and `status` in (1,2)) as competitionAuditCount
|
||||
from experts e
|
||||
left join users u on e.user_id = u.id
|
||||
where e.is_delete = '0'
|
||||
and e.status = 1) tmp
|
||||
order by (tmp.taskAuditCount + tmp.competitionAuditCount) desc,tmp.created_on desc
|
||||
order by (tmp.taskAuditCount + tmp.competitionAuditCount) desc
|
||||
limit 0,12
|
||||
</select>
|
||||
|
||||
|
|
@ -552,9 +547,4 @@
|
|||
<select id="getAttachmentInfo" resultType="java.util.Map">
|
||||
select file_name,id,unique_file_name from busi_attachments where id = #{id} limit 1
|
||||
</select>
|
||||
|
||||
|
||||
<select id="getAttachments" resultType="com.microservices.dms.resourceLibrary.domain.vo.KeyValVo">
|
||||
select id as v, file_name as k from busi_attachments where FIND_IN_SET (id,#{fullFileIds})
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
i.description as "content",
|
||||
i.author_id as "author_id",
|
||||
i.blockchain_token_num as "blockchain_token_num",
|
||||
(select IFNULL(NULLIF(nickname,'') ,login) from users where id = i.author_id) as "createBy",
|
||||
(select IFNULL(nickname,login) from users where id = i.author_id) as "createBy",
|
||||
i.due_date,
|
||||
(select GROUP_CONCAT(assigner_id SEPARATOR ', ')
|
||||
from issue_assigners
|
||||
|
|
@ -56,31 +56,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
inner join issue_statuses it on i.status_id = it.id
|
||||
inner join projects p on i.project_id = p.id
|
||||
inner join repositories r on p.id = r.project_id
|
||||
where p.use_blockchain='1' and i.project_issues_index is not null
|
||||
where p.use_blockchain='1'
|
||||
<if test="projectName != null and projectName != ''">and p.name like concat('%', #{projectName}, '%')</if>
|
||||
<if test="issueName != null and issueName != ''">and i.subject like concat('%', #{issueName}, '%')</if>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="commitDataList" resultType="java.util.Map">
|
||||
select cl.commit_id as "commit_id",
|
||||
re.id as "repo_id",
|
||||
cl.repository_id as "repo_id",
|
||||
cl.user_id as "committer",
|
||||
(select IFNULL(NULLIF(nickname, ''),login) from users where id = cl.user_id) as "createBy",
|
||||
(select IFNULL(nickname,login) from users where id = cl.user_id) as "createBy",
|
||||
cl.project_id,p.name as "project_name",
|
||||
cl.message as "content",
|
||||
cl.created_at as "committer_time",
|
||||
cl.message as "content",
|
||||
re.user_id as "author",
|
||||
ibd.tx_hash as "commitHash",
|
||||
cl.ref as "commit_diff"
|
||||
ibd.tx_hash as "commitHash"
|
||||
from commit_logs cl
|
||||
inner join projects p on cl.project_id = p.id
|
||||
inner join repositories re on p.id = re.project_id
|
||||
inner join in_blockchain_data ibd on cl.commit_id = ibd.type_id
|
||||
left join repositories re on cl.repository_id = re.id
|
||||
left join in_blockchain_data ibd on cl.commit_id = ibd.type_id
|
||||
where p.use_blockchain = '1'
|
||||
<if test="projectName != null and projectName != ''">and p.name like concat('%', #{projectName}, '%')</if>
|
||||
order by ibd.create_time desc,cl.created_at desc
|
||||
</select>
|
||||
|
||||
<select id="prDataList" resultType="java.util.Map">
|
||||
|
|
@ -97,7 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
pr.base as "target_branch",
|
||||
target.id as "target_repo_id",
|
||||
pr.created_at,
|
||||
pr.updated_at,p.name as "projectName",(select IFNULL(NULLIF(nickname, ''),login) from users where id = pr.user_id) as "createBy"
|
||||
pr.updated_at,p.name as "projectName",(select IFNULL(nickname,login) from users where id = pr.user_id) as "createBy"
|
||||
from pull_requests pr
|
||||
inner join projects p on pr.project_id = p.id
|
||||
inner join repositories source on p.id = source.project_id
|
||||
|
|
@ -147,23 +144,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="getNeedToBlockCommitList" resultType="String">
|
||||
select
|
||||
cl.commit_id as "commit_id"
|
||||
from commit_logs cl
|
||||
inner join projects p on cl.project_id = p.id
|
||||
left join repositories re on cl.repository_id = re.id
|
||||
left join in_blockchain_data ibd on cl.commit_id = ibd.type_id
|
||||
where p.use_blockchain = '1' and ibd.tx_hash is null
|
||||
</select>
|
||||
|
||||
<select id="getCommitListById" resultType="com.microservices.dms.common.vo.CommitResultVo">
|
||||
select
|
||||
cl.commit_id as "commit_id",cl.ref as "commit_diff"
|
||||
from commit_logs cl
|
||||
inner join projects p on cl.project_id = p.id
|
||||
left join in_blockchain_data ibd on cl.commit_id = ibd.type_id
|
||||
where p.use_blockchain = '1' and ibd.tx_hash is null and p.id = #{projectId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -216,7 +216,7 @@
|
|||
<if test="attachments != null and attachments != ''">and attachments = #{attachments}</if>
|
||||
<if test="projectDomain != null and projectDomain != ''">and project_domain = #{projectDomain}</if>
|
||||
</where>
|
||||
order by is_transferred_to_achievement,create_time desc,release_date desc
|
||||
order by is_transferred_to_achievement
|
||||
</select>
|
||||
|
||||
<select id="selectProjectResourceLibraryById" parameterType="Long" resultMap="ProjectResourceLibraryResult">
|
||||
|
|
@ -370,18 +370,18 @@
|
|||
</select>
|
||||
|
||||
<select id="selectProjectInfos" resultType="com.microservices.dms.achievementLibrary.domain.TokenListVo">
|
||||
select p.id, p.name, created_on createdOn, r.identifier repositoryName, r.id as repositoryId,p.user_id as "userId",
|
||||
(select IFNULL(NULLIF(nickname,''),login) from users where id = p.user_id) as createBy
|
||||
select p.id, p.name, created_on createdOn, r.identifier repositoryName, r.id as repositoryId,
|
||||
(select IFNULL(users.nickname,login) from users where id = p.user_id) as createBy
|
||||
from projects p
|
||||
join repositories r on p.id = r.project_id
|
||||
where p.use_blockchain = 1
|
||||
<if test="name != null and name != ''">and p.name like concat('%', #{name}, '%')</if>
|
||||
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
|
||||
</select>
|
||||
|
||||
<select id="sumProjectIssueToken" resultType="java.lang.Long">
|
||||
select IFNULL(sum(i.blockchain_token_num),0)
|
||||
from issues i
|
||||
inner join projects p on i.project_id = p.id
|
||||
inner join projects p on i.project_id = p.id
|
||||
where p.id=#{id}
|
||||
</select>
|
||||
|
||||
|
|
@ -395,12 +395,12 @@
|
|||
cl.message as "content",
|
||||
re.user_id as "author",
|
||||
'' as "committer_time",
|
||||
cl.ref as "commit_diff"
|
||||
'' as "commit_diff"
|
||||
from commit_logs cl
|
||||
inner join projects p on cl.project_id = p.id
|
||||
left join repositories re on cl.repository_id = re.id
|
||||
where p.use_blockchain = '1'
|
||||
and cl.commit_id = #{commitId} and cl.ref = #{commitDiff}
|
||||
and cl.commit_id = #{commitId}
|
||||
</select>
|
||||
|
||||
<select id="selectPrInfo" resultType="java.util.Map">
|
||||
|
|
@ -448,25 +448,4 @@
|
|||
where p.use_blockchain='1' and i.id = #{issueId}
|
||||
</select>
|
||||
|
||||
<select id="getProjectUserIdById" resultType="String">
|
||||
select u.id from projects p
|
||||
inner join users u on p.user_id=u.id
|
||||
where p.id = #{tokenName}
|
||||
</select>
|
||||
|
||||
<select id="getUsedApplyToken" resultType="Long">
|
||||
select IFNULL(sum(token),0) as "totalSum" from user_project_transfer_records where project_id =#{tokenName} and payee_id !=#{userName}
|
||||
</select>
|
||||
|
||||
<select id="getUserIdBYLogin" resultType="String">
|
||||
select id from users where login=#{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectIssueEndInfo" resultType="com.microservices.dms.achievementLibrary.domain.blockchain.UserProjectTransferRecords">
|
||||
select i.project_id as "projectId",i.blockchain_token_num as "token", ia.assigner_id as "payeeId",p.user_id as "payerId"
|
||||
from issues i
|
||||
inner join issue_assigners ia on i.id= ia.issue_id
|
||||
inner join projects p on i.project_id = p.id
|
||||
where issue_id = #{issueId} and status_id in ('1','2') and i.blockchain_token_num >0
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="achievementLittleType != null and achievementLittleType != ''"> and achievement_little_type = #{achievementLittleType}</if>
|
||||
<if test="teamName != null and teamName != ''"> and team_name = #{teamName}</if>
|
||||
</where>
|
||||
order by status desc,create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectSchoolEnterpriseAchievementsById" parameterType="Long" resultMap="SchoolEnterpriseAchievementsResult">
|
||||
|
|
@ -89,12 +88,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectSchoolEnterpriseAchievementsByName" resultMap="SchoolEnterpriseAchievementsResult">
|
||||
<include refid="selectSchoolEnterpriseAchievementsVo"/>
|
||||
where achievement_name = #{achievementName}
|
||||
limit 0,1
|
||||
</select>
|
||||
|
||||
<select id="topStatistic" resultType="java.lang.Long">
|
||||
select count(*) from school_enterprise_achievements
|
||||
<where>
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@
|
|||
<where>
|
||||
<if test="id != null ">and id = #{id}</if>
|
||||
<if test="projectId != null ">and project_id = #{projectId}</if>
|
||||
<if test="subject != null and subject != ''">and `subject` = #{subject}</if>
|
||||
<if test="issueClassify != null and issueClassify != ''">and `issue_classify` = #{issueClassify}</if>
|
||||
<if test="subject != null ">and `subject` = #{subject}</if>
|
||||
<if test="statusIds != null and statusIds.size() > 0">and status_id in
|
||||
<foreach item="item" collection="statusIds" open="(" separator="," close=")">
|
||||
#{item}
|
||||
|
|
|
|||
|
|
@ -42,12 +42,10 @@
|
|||
</trim>
|
||||
</insert>
|
||||
<select id="countClicker" resultType="java.lang.Long">
|
||||
select count(*) from clickers c
|
||||
inner join achievements a ON a.id = c.click_id
|
||||
select count(*) from clickers c inner join achievements a ON a.id = c.click_id
|
||||
<where>
|
||||
and a.status='1'
|
||||
<if test="null != clickType and '' != clickType">
|
||||
and c.click_type = #{clickType}
|
||||
c.click_type = #{clickType}
|
||||
</if>
|
||||
and a.source='4'
|
||||
</where>
|
||||
|
|
@ -55,11 +53,9 @@
|
|||
|
||||
<select id="countClickerSimple" resultType="java.lang.Long">
|
||||
select count(*) from clickers c
|
||||
inner join expert_resource_library erl on c.click_id = erl.id
|
||||
<where>
|
||||
and erl.status='1'
|
||||
<if test="null != clickType and '' != clickType">
|
||||
and c.click_type = #{clickType}
|
||||
c.click_type = #{clickType}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
|
@ -448,8 +444,7 @@
|
|||
pd.paper_id as paper_id,
|
||||
t.name as task_name,
|
||||
IFNULL(ts.task_domain, t.category_id) as task_domain,
|
||||
t.bounty as task_total_amount,
|
||||
ROUND(t.bounty / (select count(1) from papers where status = 2 and t.id = task_id),2) as task_amount,
|
||||
t.bounty as task_amount,
|
||||
p.number as submission_name,
|
||||
p.created_at as submission_date,
|
||||
(select u.login from users u where u.id = p.user_id) as submitter_name,
|
||||
|
|
@ -505,7 +500,7 @@
|
|||
<if test="imageUrl != null and imageUrl != ''">and image_url = #{imageUrl}</if>
|
||||
<if test="attachmentUrl != null and attachmentUrl != ''">and attachment_url = #{attachmentUrl}</if>
|
||||
</where>
|
||||
order by is_transferred_to_results_library,create_time desc,submission_date desc
|
||||
order by is_transferred_to_results_library
|
||||
</select>
|
||||
|
||||
<select id="selectTaskResourceLibraryById" parameterType="Long" resultMap="TaskResourceLibraryResult">
|
||||
|
|
@ -527,13 +522,22 @@
|
|||
</select>
|
||||
|
||||
<select id="getConvertedTaskAmount" resultType="java.lang.Double">
|
||||
select IFNULL(SUM(task_amount), 0) from task_resource_library where is_transferred_to_results_library = 1
|
||||
select IFNULL(SUM(bounty), 0)
|
||||
from (select distinct t.id, t.bounty
|
||||
from tasks t
|
||||
join (select distinct task_id from papers where status = 2) p on t.id = p.task_id
|
||||
join task_resource_library on t.id = task_resource_library.task_id
|
||||
where is_transferred_to_results_library = 1) tmp
|
||||
</select>
|
||||
|
||||
<select id="getConvertedTaskAmount2" resultType="java.lang.Double">
|
||||
select IFNULL(SUM(t.task_amount), 0) from achievements a
|
||||
inner join task_resource_library t on a.source_id = t.id
|
||||
where a.source='2' and a.status= '1'
|
||||
select IFNULL(SUM(bounty), 0)
|
||||
from (select distinct t.id, t.bounty
|
||||
from tasks t
|
||||
join (select task_id from papers where status = 2) p on t.id = p.task_id
|
||||
join task_resource_library on t.id = task_resource_library.task_id
|
||||
join achievements a on a.source_id = task_resource_library.id and a.source='2' and a.status= '1'
|
||||
where is_transferred_to_results_library = 1) tmp
|
||||
</select>
|
||||
|
||||
<select id="getConvertedTasksCount" resultType="java.lang.Long">
|
||||
|
|
|
|||
|
|
@ -54,8 +54,8 @@
|
|||
</select>
|
||||
|
||||
<select id="userDataList" resultType="java.util.Map">
|
||||
select * from ( select p.name projectName,payer_id,payee_id,uptr.token,uptr.tx_hash,uptr.type,
|
||||
(select IFNULL(nickname,login) from users where id = uptr.payer_id) as "payerName" ,
|
||||
select * from ( select p.name projectName,payer_id,payee_id,uptr.token,uptr.tx_hash,
|
||||
(select IFNULL(nickname,login) from users where id = uptr.payer_id) as "payerName" ,
|
||||
(select IFNULL(nickname,login) from users where id = uptr.payee_id) as "payeeName"
|
||||
from user_project_transfer_records uptr join projects p on uptr.project_id = p.id)tmp
|
||||
<where>
|
||||
|
|
|
|||
|
|
@ -12,12 +12,10 @@ public class MakerSpaceTotalDataVo {
|
|||
|
||||
private int totalApplicants;
|
||||
|
||||
private float currentTotalAwardAmount;
|
||||
private int currentTotalAwardAmount;
|
||||
|
||||
private float paidAwardAmount;
|
||||
|
||||
private int totalVisits;
|
||||
|
||||
private List<Object> taskPublishedCountsByYear;
|
||||
|
||||
private List<Object> taskBountyCountsByYear;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public interface TasksMapper{
|
|||
|
||||
int getTotalApplicantCount();
|
||||
|
||||
float getCurrentTotalAwardAmount();
|
||||
int getCurrentTotalAwardAmount();
|
||||
|
||||
List<Object> getTaskPublishedCountsByYear();
|
||||
|
||||
|
|
@ -46,6 +46,4 @@ public interface TasksMapper{
|
|||
Map<String, String> getTaskStatisticsByStatus(@Param("status") Integer status);
|
||||
|
||||
List<Map<String, String>> getTaskUserOperLogTopN(@Param("topNum") Integer topNum, @Param("taskLogOperations") String[] taskLogOperations);
|
||||
|
||||
int getTotalVisits();
|
||||
}
|
||||
|
|
@ -40,9 +40,8 @@ public class TasksServiceImpl implements ITasksService {
|
|||
MakerSpaceTotalDataVo makerSpaceTotalDataVo = new MakerSpaceTotalDataVo();
|
||||
makerSpaceTotalDataVo.setTotalTasks(tasksMapper.getTotalTaskCount());
|
||||
makerSpaceTotalDataVo.setTotalApplicants(tasksMapper.getTotalApplicantCount());
|
||||
makerSpaceTotalDataVo.setCurrentTotalAwardAmount(tasksMapper.getCurrentTotalAwardAmount() /10000L);
|
||||
makerSpaceTotalDataVo.setCurrentTotalAwardAmount(tasksMapper.getCurrentTotalAwardAmount()/10000);
|
||||
makerSpaceTotalDataVo.setPaidAwardAmount(tasksMapper.getPaidAwardAmount()/10000);
|
||||
makerSpaceTotalDataVo.setTotalVisits(tasksMapper.getTotalVisits());
|
||||
makerSpaceTotalDataVo.setTaskPublishedCountsByYear(tasksMapper.getTaskPublishedCountsByYear());
|
||||
makerSpaceTotalDataVo.setTaskBountyCountsByYear(tasksMapper.getTaskBountyCountsByYear());
|
||||
return makerSpaceTotalDataVo;
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
from papers
|
||||
where is_delete = 0 and parent_id = 0
|
||||
</select>
|
||||
<select id="getCurrentTotalAwardAmount" resultType="java.lang.Float">
|
||||
select COALESCE(SUM(bounty), 0)
|
||||
<select id="getCurrentTotalAwardAmount" resultType="java.lang.Integer">
|
||||
select sum(bounty)
|
||||
from tasks
|
||||
where is_delete = 0 and `status` between 3 and 8
|
||||
</select>
|
||||
|
|
@ -208,14 +208,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
GROUP BY publish_mode
|
||||
</select>
|
||||
<select id="getPaidAwardAmount" resultType="java.lang.Float">
|
||||
SELECT COALESCE(SUM(bounty), 0) AS total_bounty
|
||||
SELECT SUM(bounty)
|
||||
FROM tasks
|
||||
WHERE is_delete = 0 AND `status` = 8;
|
||||
</select>
|
||||
<select id="getTotalVisits" resultType="java.lang.Integer">
|
||||
SELECT COALESCE(SUM(visits), 0) AS total_visits
|
||||
FROM tasks
|
||||
WHERE is_delete = 0;
|
||||
WHERE is_delete = 0 AND `status` = 8 and except_closed_boolean = 0;
|
||||
</select>
|
||||
<select id="getTaskStatisticsByStatus" resultType="java.util.Map">
|
||||
<if test = "status == 3">
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import com.microservices.common.security.annotation.EnableRyFeignClients;
|
|||
import com.microservices.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* 文件服务
|
||||
|
|
@ -16,7 +15,6 @@ import org.springframework.scheduling.annotation.EnableScheduling;
|
|||
@EnableCustomConfig
|
||||
@SpringBootApplication
|
||||
@EnableRyFeignClients
|
||||
@EnableScheduling
|
||||
public class MicroservicesFileApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MicroservicesFileApplication.class, args);
|
||||
|
|
|
|||
|
|
@ -1,176 +0,0 @@
|
|||
package com.microservices.file.controller;
|
||||
|
||||
import com.microservices.common.core.web.controller.BaseController;
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
import com.microservices.common.core.web.domain.GenericsAjaxResult;
|
||||
import com.microservices.file.domain.vo.CheckChunkVo;
|
||||
import com.microservices.file.domain.vo.CheckInstantUploadVo;
|
||||
import com.microservices.file.domain.vo.InitChunkedUploadVo;
|
||||
import com.microservices.file.domain.vo.UploadProgressVo;
|
||||
import com.microservices.file.domain.vo.input.CheckInstantUploadInputVo;
|
||||
import com.microservices.file.domain.vo.input.InitChunkedUploadInputVo;
|
||||
import com.microservices.file.domain.vo.response.*;
|
||||
import com.microservices.file.service.IChunkedUploadService;
|
||||
import com.microservices.system.api.domain.SysFileInfo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 分片上传控制器
|
||||
*
|
||||
* @author microservices
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/chunked")
|
||||
@Api(tags = "分片上传接口")
|
||||
public class ChunkedUploadController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IChunkedUploadService chunkedUploadService;
|
||||
|
||||
/**
|
||||
* 初始化分片上传
|
||||
* <p>
|
||||
* 功能:
|
||||
* 1. 创建上传会话
|
||||
* 2. 根据文件大小判断哈希类型(FULL/SAMPLE)
|
||||
* 3. 返回采样点信息(SAMPLE类型)
|
||||
*
|
||||
* @param input 初始化上传请求参数
|
||||
* @return 初始化结果,包含 uploadId、totalChunks、chunkSize、hashType、sampleChunks
|
||||
*/
|
||||
@PostMapping("/init")
|
||||
@ApiOperation("初始化分片上传")
|
||||
public GenericsAjaxResult<InitChunkedUploadResponseVo> initChunkedUpload(@Validated @RequestBody InitChunkedUploadInputVo input) {
|
||||
InitChunkedUploadVo result = chunkedUploadService.initChunkedUpload(input);
|
||||
return genericsSuccess(InitChunkedUploadResponseVo.from(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查秒传(简化版)
|
||||
* <p>
|
||||
* 功能:
|
||||
* 1. 校验上传会话和时间窗口
|
||||
* 2. 查询是否存在相同的 file_hash 且状态为已完成
|
||||
* 3. 秒传成功:删除当前会话,返回已存在文件信息
|
||||
* 4. 不能秒传:返回继续上传
|
||||
*
|
||||
* @param input 检查秒传请求参数
|
||||
* @return 检查结果
|
||||
*/
|
||||
@PostMapping("/checkInstantUpload")
|
||||
@ApiOperation("检查秒传")
|
||||
public GenericsAjaxResult<CheckInstantUploadResponseVo> checkInstantUpload(@Validated @RequestBody CheckInstantUploadInputVo input) {
|
||||
CheckInstantUploadVo result = chunkedUploadService.checkInstantUpload(input.getUploadId(), input.getFileSignature());
|
||||
return genericsSuccess(CheckInstantUploadResponseVo.from(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查分片是否已上传(断点续传)
|
||||
*
|
||||
* @param uploadId 上传ID
|
||||
* @param chunkNumber 分片序号
|
||||
* @return 分片检查结果
|
||||
*/
|
||||
@GetMapping("/check/{uploadId}/{chunkNumber}")
|
||||
@ApiOperation("检查分片是否已上传")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "uploadId", value = "上传ID", paramType = "path", dataType = "String", required = true),
|
||||
@ApiImplicitParam(name = "chunkNumber", value = "分片序号", paramType = "path", dataType = "Integer", required = true)
|
||||
})
|
||||
public GenericsAjaxResult<CheckChunkResponseVo> checkChunk(@PathVariable("uploadId") String uploadId, @PathVariable("chunkNumber") Integer chunkNumber) {
|
||||
CheckChunkVo result = chunkedUploadService.checkChunk(uploadId, chunkNumber);
|
||||
return genericsSuccess(CheckChunkResponseVo.from(result));
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传分片
|
||||
*
|
||||
* @param uploadId 上传ID
|
||||
* @param chunkNumber 分片序号
|
||||
* @param chunk 分片文件
|
||||
* @return 上传结果
|
||||
*/
|
||||
@PostMapping("/upload/{uploadId}/{chunkNumber}")
|
||||
@ApiOperation("上传分片")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "uploadId", value = "上传ID", paramType = "path", dataType = "String", required = true),
|
||||
@ApiImplicitParam(name = "chunkNumber", value = "分片序号", paramType = "path", dataType = "Integer", required = true),
|
||||
@ApiImplicitParam(name = "chunk", value = "分片文件", paramType = "form", dataType = "_file", required = true)
|
||||
})
|
||||
public GenericsAjaxResult<UploadChunkResponseVo> uploadChunk(
|
||||
@PathVariable("uploadId") String uploadId,
|
||||
@PathVariable("chunkNumber") Integer chunkNumber,
|
||||
@RequestPart("chunk") MultipartFile chunk) {
|
||||
chunkedUploadService.uploadChunk(uploadId, chunkNumber, chunk);
|
||||
return genericsSuccess(UploadChunkResponseVo.success(chunkNumber));
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并分片(异步)
|
||||
* <p>
|
||||
* 功能:
|
||||
* 1. 提交合并任务,立即返回
|
||||
* 2. 客户端通过轮询进度接口获取合并结果
|
||||
*
|
||||
* @param uploadId 上传ID
|
||||
* @return 合并任务提交结果
|
||||
*/
|
||||
@PostMapping("/merge/{uploadId}")
|
||||
@ApiOperation("合并分片")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "uploadId", value = "上传ID", paramType = "path", dataType = "String", required = true)
|
||||
})
|
||||
public GenericsAjaxResult<Map<String, String>> mergeChunks(@PathVariable("uploadId") String uploadId) {
|
||||
chunkedUploadService.mergeChunks(uploadId);
|
||||
Map<String, String> result = new HashMap<>();
|
||||
result.put("uploadId", uploadId);
|
||||
result.put("message", "合并任务已提交,请通过进度接口查询结果");
|
||||
return genericsSuccess(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消上传
|
||||
* <p>
|
||||
* 功能:
|
||||
* 1. 删除上传会话记录
|
||||
* 2. 清理已上传的分片文件
|
||||
*
|
||||
* @param uploadId 上传ID
|
||||
* @return 取消结果
|
||||
*/
|
||||
@DeleteMapping("/cancel/{uploadId}")
|
||||
@ApiOperation("取消上传")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "uploadId", value = "上传ID", paramType = "path", dataType = "String", required = true)
|
||||
})
|
||||
public GenericsAjaxResult<CancelUploadResponseVo> cancelUpload(@PathVariable("uploadId") String uploadId) {
|
||||
boolean result = chunkedUploadService.cancelUpload(uploadId);
|
||||
return genericsSuccess(result ? CancelUploadResponseVo.success() : CancelUploadResponseVo.failed("取消上传失败"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传进度
|
||||
*
|
||||
* @param uploadId 上传ID
|
||||
* @return 上传进度
|
||||
*/
|
||||
@GetMapping("/progress/{uploadId}")
|
||||
@ApiOperation("获取上传进度")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "uploadId", value = "上传ID", paramType = "path", dataType = "String", required = true)
|
||||
})
|
||||
public GenericsAjaxResult<UploadProgressResponseVo> getProgress(@PathVariable("uploadId") String uploadId) {
|
||||
UploadProgressVo progress = chunkedUploadService.getProgress(uploadId);
|
||||
return genericsSuccess(UploadProgressResponseVo.from(progress));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue