Commit 4242e9b8 by zhiwj

修改模块

parent 7971e41d
......@@ -129,7 +129,7 @@ public class IndexDTO implements Serializable {
private Integer showStatus;
private List<Integer> relModuleIdList;
private List<String> relModuleIdList;
/**
* 操作人id
......@@ -324,11 +324,11 @@ public class IndexDTO implements Serializable {
this.updateTime = updateTime;
}
public List<Integer> getRelModuleIdList() {
public List<String> getRelModuleIdList() {
return relModuleIdList;
}
public void setRelModuleIdList(List<Integer> relModuleIdList) {
public void setRelModuleIdList(List<String> relModuleIdList) {
this.relModuleIdList = relModuleIdList;
}
......
......@@ -12,6 +12,7 @@ import com.gic.cloud.service.IndexLogApiService;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.error.ErrorCode;
import com.gic.enterprise.utils.ResultControllerUtils;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -34,7 +35,7 @@ public class IndexController {
@RequestMapping("/saveIndex")
public RestResponse saveIndex(IndexDTO indexDTO) {
public RestResponse saveIndex(IndexDTO indexDTO, String relModuleIds) {
if (indexDTO.getClassifyType() == null ||
StringUtils.isBlank(indexDTO.getCode()) ||
StringUtils.isBlank(indexDTO.getName()) ||
......@@ -44,6 +45,9 @@ public class IndexController {
UserDetailsVO user = UserUtils.getUser();
indexDTO.setOptUserId(user.getId());
indexDTO.setOptUserName(user.getRealName());
if (StringUtils.isNotBlank(relModuleIds)) {
indexDTO.setRelModuleIdList(Lists.newArrayList(relModuleIds.split(",")));
}
ServiceResponse<Void> serviceResponse = indexApiService.saveIndex(indexDTO);
return ResultControllerUtils.commonResult(serviceResponse);
}
......
......@@ -58,9 +58,9 @@ public interface TabIndexModuleRelMapper {
void insertSelectiveByNotExist(TabIndexModuleRel rel);
void updateStatusByBusinessIds(@Param("businessId") Integer businessId, @Param("ids") List<Integer> moduleIdList, @Param("type") Integer type);
void updateStatusByBusinessIds(@Param("businessId") Integer businessId, @Param("ids") List<String> moduleIdList, @Param("type") Integer type);
List<Integer> listModuleIdByBusinessId(@Param("businessId") Integer businessId, @Param("type") Integer type);
List<String> listModuleIdByBusinessId(@Param("businessId") Integer businessId, @Param("type") Integer type);
List<Integer> listBusinessIdByModuleId(@Param("moduleId") Integer moduleId);
......
......@@ -24,7 +24,7 @@ public class TabIndexModuleRel {
/**
* 模块的id
*/
private Integer moduleId;
private String moduleId;
/**
*
......@@ -65,11 +65,11 @@ public class TabIndexModuleRel {
this.businessId = businessId;
}
public Integer getModuleId() {
public String getModuleId() {
return moduleId;
}
public void setModuleId(Integer moduleId) {
public void setModuleId(String moduleId) {
this.moduleId = moduleId;
}
......
......@@ -9,13 +9,13 @@ import java.util.Map;
* @date 2020-07-08 10:22
*/
public interface IndexModuleRelService {
void save(Integer indexId, List<Integer> moduleId, Integer type);
void save(Integer indexId, List<String> moduleId, Integer type);
List<Integer> listModuleIdByBusinessId(Integer indexId, Integer type);
List<String> listModuleIdByBusinessId(Integer indexId, Integer type);
List<Integer> listBusinessIdByModuleId(Integer moduleId);
void deleteByBusinessId(Integer businessId, Integer type);
Map<Integer, List<Integer>> groupModuleIdByBusinessIds(List<Integer> indexIdList, Integer type);
Map<Integer, List<String>> groupModuleIdByBusinessIds(List<Integer> indexIdList, Integer type);
}
......@@ -22,11 +22,11 @@ public class IndexModuleRelServiceImpl implements IndexModuleRelService {
@Override
public void save(Integer businessId, List<Integer> moduleIdList, Integer type) {
public void save(Integer businessId, List<String> moduleIdList, Integer type) {
// 把所有关联status设置为0
tabIndexModuleRelMapper.delByBusinessId(businessId, type);
// 插入不存在的关联
for (Integer moduleId : moduleIdList) {
for (String moduleId : moduleIdList) {
TabIndexModuleRel rel = new TabIndexModuleRel();
rel.setType(type);
rel.setBusinessId(businessId);
......@@ -40,7 +40,7 @@ public class IndexModuleRelServiceImpl implements IndexModuleRelService {
}
@Override
public List<Integer> listModuleIdByBusinessId(Integer businessId, Integer type) {
public List<String> listModuleIdByBusinessId(Integer businessId, Integer type) {
return tabIndexModuleRelMapper.listModuleIdByBusinessId(businessId, type);
}
......@@ -55,10 +55,10 @@ public class IndexModuleRelServiceImpl implements IndexModuleRelService {
}
@Override
public Map<Integer, List<Integer>> groupModuleIdByBusinessIds(List<Integer> businessIdList, Integer type) {
public Map<Integer, List<String>> 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())));
Collectors.mapping(TabIndexModuleRel::getModuleId, Collectors.toList())));
}
}
......@@ -89,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.listModuleIdByBusinessId(indexDTO.getIndexId(), LogAndUpdateTipsTypeEnum.INDEX.getCode());
List<String> moduleIdList = this.indexModuleRelService.listModuleIdByBusinessId(indexDTO.getIndexId(), LogAndUpdateTipsTypeEnum.INDEX.getCode());
indexDTO.setRelModuleIdList(moduleIdList);
return EnterpriseServiceResponse.success(indexDTO);
}
......@@ -100,7 +100,7 @@ public class IndexApiServiceImpl implements IndexApiService {
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());
Map<Integer, List<String>> moduleIdByBusinessIdMap = indexModuleRelService.groupModuleIdByBusinessIds(indexIdList, LogAndUpdateTipsTypeEnum.INDEX.getCode());
List<IndexDTO> indexDTOList = indexDTOPage.getResult();
for (IndexDTO indexDTO : indexDTOList) {
indexDTO.setRelModuleIdList(moduleIdByBusinessIdMap.get(indexDTO.getIndexId()));
......@@ -115,7 +115,7 @@ public class IndexApiServiceImpl implements IndexApiService {
if (index == null) {
return EnterpriseServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "指标不存在或已删除");
}
List<Integer> moduleIdList = indexModuleRelService.listModuleIdByBusinessId(indexId, LogAndUpdateTipsTypeEnum.INDEX.getCode());
List<String> moduleIdList = indexModuleRelService.listModuleIdByBusinessId(indexId, LogAndUpdateTipsTypeEnum.INDEX.getCode());
if (CollectionUtils.isNotEmpty(moduleIdList)) {
return EnterpriseServiceResponse.failure(ErrorCode.PARAMETER_ERROR.getCode(), "不能删除被引用的指标");
}
......
......@@ -5,7 +5,7 @@
<id column="index_module_rel_id" jdbcType="INTEGER" property="indexModuleRelId" />
<result column="type" jdbcType="INTEGER" property="type" />
<result column="business_id" jdbcType="INTEGER" property="businessId" />
<result column="module_id" jdbcType="INTEGER" property="moduleId" />
<result column="module_id" jdbcType="VARCHAR" property="moduleId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="status" jdbcType="INTEGER" property="status" />
......@@ -28,7 +28,7 @@
module_id, create_time, update_time,
status)
values (#{indexModuleRelId,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}, #{businessId,jdbcType=INTEGER},
#{moduleId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{moduleId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{status,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.gic.cloud.entity.TabIndexModuleRel">
......@@ -67,7 +67,7 @@
#{businessId,jdbcType=INTEGER},
</if>
<if test="moduleId != null">
#{moduleId,jdbcType=INTEGER},
#{moduleId,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
......@@ -90,7 +90,7 @@
business_id = #{businessId,jdbcType=INTEGER},
</if>
<if test="moduleId != null">
module_id = #{moduleId,jdbcType=INTEGER},
module_id = #{moduleId,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
......@@ -108,7 +108,7 @@
update tab_index_module_rel
set type = #{type,jdbcType=INTEGER},
business_id = #{businessId,jdbcType=INTEGER},
module_id = #{moduleId,jdbcType=INTEGER},
module_id = #{moduleId,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
status = #{status,jdbcType=INTEGER}
......@@ -156,7 +156,7 @@
</foreach>
</if>
</update>
<select id="listModuleIdByBusinessId" resultType="int">
<select id="listModuleIdByBusinessId" resultType="string">
select
module_id
from tab_index_module_rel
......
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