优化商品类别和机构的删除操作

This commit is contained in:
季圣华 2021-11-09 23:49:21 +08:00
parent 15ee7455f6
commit 9dc9785111
5 changed files with 38 additions and 10 deletions

View File

@ -253,12 +253,15 @@ public class ExceptionConstants {
//商品类别编号已存在
public static final int MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE = 7500003;
public static final String MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG = "商品类别编号已存在";
//目录不支持修改
//类别不支持修改
public static final int MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_CODE = 7500004;
public static final String MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_MSG = "目录不支持修改";
//目录不支持删除
public static final String MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_EDIT_MSG = "类别不支持修改";
//类别不支持删除
public static final int MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_CODE = 7500005;
public static final String MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_MSG = "根目录不支持删除";
public static final String MATERIAL_CATEGORY_ROOT_NOT_SUPPORT_DELETE_MSG = "根类别不支持删除";
//该类别存在下级不允许删除
public static final int MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_CODE = 7500006;
public static final String MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_MSG = "该类别存在下级不允许删除";
/**
* 商品信息
* type = 80
@ -422,6 +425,9 @@ public class ExceptionConstants {
//根机构不允许修改
public static final int ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_CODE = 11000005;
public static final String ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_MSG = "根机构不允许修改";
//该机构存在下级不允许删除
public static final int ORGANIZATION_CHILD_NOT_ALLOWED_DELETE_CODE = 11000006;
public static final String ORGANIZATION_CHILD_NOT_ALLOWED_DELETE_MSG = "该机构存在下级不允许删除";
/**
* 机构用户关联关系
* type = 115

View File

@ -23,6 +23,8 @@ public interface OrganizationMapperEx {
int addOrganization(Organization org);
List <Organization> getOrganizationByParentIds(@Param("ids") String ids[]);
int batchDeleteOrganizationByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
int editOrganization(Organization org);

View File

@ -200,10 +200,14 @@ public class MaterialCategoryService {
if(strArray.length<1){
return 0;
}
try{
List<MaterialCategory> mcList = materialCategoryMapperEx.getMaterialCategoryListByCategoryIds(idArray);
if(mcList!=null && mcList.size()>0) {
logger.error("异常码[{}],异常提示[{}]",
ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_CODE,ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_MSG);
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_CODE,
ExceptionConstants.MATERIAL_CATEGORY_CHILD_NOT_SUPPORT_DELETE_MSG);
} else {
result=materialCategoryMapperEx.batchDeleteMaterialCategoryByIds(updateDate,updater,strArray);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}

View File

@ -117,11 +117,16 @@ public class OrganizationService {
User userInfo=userService.getCurrentUser();
String [] idArray=ids.split(",");
int result=0;
try{
List <Organization> organList = organizationMapperEx.getOrganizationByParentIds(idArray);
if(organList!=null && organList.size()>0) {
//如果存在子机构则不能删除
logger.error("异常码[{}],异常提示[{}]",
ExceptionConstants.ORGANIZATION_CHILD_NOT_ALLOWED_DELETE_CODE,ExceptionConstants.ORGANIZATION_CHILD_NOT_ALLOWED_DELETE_MSG);
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_CHILD_NOT_ALLOWED_DELETE_CODE,
ExceptionConstants.ORGANIZATION_CHILD_NOT_ALLOWED_DELETE_MSG);
} else {
result=organizationMapperEx.batchDeleteOrganizationByIds(
new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){
JshException.writeFail(logger, e);
}
return result;
}

View File

@ -60,6 +60,17 @@
#{parentId,jdbcType=BIGINT}, #{sort,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
</insert>
<select id="getOrganizationByParentIds" resultMap="com.jsh.erp.datasource.mappers.OrganizationMapper.BaseResultMap">
select * from jsh_organization
where
1=1
and ifnull(delete_flag,'0') !='1'
and parent_id in (
<foreach collection="ids" item="id" separator=",">
#{id}
</foreach>
)
</select>
<update id="batchDeleteOrganizationByIds">
update jsh_organization
set update_Time=#{updateTime},delete_flag='1'