接口审核问题
This commit is contained in:
parent
b343abf8ed
commit
2073049b66
@ -2,6 +2,7 @@ package ink.wgink.gatewaymanage.controller.api.api.permission;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.exceptions.ParamsException;
|
||||
import ink.wgink.gatewaymanage.pojo.dtos.api.ApiClaimDTO;
|
||||
import ink.wgink.gatewaymanage.pojo.dtos.api.ApiDTO;
|
||||
import ink.wgink.gatewaymanage.service.api.permission.IApiPermissionService;
|
||||
import ink.wgink.gatewaymanage.service.claim.IClaimService;
|
||||
@ -69,7 +70,7 @@ public class ApiPermissionController extends DefaultBaseController {
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage-claim/{claimType}")
|
||||
public SuccessResultList<List<ApiDTO>> listPageClaim(@PathVariable("claimType") String claimType, ListPage page) {
|
||||
public SuccessResultList<List<ApiClaimDTO>> listPageClaim(@PathVariable("claimType") String claimType, ListPage page) {
|
||||
if (!StringUtils.equals(IClaimService.CLAIM_TYPE_ALL, claimType) &&
|
||||
!StringUtils.equals(IClaimService.CLAIM_TYPE_CLAIM, claimType) &&
|
||||
!StringUtils.equals(IClaimService.CLAIM_TYPE_UNCLAIMED, claimType)) {
|
||||
|
@ -135,4 +135,13 @@ public interface IApiDao extends IInitBaseTable {
|
||||
* @throws SearchException
|
||||
*/
|
||||
ExamineDTO getExamineResult(Map<String, Object> params) throws SearchException;
|
||||
|
||||
/**
|
||||
* 接口ID列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws SearchException
|
||||
*/
|
||||
List<String> listId(Map<String, Object> params) throws SearchException;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package ink.wgink.gatewaymanage.pojo.dtos.api;
|
||||
|
||||
import ink.wgink.gatewaymanage.pojo.dtos.claim.ClaimDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName: ApiClaimDTO
|
||||
* @Description: 接口认领
|
||||
* @Author: CodeFactory
|
||||
* @Date: 2021-08-16 14:50:40
|
||||
* @Version: 3.0
|
||||
**/
|
||||
@ApiModel
|
||||
public class ApiClaimDTO extends ApiDTO {
|
||||
|
||||
private ClaimDTO claim;
|
||||
|
||||
public ClaimDTO getClaim() {
|
||||
return claim == null ? new ClaimDTO() : claim;
|
||||
}
|
||||
|
||||
public void setClaim(ClaimDTO claim) {
|
||||
this.claim = claim;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package ink.wgink.gatewaymanage.pojo.dtos.api;
|
||||
|
||||
import ink.wgink.gatewaymanage.pojo.dtos.claim.ClaimDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
@ -57,8 +56,6 @@ public class ApiDTO {
|
||||
private String gmtCreate;
|
||||
@ApiModelProperty(name = "gmtModified", value = "修改时间")
|
||||
private String gmtModified;
|
||||
@ApiModelProperty(name = "claim", value = "认领情况")
|
||||
private ClaimDTO claim;
|
||||
|
||||
public String getApiId() {
|
||||
return apiId == null ? "" : apiId.trim();
|
||||
@ -228,11 +225,4 @@ public class ApiDTO {
|
||||
this.gmtModified = gmtModified;
|
||||
}
|
||||
|
||||
public ClaimDTO getClaim() {
|
||||
return claim == null ? new ClaimDTO() : claim;
|
||||
}
|
||||
|
||||
public void setClaim(ClaimDTO claim) {
|
||||
this.claim = claim;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName: ClaimDTO
|
||||
* @Description: 接口认领
|
||||
* @Author: CodeFactory
|
||||
|
@ -217,6 +217,30 @@ public interface IApiService {
|
||||
*/
|
||||
SuccessResultList<List<ApiDTO>> listPage(ListPage page);
|
||||
|
||||
/**
|
||||
* API列表
|
||||
*
|
||||
* @param systemIds
|
||||
* @return
|
||||
*/
|
||||
List<ApiDTO> listBySystemIds(List<String> systemIds);
|
||||
|
||||
/**
|
||||
* 接口ID列表
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<String> listId(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 接口ID列表
|
||||
*
|
||||
* @param systemIds
|
||||
* @return
|
||||
*/
|
||||
List<String> listIdBySystemIds(List<String> systemIds);
|
||||
|
||||
/**
|
||||
* 接口统计
|
||||
*
|
||||
|
@ -18,6 +18,7 @@ import ink.wgink.gatewaymanage.pojo.vos.api.ApiVO;
|
||||
import ink.wgink.gatewaymanage.pojo.vos.examine.ExamineVO;
|
||||
import ink.wgink.gatewaymanage.pojo.vos.message.MessageVO;
|
||||
import ink.wgink.gatewaymanage.service.api.IApiService;
|
||||
import ink.wgink.gatewaymanage.service.claim.IClaimService;
|
||||
import ink.wgink.gatewaymanage.service.message.IMessageService;
|
||||
import ink.wgink.gatewaymanage.service.system.ISystemService;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
@ -47,6 +48,8 @@ public class ApiServiceImpl extends DefaultBaseService implements IApiService {
|
||||
@Autowired
|
||||
private ISystemService systemService;
|
||||
@Autowired
|
||||
private IClaimService claimService;
|
||||
@Autowired
|
||||
private IMessageService messageService;
|
||||
@Autowired
|
||||
private KafkaTemplate<String, Object> kafkaTemplate;
|
||||
@ -100,10 +103,13 @@ public class ApiServiceImpl extends DefaultBaseService implements IApiService {
|
||||
|
||||
@Override
|
||||
public void removeBySystemIds(List<String> systemIds) {
|
||||
List<String> apiIds = listIdBySystemIds(systemIds);
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("systemIds", systemIds);
|
||||
setUpdateInfo(params);
|
||||
apiDao.remove(params);
|
||||
// 删除接口认领记录
|
||||
claimService.deleteByApiIds(apiIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,6 +117,8 @@ public class ApiServiceImpl extends DefaultBaseService implements IApiService {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("apiIds", ids);
|
||||
apiDao.delete(params);
|
||||
// 删除接口认领记录
|
||||
claimService.deleteByApiIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -224,6 +232,25 @@ public class ApiServiceImpl extends DefaultBaseService implements IApiService {
|
||||
return new SuccessResultList<>(apiDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApiDTO> listBySystemIds(List<String> systemIds) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("systemIds", systemIds);
|
||||
return list(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listId(Map<String, Object> params) {
|
||||
return apiDao.listId(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listIdBySystemIds(List<String> systemIds) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("systemIds", systemIds);
|
||||
return listId(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer count(Map<String, Object> params) {
|
||||
Integer count = apiDao.count(params);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package ink.wgink.gatewaymanage.service.api.permission;
|
||||
|
||||
import ink.wgink.gatewaymanage.pojo.dtos.api.ApiClaimDTO;
|
||||
import ink.wgink.gatewaymanage.pojo.dtos.api.ApiDTO;
|
||||
import ink.wgink.pojo.ListPage;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
@ -39,5 +40,5 @@ public interface IApiPermissionService {
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<ApiDTO>> listPageClaim(String claimType, ListPage page);
|
||||
SuccessResultList<List<ApiClaimDTO>> listPageClaim(String claimType, ListPage page);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package ink.wgink.gatewaymanage.service.api.permission.impl;
|
||||
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.gatewaymanage.pojo.dtos.api.ApiClaimDTO;
|
||||
import ink.wgink.gatewaymanage.pojo.dtos.api.ApiDTO;
|
||||
import ink.wgink.gatewaymanage.pojo.dtos.claim.ClaimDTO;
|
||||
import ink.wgink.gatewaymanage.pojo.pos.claim.ClaimPO;
|
||||
@ -47,7 +48,7 @@ public class ApiPermissionServiceImpl extends DefaultBaseService implements IApi
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<ApiDTO>> listPageClaim(String claimType, ListPage page) {
|
||||
public SuccessResultList<List<ApiClaimDTO>> listPageClaim(String claimType, ListPage page) {
|
||||
// 我的认领列表
|
||||
List<ClaimPO> claimPOs = claimPermissionService.listPO();
|
||||
Set<String> apiIds = new HashSet<>();
|
||||
@ -56,26 +57,38 @@ public class ApiPermissionServiceImpl extends DefaultBaseService implements IApi
|
||||
}
|
||||
if (StringUtils.equals(IClaimService.CLAIM_TYPE_CLAIM, claimType)) {
|
||||
if (claimPOs.isEmpty()) {
|
||||
return new SuccessResultList<List<ApiDTO>>(new ArrayList<>(), 1, 0L);
|
||||
return new SuccessResultList<>(new ArrayList<>(), 1, 0L);
|
||||
}
|
||||
page.getParams().put("claimApiIds", new ArrayList<>(apiIds));
|
||||
} else if (StringUtils.equals(IClaimService.CLAIM_TYPE_UNCLAIMED, claimType)) {
|
||||
page.getParams().put("unclaimedApiIds", new ArrayList<>(apiIds));
|
||||
}
|
||||
page.getParams().put("auditStatus", "pass");
|
||||
SuccessResultList<List<ApiDTO>> listSuccessResultList = apiService.listPage(page);
|
||||
SuccessResultList<List<ApiDTO>> apiSuccessResultList = apiService.listPage(page);
|
||||
List<ClaimDTO> claimDTOs = new ArrayList<>();
|
||||
for (ApiDTO apiDTO : listSuccessResultList.getRows()) {
|
||||
List<ApiClaimDTO> apiClaimDTOs = new ArrayList<>();
|
||||
apiSuccessResultList.getRows().forEach(apiDTO -> {
|
||||
ApiClaimDTO apiClaimDTO = new ApiClaimDTO();
|
||||
apiClaimDTO.setApiId(apiDTO.getApiId());
|
||||
apiClaimDTO.setSystemId(apiDTO.getSystemId());
|
||||
apiClaimDTO.setSystemName(apiDTO.getSystemName());
|
||||
apiClaimDTO.setTitle(apiDTO.getTitle());
|
||||
apiClaimDTO.setUrl(apiDTO.getUrl());
|
||||
apiClaimDTO.setSummary(apiDTO.getSummary());
|
||||
apiClaimDTO.setPublishTime(apiDTO.getPublishTime());
|
||||
apiClaimDTO.setMethod(apiDTO.getMethod());
|
||||
for (ClaimPO claimPO : claimPOs) {
|
||||
if (StringUtils.equals(apiDTO.getApiId(), claimPO.getApiId())) {
|
||||
ClaimDTO claimDTO = new ClaimDTO();
|
||||
BeanUtils.copyProperties(claimPO, claimDTO);
|
||||
apiDTO.setClaim(claimDTO);
|
||||
apiClaimDTO.setClaim(claimDTO);
|
||||
claimDTOs.add(claimDTO);
|
||||
}
|
||||
}
|
||||
}
|
||||
apiClaimDTOs.add(apiClaimDTO);
|
||||
});
|
||||
// 设置审核人
|
||||
claimService.setAuditor(claimDTOs);
|
||||
return listSuccessResultList;
|
||||
return new SuccessResultList<>(apiClaimDTOs, apiSuccessResultList.getPage(), apiSuccessResultList.getTotal());
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,13 @@ public interface IClaimService {
|
||||
*/
|
||||
void delete(List<String> ids);
|
||||
|
||||
/**
|
||||
* 删除接口认领(物理删除)
|
||||
*
|
||||
* @param apiIds
|
||||
*/
|
||||
void deleteByApiIds(List<String> apiIds);
|
||||
|
||||
/**
|
||||
* 修改接口认领
|
||||
*
|
||||
@ -213,4 +220,5 @@ public interface IClaimService {
|
||||
* @param claimDTOs
|
||||
*/
|
||||
void setAuditor(List<ClaimDTO> claimDTOs);
|
||||
|
||||
}
|
@ -97,6 +97,13 @@ public class ClaimServiceImpl extends DefaultBaseService implements IClaimServic
|
||||
claimDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByApiIds(List<String> apiIds) {
|
||||
Map<String, Object> params = getHashMap(2);
|
||||
params.put("apiIds", apiIds);
|
||||
claimDao.delete(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String claimId, ClaimVO claimVO) {
|
||||
update(null, claimId, claimVO);
|
||||
@ -228,22 +235,32 @@ public class ClaimServiceImpl extends DefaultBaseService implements IClaimServic
|
||||
List<ApiPO> apiPOs = apiService.listPO(new ArrayList<>(apiSet));
|
||||
|
||||
for (ClaimDTO claimDTO : claimDTOs) {
|
||||
boolean isSystemExist = false;
|
||||
boolean isApiExist = false;
|
||||
for (SystemPO systemPO : systemPOs) {
|
||||
if (StringUtils.equals(claimDTO.getSystemId(), systemPO.getSystemId())) {
|
||||
SystemDTO systemDTO = new SystemDTO();
|
||||
BeanUtils.copyProperties(systemPO, systemDTO);
|
||||
claimDTO.setSystem(systemDTO);
|
||||
isSystemExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isSystemExist) {
|
||||
claimDTO.setSystem(new SystemDTO());
|
||||
}
|
||||
for (ApiPO apiPO : apiPOs) {
|
||||
if (StringUtils.equals(claimDTO.getApiId(), apiPO.getApiId())) {
|
||||
ApiDTO apiDTO = new ApiDTO();
|
||||
BeanUtils.copyProperties(apiPO, apiDTO);
|
||||
claimDTO.setApi(apiDTO);
|
||||
isApiExist = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!isApiExist) {
|
||||
claimDTO.setApi(new ApiDTO());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,8 @@ public class SystemServiceImpl extends DefaultBaseService implements ISystemServ
|
||||
@Override
|
||||
public void remove(List<String> ids) {
|
||||
remove(null, ids);
|
||||
// 删除API
|
||||
apiService.removeBySystemIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -94,6 +96,8 @@ public class SystemServiceImpl extends DefaultBaseService implements ISystemServ
|
||||
params.put("systemIds", ids);
|
||||
systemDao.delete(params);
|
||||
deleteDependency(ids);
|
||||
// 删除API
|
||||
apiService.deleteBySystemIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -429,6 +429,13 @@
|
||||
#{apiIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="systemIds != null and systemIds != ''">
|
||||
AND
|
||||
t1.system_id IN
|
||||
<foreach collection="systemIds" index="index" open="(" separator="," close=")">
|
||||
#{systemIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="creator != null and creator != ''">
|
||||
AND
|
||||
t1.creator = #{creator}
|
||||
@ -575,7 +582,26 @@
|
||||
FROM
|
||||
api_api t1
|
||||
WHERE
|
||||
t1.is_delete = 0
|
||||
AND
|
||||
t1.api_id = #{apiId}
|
||||
</select>
|
||||
|
||||
<!-- 接口ID列表 -->
|
||||
<select id="listId" parameterType="map" resultType="String">
|
||||
SELECT
|
||||
api_id
|
||||
FROM
|
||||
api_api
|
||||
WHERE
|
||||
is_delete = 0
|
||||
<if test="systemIds != null and systemIds.size > 0">
|
||||
AND
|
||||
system_id IN
|
||||
<foreach collection="systemIds" index="index" open="(" separator="," close=")">
|
||||
#{systemIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -89,10 +89,24 @@
|
||||
DELETE FROM
|
||||
api_claim
|
||||
WHERE
|
||||
<if test="claimIds != null and claimIds.size > 0">
|
||||
claim_id IN
|
||||
<foreach collection="claimIds" index="index" open="(" separator="," close=")">
|
||||
#{claimIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="systemIds != null and systemIds.size > 0">
|
||||
system_id IN
|
||||
<foreach collection="systemIds" index="index" open="(" separator="," close=")">
|
||||
#{systemIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="apiIds != null and apiIds.size > 0">
|
||||
api_id IN
|
||||
<foreach collection="apiIds" index="index" open="(" separator="," close=")">
|
||||
#{apiIds[${index}]}
|
||||
</foreach>
|
||||
</if>
|
||||
</update>
|
||||
|
||||
<!-- 修改接口认领 -->
|
||||
|
@ -62,6 +62,7 @@
|
||||
|
||||
// 初始化表格
|
||||
function initTable() {
|
||||
var cols =
|
||||
table.render({
|
||||
elem: '#dataTable',
|
||||
id: 'dataTable',
|
||||
|
Loading…
Reference in New Issue
Block a user