|
|
@ -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.VactOrgTypeDao; |
|
|
@ -51,11 +52,9 @@ public class VactOrgTypeServiceImpl extends BaseServiceImpl<VactOrgTypeDao, Vact |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<VactOrgTypeDTO> page(Map<String, Object> params) { |
|
|
|
IPage<VactOrgTypeEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, VactOrgTypeDTO.class); |
|
|
|
IPage<VactOrgTypeDTO> page = getPage(params); |
|
|
|
List<VactOrgTypeDTO> list = baseDao.getPageList(params); |
|
|
|
return new PageData<>(list, page.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -83,13 +82,36 @@ public class VactOrgTypeServiceImpl extends BaseServiceImpl<VactOrgTypeDao, Vact |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(VactOrgTypeDTO dto) { |
|
|
|
String typeName = dto.getTypeName(); |
|
|
|
if (StringUtils.isNotBlank(typeName)) { |
|
|
|
if (getCodeCount(dto) > 0) { |
|
|
|
throw new RenException("您输入的名称已存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
VactOrgTypeEntity entity = ConvertUtils.sourceToTarget(dto, VactOrgTypeEntity.class); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
public Integer getCodeCount(VactOrgTypeDTO dto) { |
|
|
|
QueryWrapper<VactOrgTypeEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq("type_name", dto.getTypeName()); |
|
|
|
wrapper.eq("del_flag", "0"); |
|
|
|
return baseDao.selectCount(wrapper); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(VactOrgTypeDTO dto) { |
|
|
|
String typeName = dto.getTypeName(); |
|
|
|
QueryWrapper<VactOrgTypeEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq("type_name", dto.getTypeName()); |
|
|
|
wrapper.eq("del_flag", "0"); |
|
|
|
wrapper.ne("id", dto.getId()); |
|
|
|
if (StringUtils.isNotBlank(typeName)) { |
|
|
|
if (baseDao.selectCount(wrapper) > 0) { |
|
|
|
throw new RenException("您输入的名称已存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
VactOrgTypeEntity entity = ConvertUtils.sourceToTarget(dto, VactOrgTypeEntity.class); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|