|
|
@ -21,6 +21,7 @@ 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.FieldConstant; |
|
|
|
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.modules.volunteer.dao.VolunteerTeamTypeDao; |
|
|
@ -52,7 +53,7 @@ public class VolunteerTeamTypeServiceImpl extends BaseServiceImpl<VolunteerTeamT |
|
|
|
@Override |
|
|
|
public PageData<VolunteerTeamTypeDTO> page(Map<String, Object> params) { |
|
|
|
IPage<VolunteerTeamTypeEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, "create_date", false), |
|
|
|
getPage(params, "sort", true), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, VolunteerTeamTypeDTO.class); |
|
|
@ -83,13 +84,62 @@ public class VolunteerTeamTypeServiceImpl extends BaseServiceImpl<VolunteerTeamT |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(VolunteerTeamTypeDTO dto) { |
|
|
|
String categoryCode = dto.getTypeCode(); |
|
|
|
if (StringUtils.isNotBlank(categoryCode)) { |
|
|
|
if (getCodeCount(dto) > 0) { |
|
|
|
throw new RenException("您输入的编码已存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
String categoryName = dto.getTypeName(); |
|
|
|
if (StringUtils.isNotBlank(categoryName)) { |
|
|
|
if (getNameCount(dto) > 0) { |
|
|
|
throw new RenException("您输入的名称已存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
VolunteerTeamTypeEntity entity = ConvertUtils.sourceToTarget(dto, VolunteerTeamTypeEntity.class); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public Integer getCodeCount(VolunteerTeamTypeDTO dto) { |
|
|
|
QueryWrapper<VolunteerTeamTypeEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq("type_code", dto.getTypeCode()); |
|
|
|
wrapper.eq("del_flag", "0"); |
|
|
|
if(null != dto.getId()){ |
|
|
|
wrapper.ne("id", dto.getId()); |
|
|
|
} |
|
|
|
return baseDao.selectCount(wrapper); |
|
|
|
} |
|
|
|
|
|
|
|
public Integer getNameCount(VolunteerTeamTypeDTO dto) { |
|
|
|
QueryWrapper<VolunteerTeamTypeEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq("type_name", dto.getTypeName()); |
|
|
|
wrapper.eq("del_flag", "0"); |
|
|
|
if(null != dto.getId()){ |
|
|
|
wrapper.ne("id", dto.getId()); |
|
|
|
} |
|
|
|
return baseDao.selectCount(wrapper); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(VolunteerTeamTypeDTO dto) { |
|
|
|
|
|
|
|
String categoryCode = dto.getTypeCode(); |
|
|
|
if (StringUtils.isNotBlank(categoryCode)) { |
|
|
|
if (getCodeCount(dto) > 0) { |
|
|
|
throw new RenException("您输入的编码已存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
String categoryName = dto.getTypeName(); |
|
|
|
if (StringUtils.isNotBlank(categoryName)) { |
|
|
|
if (getNameCount(dto) > 0) { |
|
|
|
throw new RenException("您输入的名称已存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
VolunteerTeamTypeEntity entity = ConvertUtils.sourceToTarget(dto, VolunteerTeamTypeEntity.class); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|