Commit 4242e9b8 by zhiwj

修改模块

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