Commit f56b60e8 by zhiwj

发布小红点

parent 2b9bacdb
......@@ -50,4 +50,24 @@ public interface DataExplainApiService {
* @throws
*/
ServiceResponse<Page<DataExplainDTO>> listDataExplain(DataExplainQO dataExplainQO);
/**
* @Title: delete
* @Description:
* @author zhiwj
* @param dataExplainId
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>
* @throws
*/
ServiceResponse<Void> delete(Integer dataExplainId);
/**
* @Title: publish
* @Description:
* @author zhiwj
* @param dataExplainId
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>
* @throws
*/
ServiceResponse<Void> publish(Integer dataExplainId);
}
......@@ -50,4 +50,25 @@ public interface IndexApiService {
* @throws
*/
ServiceResponse<Page<IndexDTO>> listIndex(IndexQO indexQO);
/**
* @Title: delete
* @Description:
* @author zhiwj
* @param indexId
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>
* @throws
*/
ServiceResponse<Void> delete(Integer indexId);
/**
* 发布指标
* @Title: publish
* @Description:
* @author zhiwj
* @param indexId
* @return com.gic.api.base.commons.ServiceResponse<java.lang.Void>
* @throws
*/
ServiceResponse<Void> publish(Integer indexId);
}
......@@ -63,4 +63,16 @@ public class DataExplainController {
return ResultControllerUtils.commonResult(serviceResponse);
}
@RequestMapping("/deleteDataExplain")
public RestResponse delete(Integer dataExplainId) {
ServiceResponse<Void> serviceResponse = dataExplainApiService.delete(dataExplainId);
return ResultControllerUtils.commonResult(serviceResponse);
}
@RequestMapping("/publishDataExplain")
public RestResponse publishIndex(Integer dataExplainId) {
ServiceResponse<Void> serviceResponse = dataExplainApiService.publish(dataExplainId);
return ResultControllerUtils.commonResult(serviceResponse);
}
}
\ No newline at end of file
......@@ -75,4 +75,15 @@ public class IndexController {
return ResultControllerUtils.commonResult(serviceResponse);
}
@RequestMapping("/deleteIndex")
public RestResponse delete(Integer indexId) {
ServiceResponse<Void> serviceResponse = indexApiService.delete(indexId);
return ResultControllerUtils.commonResult(serviceResponse);
}
@RequestMapping("/publishIndex")
public RestResponse publishIndex(Integer indexId) {
ServiceResponse<Void> serviceResponse = indexApiService.publish(indexId);
return ResultControllerUtils.commonResult(serviceResponse);
}
}
\ No newline at end of file
......@@ -60,7 +60,9 @@ public interface TabIndexModuleRelMapper {
void updateStatusByBusinessIds(@Param("businessId") Integer businessId, @Param("ids") List<Integer> moduleIdList, @Param("type") Integer type);
List<Integer> listModuleIdByIndexId(@Param("indexId") Integer indexId);
List<Integer> listModuleIdByBusinessId(@Param("businessId") Integer businessId, @Param("type") Integer type);
List<Integer> listIndexIdByModuleId(@Param("moduleId") Integer moduleId);
List<Integer> listBusinessIdByModuleId(@Param("moduleId") Integer moduleId);
List<TabIndexModuleRel> listModuleIdByBusinessIds(@Param("ids") List<Integer> businessIdList, @Param("type") Integer type);
}
\ No newline at end of file
......@@ -25,4 +25,6 @@ public interface DataExplainService {
Page<TabDataExplain> listDataExplain(DataExplainQO dataExplainQO);
List<TabDataExplain> listAllDataExplain();
void deleteById(Integer dataExplainId);
}
package com.gic.cloud.service;
import java.util.List;
import java.util.Map;
/**
* @author zhiwj
......@@ -10,7 +11,11 @@ import java.util.List;
public interface IndexModuleRelService {
void save(Integer indexId, List<Integer> moduleId, Integer type);
List<Integer> listModuleIdByIndexId(Integer indexId);
List<Integer> listModuleIdByBusinessId(Integer indexId, Integer type);
List<Integer> listIndexIdByModuleId(Integer moduleId);
List<Integer> listBusinessIdByModuleId(Integer moduleId);
void deleteByBusinessId(Integer businessId, Integer type);
Map<Integer, List<Integer>> groupModuleIdByBusinessIds(List<Integer> indexIdList, Integer type);
}
......@@ -27,4 +27,6 @@ public interface IndexService {
Page<TabIndex> listIndex(IndexQO indexQO);
List<TabIndex> listAllIndex();
void deleteById(Integer indexId);
}
......@@ -63,4 +63,12 @@ public class DataExplainServiceImpl implements DataExplainService {
public List<TabDataExplain> listAllDataExplain() {
return tabDataExplainMapper.listDataExplain(new DataExplainQO());
}
@Override
public void deleteById(Integer dataExplainId) {
TabDataExplain dataExplain = new TabDataExplain();
dataExplain.setDataExplainId(dataExplainId);
dataExplain.setStatus(0);
tabDataExplainMapper.updateByPrimaryKeySelective(dataExplain);
}
}
......@@ -6,8 +6,8 @@ import com.gic.cloud.service.IndexModuleRelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author zhiwj
......@@ -40,12 +40,25 @@ public class IndexModuleRelServiceImpl implements IndexModuleRelService {
}
@Override
public List<Integer> listModuleIdByIndexId(Integer indexId) {
return tabIndexModuleRelMapper.listModuleIdByIndexId(indexId);
public List<Integer> listModuleIdByBusinessId(Integer businessId, Integer type) {
return tabIndexModuleRelMapper.listModuleIdByBusinessId(businessId, type);
}
@Override
public List<Integer> listIndexIdByModuleId(Integer moduleId) {
return tabIndexModuleRelMapper.listIndexIdByModuleId(moduleId);
public List<Integer> listBusinessIdByModuleId(Integer moduleId) {
return tabIndexModuleRelMapper.listBusinessIdByModuleId(moduleId);
}
@Override
public void deleteByBusinessId(Integer businessId, Integer type) {
tabIndexModuleRelMapper.delByBusinessId(businessId, type);
}
@Override
public Map<Integer, List<Integer>> groupModuleIdByBusinessIds(List<Integer> businessIdList, Integer type) {
List<TabIndexModuleRel> relList = tabIndexModuleRelMapper.listModuleIdByBusinessIds(businessIdList, type);
return Optional.ofNullable(relList).orElse(Collections.emptyList()).stream()
.collect(Collectors.groupingBy(TabIndexModuleRel::getBusinessId,
Collectors.mapping(TabIndexModuleRel::getIndexModuleRelId, Collectors.toList())));
}
}
......@@ -68,4 +68,12 @@ public class IndexServiceImpl implements IndexService {
public List<TabIndex> listAllIndex() {
return tabIndexMapper.listIndex(new IndexQO());
}
@Override
public void deleteById(Integer indexId) {
TabIndex index = new TabIndex();
index.setIndexId(indexId);
index.setStatus(0);
tabIndexMapper.updateByPrimaryKeySelective(index);
}
}
......@@ -81,4 +81,23 @@ public class DataExplainApiServiceImpl implements DataExplainApiService {
Page<DataExplainDTO> dtoPage = PageHelperUtils.changePageHelperToCurrentPage(listDataExplain, DataExplainDTO.class);
return EnterpriseServiceResponse.success(dtoPage);
}
@Override
public ServiceResponse<Void> delete(Integer dataExplainId) {
TabDataExplain dataExplain = this.dataExplainService.getByDataExplainId(dataExplainId);
if (dataExplain == null) {
return EnterpriseServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "数据解读不存在或已删除");
}
if (dataExplain.getModuleId() == null) {
return EnterpriseServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "不能删除被引用的指标");
}
this.dataExplainService.deleteById(dataExplainId);
return EnterpriseServiceResponse.success();
}
@Override
public ServiceResponse<Void> publish(Integer dataExplainId) {
this.updateTipService.publish(dataExplainId, LogAndUpdateTipsTypeEnum.DATA_EXPLAIN.getCode());
return EnterpriseServiceResponse.success();
}
}
......@@ -12,10 +12,13 @@ import com.gic.commons.util.EntityUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.response.EnterpriseServiceResponse;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author zhiwj
......@@ -86,7 +89,7 @@ public class IndexApiServiceImpl implements IndexApiService {
public ServiceResponse<IndexDTO> getByIndexId(Integer indexId) {
TabIndex index = this.indexService.getByIndexId(indexId);
IndexDTO indexDTO = EntityUtil.changeEntityByJSON(IndexDTO.class, index);
List<Integer> moduleIdList = this.indexModuleRelService.listModuleIdByIndexId(indexDTO.getIndexId());
List<Integer> moduleIdList = this.indexModuleRelService.listModuleIdByBusinessId(indexDTO.getIndexId(), LogAndUpdateTipsTypeEnum.INDEX.getCode());
indexDTO.setRelModuleIdList(moduleIdList);
return EnterpriseServiceResponse.success(indexDTO);
}
......@@ -95,6 +98,35 @@ public class IndexApiServiceImpl implements IndexApiService {
public ServiceResponse<Page<IndexDTO>> listIndex(IndexQO indexQO) {
com.github.pagehelper.Page<TabIndex> indexList = indexService.listIndex(indexQO);
Page<IndexDTO> indexDTOPage = PageHelperUtils.changePageHelperToCurrentPage(indexList, IndexDTO.class);
if (CollectionUtils.isNotEmpty(indexList)) {
List<Integer> indexIdList = indexList.stream().map(TabIndex::getIndexId).collect(Collectors.toList());
Map<Integer, List<Integer>> moduleIdByBusinessIdMap = indexModuleRelService.groupModuleIdByBusinessIds(indexIdList, LogAndUpdateTipsTypeEnum.INDEX.getCode());
List<IndexDTO> indexDTOList = indexDTOPage.getResult();
for (IndexDTO indexDTO : indexDTOList) {
indexDTO.setRelModuleIdList(moduleIdByBusinessIdMap.get(indexDTO.getIndexId()));
}
}
return EnterpriseServiceResponse.success(indexDTOPage);
}
@Override
public ServiceResponse<Void> delete(Integer indexId) {
TabIndex index = this.indexService.getByIndexId(indexId);
if (index == null) {
return EnterpriseServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "指标不存在或已删除");
}
List<Integer> moduleIdList = indexModuleRelService.listModuleIdByBusinessId(indexId, LogAndUpdateTipsTypeEnum.INDEX.getCode());
if (CollectionUtils.isNotEmpty(moduleIdList)) {
return EnterpriseServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "不能删除被引用的指标");
}
this.indexService.deleteById(indexId);
this.indexModuleRelService.deleteByBusinessId(indexId, LogAndUpdateTipsTypeEnum.INDEX.getCode());
return EnterpriseServiceResponse.success();
}
@Override
public ServiceResponse<Void> publish(Integer indexId) {
this.updateTipService.publish(indexId, LogAndUpdateTipsTypeEnum.INDEX.getCode());
return EnterpriseServiceResponse.success();
}
}
......@@ -156,16 +156,27 @@
</foreach>
</if>
</update>
<select id="listModuleIdByIndexId" resultType="int">
<select id="listModuleIdByBusinessId" resultType="int">
select
module_id
from tab_index_module_rel
where status = 1 and index_id = #{indexId}
where status = 1 and index_id = #{businessId} and type = #{type}
</select>
<select id="listIndexIdByModuleId" resultType="int">
<select id="listBusinessIdByModuleId" resultType="int">
select
module_id
from tab_index_module_rel
where status = 1 and module_id = #{moduleId}
</select>
<select id="listModuleIdByBusinessIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tab_index_module_rel where status = 1 and type = #{type}
<if test="null != ids and ids.size > 0">
and business_id in
<foreach collection="ids" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment