|
|
@ -18,7 +18,6 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
@ -34,6 +33,8 @@ import com.epmet.redis.GovRoleRedis; |
|
|
|
import com.epmet.service.GovRoleMenuService; |
|
|
|
import com.epmet.service.GovRoleService; |
|
|
|
import com.epmet.service.GovRoleUserService; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -64,11 +65,20 @@ public class GovRoleServiceImpl extends BaseServiceImpl<GovRoleDao, GovRoleEntit |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<GovRoleDTO> page(Map<String, Object> params) { |
|
|
|
IPage<GovRoleEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, GovRoleDTO.class); |
|
|
|
Integer pageNo = Integer.valueOf((String) params.get("pageNo")); |
|
|
|
Integer pageSize = Integer.valueOf((String) params.get("pageSize")); |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
String name = (String) params.get(FieldConstant.NAME_HUMP); |
|
|
|
String customerId = (String) params.get(FieldConstant.CUSTOMER_ID_HUMP); |
|
|
|
QueryWrapper<GovRoleEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id) |
|
|
|
.like(StringUtils.isNotBlank(name), FieldConstant.NAME, name) |
|
|
|
.eq(StringUtils.isNotBlank(customerId), FieldConstant.CUSTOMER_ID, customerId); |
|
|
|
PageHelper.startPage(pageNo, pageSize); |
|
|
|
List<GovRoleEntity> list = baseDao.selectList(wrapper); |
|
|
|
List<GovRoleDTO> resList = ConvertUtils.sourceToTarget(list, GovRoleDTO.class); |
|
|
|
PageInfo<GovRoleDTO> pageInfo = new PageInfo<>(resList); |
|
|
|
return new PageData<>(resList, pageInfo.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -79,10 +89,10 @@ public class GovRoleServiceImpl extends BaseServiceImpl<GovRoleDao, GovRoleEntit |
|
|
|
return ConvertUtils.sourceToTarget(entityList, GovRoleDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<GovRoleEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
String name = (String)params.get(FieldConstant.NAME_HUMP); |
|
|
|
String customerId = (String)params.get(FieldConstant.CUSTOMER_ID_HUMP); |
|
|
|
private QueryWrapper<GovRoleEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
String name = (String) params.get(FieldConstant.NAME_HUMP); |
|
|
|
String customerId = (String) params.get(FieldConstant.CUSTOMER_ID_HUMP); |
|
|
|
QueryWrapper<GovRoleEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id).like(StringUtils.isNotBlank(name), FieldConstant.NAME, name) |
|
|
|
.eq(StringUtils.isNotBlank(customerId), FieldConstant.CUSTOMER_ID, customerId); |
|
|
@ -101,7 +111,7 @@ public class GovRoleServiceImpl extends BaseServiceImpl<GovRoleDao, GovRoleEntit |
|
|
|
public void save(GovRoleDTO dto) { |
|
|
|
GovRoleEntity entity = ConvertUtils.sourceToTarget(dto, GovRoleEntity.class); |
|
|
|
insert(entity); |
|
|
|
//保存角色菜单关系
|
|
|
|
// 保存角色菜单关系
|
|
|
|
govRoleMenuService.saveOrUpdate(entity.getId(), dto.getMenuIdList()); |
|
|
|
} |
|
|
|
|
|
|
@ -110,16 +120,16 @@ public class GovRoleServiceImpl extends BaseServiceImpl<GovRoleDao, GovRoleEntit |
|
|
|
public void update(GovRoleDTO dto) { |
|
|
|
GovRoleEntity entity = ConvertUtils.sourceToTarget(dto, GovRoleEntity.class); |
|
|
|
updateById(entity); |
|
|
|
//保存角色菜单关系
|
|
|
|
// 保存角色菜单关系
|
|
|
|
govRoleMenuService.saveOrUpdate(entity.getId(), dto.getMenuIdList()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String[] ids) { |
|
|
|
//联建单位负责人、社区自组织负责人两个默认解释不允许删除
|
|
|
|
// 联建单位负责人、社区自组织负责人两个默认解释不允许删除
|
|
|
|
GovRoleEntity entity = baseDao.selectById(ids[0]); |
|
|
|
if(null!=entity && "1".equals(entity.getDefaultRole())){ |
|
|
|
if (null != entity && "1".equals(entity.getDefaultRole())) { |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "系统默认角色,不允许删除", "系统默认角色,不允许删除"); |
|
|
|
} |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
@ -144,7 +154,7 @@ public class GovRoleServiceImpl extends BaseServiceImpl<GovRoleDao, GovRoleEntit |
|
|
|
entity.setRemark("默认角色"); |
|
|
|
entity.setDefaultRole("1"); |
|
|
|
list.add(entity); |
|
|
|
GovRoleEntity entity1 = ConvertUtils.sourceToTarget(entity,GovRoleEntity.class); |
|
|
|
GovRoleEntity entity1 = ConvertUtils.sourceToTarget(entity, GovRoleEntity.class); |
|
|
|
entity1.setId(null); |
|
|
|
entity1.setName("社区自组织负责人"); |
|
|
|
list.add(entity1); |
|
|
|