Commit 03f427cc by “zcwang”

Merge remote-tracking branch 'origin/feature-changeFlow-221110' into feature-changeFlow-221110

parents 280f8a1e c93accb6
......@@ -166,6 +166,10 @@ public enum ResponseCode {
*/
ONLY_OP_SUCCESS_ALLOWED(3001,"verify only allowed when op success"),
PARAMETER_LENGTH(413, "请检查参数长度"),
EXEC_CONFIG_LENGTH(414, "请检查行动方案配置数量"),
CHANGE_TYPE_NAME_ONE(4001,"一级变更类型重复,请检查后添加~"),
CHANGE_TYPE_NAME_TOW(4002,"二级变更类型重复,请检查后添加~");
......
......@@ -13,7 +13,7 @@ public interface ChangeConfigService {
Boolean deleteChangeConfig(Long id);
Boolean addChangeConfig(ChangeConfig changeConfig);
ChangeConfig addChangeConfig(ChangeConfig changeConfig);
Boolean updateChangeConfig(Long id);
Boolean updateChangeConfig(ChangeConfig changeConfig);
}
......@@ -15,7 +15,7 @@ public interface ChangeExecConfigService {
Boolean addChangeExecConfig(List<ChangeExecConfig> changeExecConfigs);
Boolean updateChangeExecConfig(List<ChangeExecConfig> changeExecConfigs);
Boolean updateChangeExecConfig(ChangeExecConfig changeExecConfig);
Boolean deleteChangeExecConfig(Long id);
......
......@@ -27,13 +27,14 @@ public interface ChangeTypeService {
*/
List<ChangeType> addChangeType(List<ChangeType> changeTypes);
Boolean updateChangeType(List<ChangeType> changeTypes);
/**
* 判断类型是否存在
* @param typeName
* 因为牵扯到历史变更查询未保证变更类型的持久性不做真实删除和修改
* 伪善原来的 后新增
* @param changeTypes
* @return
*/
Boolean queryChangeType(String typeName);
List<ChangeType> updateChangeType(List<ChangeType> changeTypes);
Boolean deleteChangeType(List<ChangeType> changeTypes);
}
......@@ -16,21 +16,25 @@ public class ChangeConfigServiceImpl implements ChangeConfigService {
@Override
public ChangeConfig queryChangeConfig(Long id) {
return null;
return mapper.queryById(id);
}
@Override
public Boolean deleteChangeConfig(Long id) {
return null;
mapper.deleteById(id);
return true;
}
@Override
public Boolean addChangeConfig(ChangeConfig changeConfig) {
return null;
public ChangeConfig addChangeConfig(ChangeConfig changeConfig) {
int id = mapper.insertSelective(changeConfig);
changeConfig.setId((long) id);
return changeConfig;
}
@Override
public Boolean updateChangeConfig(Long id) {
return null;
public Boolean updateChangeConfig(ChangeConfig changeConfig) {
mapper.updateByPrimaryKeySelective(changeConfig);
return true;
}
}
package com.netease.mail.yanxuan.change.biz.service.impl.change;
import com.netease.mail.yanxuan.change.biz.meta.ResponseCode;
import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeExecConfigService;
import com.netease.mail.yanxuan.change.dal.entity.ChangeExecConfig;
import com.netease.mail.yanxuan.change.dal.mapper.ChangeExecConfigMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
......@@ -18,21 +21,33 @@ public class ChangeExecConfigServiceImpl implements ChangeExecConfigService {
@Override
public List<ChangeExecConfig> queryChangeExecConfig(Long changeTemplateId) {
return null;
return mapper.queryChangeExecConfig(changeTemplateId);
}
@Override
@Transactional
public Boolean addChangeExecConfig(List<ChangeExecConfig> changeExecConfigs) {
return null;
if (changeExecConfigs == null || changeExecConfigs.size() >=21){
throw ExceptionFactory.createBiz(ResponseCode.EXEC_CONFIG_LENGTH);
}
//循环添加
for (ChangeExecConfig changeExecConfig : changeExecConfigs){
//行动项,变更风险描述, 变更验证措施, 需要判断字段长度 参数验证 暂不验证
mapper.insertSelective(changeExecConfig);
}
return true;
}
@Override
public Boolean updateChangeExecConfig(List<ChangeExecConfig> changeExecConfigs) {
return null;
public Boolean updateChangeExecConfig(ChangeExecConfig changeExecConfig) {
//行动项,变更风险描述, 变更验证措施, 需要判断字段长度 参数验证 暂不验证
mapper.updateByPrimaryKeySelective(changeExecConfig);
return true;
}
@Override
public Boolean deleteChangeExecConfig(Long id) {
return null;
mapper.deleteById(id);
return true;
}
}
package com.netease.mail.yanxuan.change.biz.service.impl.change;
import com.netease.mail.yanxuan.change.biz.meta.ResponseCode;
import com.netease.mail.yanxuan.change.biz.meta.exception.ExceptionFactory;
import com.netease.mail.yanxuan.change.biz.service.change.ChangeTypeService;
import com.netease.mail.yanxuan.change.dal.entity.ChangeType;
import com.netease.mail.yanxuan.change.dal.mapper.ChangeTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
......@@ -31,21 +34,61 @@ public class ChangeTypeServiceImpl implements ChangeTypeService {
@Override
@Transactional
public List<ChangeType> addChangeType(List<ChangeType> changeTypes) {
if (changeTypes.get(0) == null || changeTypes.get(1) == null){
throw ExceptionFactory.createNotLogin();
//验证字符串长度
if (changeTypes.get(0).getTypeName().length() > 20 && changeTypes.get(0).getTypeName().length() > 20){
throw ExceptionFactory.createBiz(ResponseCode.PARAMETER_LENGTH);
}
return null;
queryChangeType(changeTypes);
int oneId = mapper.insertSelective(changeTypes.get(0));
//id 载入
changeTypes.get(0).setId((long) oneId);
changeTypes.get(1).setParentId((long) oneId);
int tow = mapper.insertSelective(changeTypes.get(1));
changeTypes.get(1).setId((long) tow);
return changeTypes;
}
@Override
public Boolean updateChangeType(List<ChangeType> changeTypes) {
return null;
public List<ChangeType> updateChangeType(List<ChangeType> changeTypes) {
deleteChangeType(changeTypes);
return addChangeType(changeTypes);
}
@Override
public Boolean queryChangeType(String typeName) {
return null;
@Transactional
public Boolean deleteChangeType(List<ChangeType> changeTypes) {
if (changeTypes.get(0) == null || changeTypes.get(1) == null){
throw ExceptionFactory.createParamFail();
}
for (ChangeType changeType : changeTypes){
changeType.setDelete(1);
mapper.updateByPrimaryKeySelective(changeType);
}
return true;
}
/**
* 判断变更类型是否重复(只判断未伪善出的)
* @param changeTypes
* @return
*/
private void queryChangeType(List<ChangeType> changeTypes) {
if (changeTypes.get(0) == null || changeTypes.get(1) == null){
throw ExceptionFactory.createParamFail();
}
int i = 0;
for (ChangeType changeType : changeTypes){
if (StringUtils.isEmpty(changeType.getTypeName())){
throw ExceptionFactory.createBiz(ResponseCode.PARAM_MISS);
}
if (mapper.queryTypeName(changeType.getTypeName()) != null){
throw ExceptionFactory.createBiz(i == 0?ResponseCode.CHANGE_TYPE_NAME_ONE:ResponseCode.CHANGE_TYPE_NAME_TOW);
}
i++;
}
}
......
......@@ -6,9 +6,12 @@
*/
package com.netease.mail.yanxuan.change.dal.mapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import com.netease.mail.yanxuan.change.dal.entity.ChangeConfig;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* @Author zcwang
......@@ -16,4 +19,11 @@ import com.netease.mail.yanxuan.change.dal.entity.ChangeConfig;
*/
@Mapper
public interface ChangeConfigMapper extends tk.mybatis.mapper.common.Mapper<ChangeConfig> {
@Select("select * from TB_YX_CHANGE_CONFIG where id = #{id}")
ChangeConfig queryById(@Param("id") Long id);
@Delete("delete from TB_YX_CHANGE_CONFIG where id = #{id}")
void deleteById(@Param("id") Long id);
}
\ No newline at end of file
......@@ -6,9 +6,14 @@
*/
package com.netease.mail.yanxuan.change.dal.mapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import com.netease.mail.yanxuan.change.dal.entity.ChangeExecConfig;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* @Author zcwang
......@@ -17,4 +22,11 @@ import com.netease.mail.yanxuan.change.dal.entity.ChangeExecConfig;
@Mapper
public interface ChangeExecConfigMapper extends tk.mybatis.mapper.common.Mapper<ChangeExecConfig> {
@Delete("delete from TB_YX_CHANGE_EXEC_CONFIG where id = #{id}")
int deleteById(@Param("id") Long id);
@Select("select * from TB_YX_CHANGE_EXEC_CONFIG where change_template_id = #{changeTemplateId}")
List<ChangeExecConfig> queryChangeExecConfig(@Param("changeTemplateId")Long changeTemplateId);
}
\ No newline at end of file
......@@ -9,6 +9,8 @@ package com.netease.mail.yanxuan.change.dal.mapper;
import org.apache.ibatis.annotations.Mapper;
import com.netease.mail.yanxuan.change.dal.entity.ChangeType;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* @Author zcwang
......@@ -16,4 +18,8 @@ import com.netease.mail.yanxuan.change.dal.entity.ChangeType;
*/
@Mapper
public interface ChangeTypeMapper extends tk.mybatis.mapper.common.Mapper<ChangeType> {
@Select("select id from TB_YX_CHANGE_TYPE where type_name = #{typeName} and delete = 0")
Integer queryTypeName(@Param("typeName") String typeName);
}
\ 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