Browse Source

党组织类型

feature/test
zhangyongzhangyong 4 years ago
parent
commit
d9c736b5f7
  1. 8
      epdc-cloud-admin/pom.xml
  2. 10
      epdc-cloud-admin/src/main/java/com/elink/esua/epdc/dao/PartyOrgDao.java
  3. 22
      epdc-cloud-admin/src/main/java/com/elink/esua/epdc/dao/PartyOrgTypeDao.java
  4. 36
      epdc-cloud-admin/src/main/java/com/elink/esua/epdc/service/impl/PartyOrgTypeServiceImpl.java
  5. 36
      epdc-cloud-admin/src/main/resources/mapper/PartyOrgDao.xml
  6. 41
      epdc-cloud-admin/src/main/resources/mapper/PartyOrgTypeDao.xml

8
epdc-cloud-admin/pom.xml

@ -167,10 +167,10 @@
<spring.profiles.active>dev</spring.profiles.active>
<docker.tag>dev</docker.tag>
<spring.redis.index>9</spring.redis.index>
<spring.redis.host>114.215.125.123</spring.redis.host>
<spring.redis.port>9603</spring.redis.port>
<spring.redis.password>epdc!redis@master1405</spring.redis.password>
<spring.redis.index>8</spring.redis.index>
<spring.redis.host>r-m5eh5czgb1nucti6azpd.redis.rds.aliyuncs.com</spring.redis.host>
<spring.redis.port>10001</spring.redis.port>
<spring.redis.password>elink!888</spring.redis.password>
<!-- nacos -->
<nacos.register-enabled>false</nacos.register-enabled>

10
epdc-cloud-admin/src/main/java/com/elink/esua/epdc/dao/PartyOrgDao.java

@ -20,6 +20,7 @@ package com.elink.esua.epdc.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.entity.PartyOrgEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 党组织表 党组织表
@ -30,4 +31,13 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface PartyOrgDao extends BaseDao<PartyOrgEntity> {
/**
* 是否存在该类型partyOrgType的党组织
*
* @param typeCode
* @return java.lang.Integer
* @Author zhangyong
* @Date 14:34 2021-08-06
**/
Integer isPartyOrgExistByPartyOrgType(@Param("typeCode") String typeCode);
}

22
epdc-cloud-admin/src/main/java/com/elink/esua/epdc/dao/PartyOrgTypeDao.java

@ -20,6 +20,7 @@ package com.elink.esua.epdc.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.entity.PartyOrgTypeEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* 党组织类型表 党组织类型表
@ -30,4 +31,25 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface PartyOrgTypeDao extends BaseDao<PartyOrgTypeEntity> {
/**
* 返回值 >0 code 已经存在
*
* @param typeCode
* @param id 过滤自身(可选项)
* @return java.lang.Integer
* @Author zhangyong
* @Date 10:55 2021-04-28
**/
Integer isTypeCodeRepeated(@Param("typeCode") String typeCode, @Param("id") String id);
/**
* 返回值 >0 name 已经存在
*
* @param typeName
* @param id 过滤自身(可选项)
* @return java.lang.Integer
* @Author zhangyong
* @Date 10:55 2021-04-28
**/
Integer isTypeNameRepeated(@Param("typeName") String typeName, @Param("id") String id);
}

36
epdc-cloud-admin/src/main/java/com/elink/esua/epdc/service/impl/PartyOrgTypeServiceImpl.java

@ -20,9 +20,12 @@ package com.elink.esua.epdc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.exception.RenException;
import com.elink.esua.epdc.commons.tools.page.PageData;
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
import com.elink.esua.epdc.dao.PartyOrgDao;
import com.elink.esua.epdc.dao.PartyOrgTypeDao;
import com.elink.esua.epdc.dto.PartyOrgTypeDTO;
import com.elink.esua.epdc.entity.PartyOrgTypeEntity;
@ -48,6 +51,8 @@ public class PartyOrgTypeServiceImpl extends BaseServiceImpl<PartyOrgTypeDao, Pa
@Autowired
private PartyOrgTypeRedis partyOrgTypeRedis;
@Autowired
private PartyOrgDao partyOrgDao;
@Override
public PageData<PartyOrgTypeDTO> page(Map<String, Object> params) {
@ -70,7 +75,7 @@ public class PartyOrgTypeServiceImpl extends BaseServiceImpl<PartyOrgTypeDao, Pa
QueryWrapper<PartyOrgTypeEntity> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id);
wrapper.orderByAsc("SORT");
return wrapper;
}
@ -83,6 +88,11 @@ public class PartyOrgTypeServiceImpl extends BaseServiceImpl<PartyOrgTypeDao, Pa
@Override
@Transactional(rollbackFor = Exception.class)
public void save(PartyOrgTypeDTO dto) {
Integer num = baseDao.isTypeCodeRepeated(dto.getTypeCode(), null);
this.exceptionHandling(num, "党组织类型编码");
num = baseDao.isTypeNameRepeated(dto.getTypeName(), null);
this.exceptionHandling(num, "党组织类型");
PartyOrgTypeEntity entity = ConvertUtils.sourceToTarget(dto, PartyOrgTypeEntity.class);
insert(entity);
}
@ -90,13 +100,37 @@ public class PartyOrgTypeServiceImpl extends BaseServiceImpl<PartyOrgTypeDao, Pa
@Override
@Transactional(rollbackFor = Exception.class)
public void update(PartyOrgTypeDTO dto) {
Integer num = baseDao.isTypeCodeRepeated(dto.getTypeCode(), dto.getId());
this.exceptionHandling(num, "党组织类型编码 不可重复!");
num = baseDao.isTypeNameRepeated(dto.getTypeName(), dto.getId());
this.exceptionHandling(num, "党组织类型 不可重复!");
PartyOrgTypeEntity entity = ConvertUtils.sourceToTarget(dto, PartyOrgTypeEntity.class);
updateById(entity);
}
/**
* 异常处理
* @param num > 0 输出异常
* @param exceptionInfo 异常描述
* @return void
* @Author zhangyong
* @Date 14:26 2021-08-06
**/
private void exceptionHandling(Integer num, String exceptionInfo) {
if (NumConstant.ZERO < num) {
throw new RenException(exceptionInfo);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String[] ids) {
for (String id : ids) {
PartyOrgTypeEntity partyOrgTypeEntity = baseDao.selectById(id);
Integer num = partyOrgDao.isPartyOrgExistByPartyOrgType(partyOrgTypeEntity.getTypeCode());
this.exceptionHandling(num, "该类型不能被删除,因当前尚存在该类型的党组织。");
}
// 逻辑删除(@TableLogic 注解)
baseDao.deleteBatchIds(Arrays.asList(ids));
}

36
epdc-cloud-admin/src/main/resources/mapper/PartyOrgDao.xml

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.elink.esua.epdc.dao.PartyOrgDao">
<resultMap type="com.elink.esua.epdc.entity.PartyOrgEntity" id="partyOrgMap">
<result property="id" column="ID"/>
<result property="partyOrgName" column="PARTY_ORG_NAME"/>
<result property="introduction" column="INTRODUCTION"/>
<result property="twoCommittees" column="TWO_COMMITTEES"/>
<result property="partyMemberNum" column="PARTY_MEMBER_NUM"/>
<result property="longitude" column="LONGITUDE"/>
<result property="latitude" column="LATITUDE"/>
<result property="deptName" column="DEPT_NAME"/>
<result property="deptId" column="DEPT_ID"/>
<result property="typeCode" column="TYPE_CODE"/>
<result property="parentDeptIds" column="PARENT_DEPT_IDS"/>
<result property="parentDeptNames" column="PARENT_DEPT_NAMES"/>
<result property="allDeptIds" column="ALL_DEPT_IDS"/>
<result property="allDeptNames" column="ALL_DEPT_NAMES"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="isPartyOrgExistByPartyOrgType" resultType="Integer">
SELECT
COUNT(1)
FROM epdc_party_org
WHERE DEL_FLAG = '0'
AND TYPE_CODE = #{typeCode}
</select>
</mapper>

41
epdc-cloud-admin/src/main/resources/mapper/PartyOrgTypeDao.xml

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.elink.esua.epdc.dao.PartyOrgTypeDao">
<resultMap type="com.elink.esua.epdc.entity.PartyOrgTypeEntity" id="partyOrgTypeMap">
<result property="id" column="ID"/>
<result property="typeName" column="TYPE_NAME"/>
<result property="typeCode" column="TYPE_CODE"/>
<result property="sort" column="SORT"/>
<result property="enable" column="ENABLE"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="isTypeCodeRepeated" resultType="Integer">
SELECT
COUNT(1)
FROM epdc_party_org_type
WHERE DEL_FLAG = '0'
AND TYPE_CODE = #{typeCode}
<if test="id != null and id.trim() != ''">
AND ID != #{id}
</if>
</select>
<select id="isTypeNameRepeated" resultType="Integer">
SELECT
COUNT(1)
FROM epdc_party_org_type
WHERE DEL_FLAG = '0'
AND TYPE_NAME = #{typeName}
<if test="id != null and id.trim() != ''">
AND ID != #{id}
</if>
</select>
</mapper>
Loading…
Cancel
Save