|
|
@ -17,17 +17,27 @@ |
|
|
|
|
|
|
|
package com.elink.esua.epdc.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
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.enums.YesOrNoEnum; |
|
|
|
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.security.user.SecurityUser; |
|
|
|
import com.elink.esua.epdc.commons.tools.security.user.UserDetail; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
|
import com.elink.esua.epdc.dao.BannerDao; |
|
|
|
import com.elink.esua.epdc.dto.BannerDTO; |
|
|
|
import com.elink.esua.epdc.entity.BannerEntity; |
|
|
|
import com.elink.esua.epdc.feign.AdminFeignClient; |
|
|
|
import com.elink.esua.epdc.redis.BannerRedis; |
|
|
|
import com.elink.esua.epdc.service.BannerDepartmentService; |
|
|
|
import com.elink.esua.epdc.service.BannerService; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -47,7 +57,9 @@ import java.util.Map; |
|
|
|
public class BannerServiceImpl extends BaseServiceImpl<BannerDao, BannerEntity> implements BannerService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private BannerRedis bannerRedis; |
|
|
|
private BannerDepartmentService bannerDepartmentService; |
|
|
|
@Autowired |
|
|
|
private AdminFeignClient adminFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<BannerDTO> page(Map<String, Object> params) { |
|
|
@ -65,8 +77,8 @@ public class BannerServiceImpl extends BaseServiceImpl<BannerDao, BannerEntity> |
|
|
|
return ConvertUtils.sourceToTarget(entityList, BannerDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<BannerEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
private QueryWrapper<BannerEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<BannerEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
@ -82,9 +94,52 @@ public class BannerServiceImpl extends BaseServiceImpl<BannerDao, BannerEntity> |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(BannerDTO dto) { |
|
|
|
public void saveOrUpdate(BannerDTO dto) { |
|
|
|
UserDetail user = SecurityUser.getUser(); |
|
|
|
dto.setCreatorName(user.getRealName()); |
|
|
|
dto.setDeptId(user.getDeptId()); |
|
|
|
dto.setDeptName(user.getDeptName()); |
|
|
|
BannerEntity entity = ConvertUtils.sourceToTarget(dto, BannerEntity.class); |
|
|
|
entity.setState(YesOrNoEnum.NO.value()); |
|
|
|
|
|
|
|
|
|
|
|
// 通知所属部门id
|
|
|
|
Long noticeDeptId = entity.getStreetId(); |
|
|
|
// 能接收通知的所有网格的ID
|
|
|
|
List<Long> noticeGridList = Lists.newArrayList(); |
|
|
|
if (null != entity.getCommunityId()) { |
|
|
|
noticeDeptId = entity.getCommunityId(); |
|
|
|
} |
|
|
|
if (null != entity.getGridId()) { |
|
|
|
noticeDeptId = entity.getGridId(); |
|
|
|
noticeGridList.add(noticeDeptId); |
|
|
|
} |
|
|
|
|
|
|
|
if (!user.getDeptIdList().contains(noticeDeptId)) { |
|
|
|
throw new RenException("您没有操作此部门的数据权限"); |
|
|
|
} |
|
|
|
|
|
|
|
if (CollUtil.isEmpty(noticeGridList)) { |
|
|
|
Result<List<Long>> adminResult = adminFeignClient.listGridIdByDeptPid(noticeDeptId); |
|
|
|
if (!adminResult.success() || CollUtil.isEmpty(adminResult.getData())) { |
|
|
|
throw new RenException("获取部门信息失败"); |
|
|
|
} |
|
|
|
noticeGridList = adminResult.getData(); |
|
|
|
} |
|
|
|
|
|
|
|
boolean isSave = true; |
|
|
|
if (StringUtils.isNotBlank(dto.getId())) { |
|
|
|
isSave = false; |
|
|
|
} |
|
|
|
|
|
|
|
if (isSave) { |
|
|
|
insert(entity); |
|
|
|
} else { |
|
|
|
updateById(entity); |
|
|
|
bannerDepartmentService.deleteByBannerId(entity.getId()); |
|
|
|
} |
|
|
|
|
|
|
|
this.bannerDepartmentService.save(entity.getId(), noticeGridList); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|