Browse Source

banner管理,增加修改逻辑

feature/screenDataPush
zhangyongzhangyong 4 years ago
parent
commit
190fe8a9e5
  1. 13
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDeptController.java
  2. 11
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysDeptDao.java
  3. 10
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDeptService.java
  4. 46
      esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java
  5. 23
      esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysDeptDao.xml
  6. 13
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/BannerDepartmentDao.java
  7. 15
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/feign/AdminFeignClient.java
  8. 5
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/feign/fallback/AdminFeignClientFallback.java
  9. 12
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/BannerDepartmentService.java
  10. 6
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/BannerDepartmentServiceImpl.java
  11. 15
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/BannerServiceImpl.java
  12. 9
      esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/BannerDepartmentDao.xml

13
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDeptController.java

@ -323,4 +323,17 @@ public class SysDeptController {
return sysDeptService.addAreaCode(dto);
}
/**
* 批量查询所有部门ID
*
* @param deptIds
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<java.lang.Long[]>>
* @Author zhangyong
* @Date 10:13 2021-09-28
**/
@GetMapping("getAllDeptIdsArray/{deptIds}")
Result<List<Long[]>> getAllDeptIdsArray(@PathVariable("deptIds") Long[] deptIds) {
return sysDeptService.getAllDeptIdsArray(deptIds);
}
}

11
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysDeptDao.java

@ -9,6 +9,7 @@
package com.elink.esua.epdc.dao;
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
import com.elink.esua.epdc.commons.tools.utils.Result;
import com.elink.esua.epdc.dto.CompleteDeptDTO;
import com.elink.esua.epdc.dto.DeptTreeDTO;
import com.elink.esua.epdc.dto.SysDeptDTO;
@ -185,4 +186,14 @@ public interface SysDeptDao extends BaseDao<SysDeptEntity> {
* @since 2021/1/20 10:01
*/
List<SysDeptDTO> selectListOfDeptInfoByTypeKey(String typeKey);
/**
* 通过网格ID获取该网格所有上级机构批量查询
*
* @param deptIds
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<java.lang.Long[]>>
* @Author zhangyong
* @Date 10:13 2021-09-28
**/
List<CompleteDeptDTO> getAllDeptIdsArray(@Param("deptIds") Long[] deptIds);
}

10
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDeptService.java

@ -307,4 +307,14 @@ public interface SysDeptService extends BaseService<SysDeptEntity> {
* @since 2021/5/11 15:21
*/
Result<SysDeptDTO> addAreaCode(SysDeptDTO dto);
/**
* 批量查询所有部门ID
*
* @param deptIds
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<java.lang.Long[]>>
* @Author zhangyong
* @Date 10:13 2021-09-28
**/
Result<List<Long[]>> getAllDeptIdsArray(Long[] deptIds);
}

46
esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java

@ -54,10 +54,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 部门管理
@ -1075,4 +1072,45 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit
return new Result<SysDeptDTO>().ok(dto);
}
@Override
public Result<List<Long[]>> getAllDeptIdsArray(Long[] deptIds) {
List<CompleteDeptDTO> allDeptIdsArray = baseDao.getAllDeptIdsArray(deptIds);
List<Long[]> ids = new ArrayList<>();
for (CompleteDeptDTO dto : allDeptIdsArray) {
Long[] allDeptId = new Long[NumConstant.FOUR];
int index = NumConstant.ZERO;
if (dto.getDistrictId() != null && dto.getDistrictId() != NumConstant.ZERO_L) {
allDeptId[index++] = dto.getDistrictId();
}
if (dto.getStreetId() != null && dto.getStreetId() != NumConstant.ZERO_L) {
allDeptId[index++] = dto.getStreetId();
}
if (dto.getCommunityId() != null && dto.getCommunityId() != NumConstant.ZERO_L) {
allDeptId[index++] = dto.getCommunityId();
}
if (dto.getGridId() != null && dto.getGridId() != NumConstant.ZERO_L) {
allDeptId[index++] = dto.getGridId();
}
Long[] copyAllDeptId = Arrays.copyOf(allDeptId, index);
ids.add(copyAllDeptId);
}
return new Result<List<Long[]> >().ok(ids);
}
}
class A {
public static void main(String[] args) {
Long[] allDeptId = new Long[4];
allDeptId[0] = 1L;
allDeptId[1] = 1L;
allDeptId[2] = 1L;
allDeptId[3] = 1L;
Long[] longs = Arrays.copyOf(allDeptId,4);
allDeptId[0] = 11L;
for (Long aLong : longs) {
System.out.println(aLong);
}
}
}

23
esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysDeptDao.xml

@ -288,4 +288,27 @@
AND type_key = #{typeKey}
AND t.id NOT IN ( SELECT c.dept_id FROM sys_dept_config c WHERE c.del_flag = '0' ) ORDER BY t.`name`
</select>
<select id="getAllDeptIdsArray" resultType="com.elink.esua.epdc.dto.CompleteDeptDTO">
SELECT
dis.`name` district,
dis.id districtId,
str.`name` street,
str.id streetId,
com.`name` community,
com.id communityId,
gri.`name` grid,
gri.id gridId
FROM
sys_dept gri
LEFT JOIN sys_dept com ON gri.pid = com.id
LEFT JOIN sys_dept str ON com.pid = str.id
LEFT JOIN sys_dept dis ON str.pid = dis.id
WHERE
gri.del_flag = '0'
AND gri.ID IN
<foreach collection="deptIds" index="index" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
</select>
</mapper>

13
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/dao/BannerDepartmentDao.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.BannerDepartmentEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* banner部门关系表
@ -37,4 +38,14 @@ public interface BannerDepartmentDao extends BaseDao<BannerDepartmentEntity> {
* @date 2019/9/10 20:04
*/
void deleteByBannerId(String bannerId);
}
/**
* 根据 bannerId查询 banner 关联的部门ID
*
* @param bannerId
* @return java.lang.Long[]
* @Author zhangyong
* @Date 09:48 2021-09-28
**/
Long[] selectBannerDepartmentByBannerId(@Param("bannerId") String bannerId);
}

15
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/feign/AdminFeignClient.java

@ -16,7 +16,9 @@ import java.util.List;
* @email yujintao@elink-cn.com
* @date 2019/9/5 14:44
*/
@FeignClient(name = ServiceConstant.EPDC_ADMIN_SERVER, fallback = AdminFeignClientFallback.class)
@FeignClient(name = ServiceConstant.EPDC_ADMIN_SERVER, fallback = AdminFeignClientFallback.class
//, url = "http://127.0.0.1:9092"
)
public interface AdminFeignClient {
/**
@ -51,4 +53,15 @@ public interface AdminFeignClient {
*/
@GetMapping("/sys/dict/listSimple/{dictType}")
Result<List<SysSimpleDictDTO>> getListSimpleByDictType(@PathVariable("dictType") String dictType);
/**
* 批量查询所有部门ID
*
* @param deptIds
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List<java.lang.Long[]>>
* @Author zhangyong
* @Date 10:13 2021-09-28
**/
@GetMapping("/sys/dept/getAllDeptIdsArray/{deptIds}")
Result<List<Long[]>> getAllDeptIdsArray(@PathVariable("deptIds") Long[] deptIds);
}

5
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/feign/fallback/AdminFeignClientFallback.java

@ -32,4 +32,9 @@ public class AdminFeignClientFallback implements AdminFeignClient {
public Result<List<SysSimpleDictDTO>> getListSimpleByDictType(String dictType) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_ADMIN_SERVER, "getListSimpleByDictType", dictType);
}
@Override
public Result<List<Long[]>> getAllDeptIdsArray(Long[] deptIds) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_ADMIN_SERVER, "getAllDeptIdsArray", deptIds);
}
}

12
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/BannerDepartmentService.java

@ -111,4 +111,14 @@ public interface BannerDepartmentService extends BaseService<BannerDepartmentEnt
* @date 2019/9/10 20:07
*/
void save(String id, List<Long> noticeGridList);
}
/**
* 根据 bannerId查询 banner 关联的部门ID
*
* @param bannerId
* @return java.lang.Long[]
* @Author zhangyong
* @Date 09:48 2021-09-28
**/
Long[] selectBannerDepartmentByBannerId(String bannerId);
}

6
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/BannerDepartmentServiceImpl.java

@ -127,4 +127,8 @@ public class BannerDepartmentServiceImpl extends BaseServiceImpl<BannerDepartmen
this.insertBatch(list, NumConstant.TWENTY);
}
}
@Override
public Long[] selectBannerDepartmentByBannerId(String bannerId) {
return baseDao.selectBannerDepartmentByBannerId(bannerId);
}
}

15
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/java/com/elink/esua/epdc/service/impl/BannerServiceImpl.java

@ -95,11 +95,14 @@ public class BannerServiceImpl extends BaseServiceImpl<BannerDao, BannerEntity>
public BannerDTO get(String id) {
BannerEntity entity = baseDao.selectById(id);
BannerDTO dto = ConvertUtils.sourceToTarget(entity, BannerDTO.class);
/*if(StringUtils.isNotBlank(dto.getAllDeptIds())){
String[] idsShow = dto.getAllDeptIds().split(",");
List<String> ids = Arrays.asList(idsShow);
dto.setAllDeptIdsShow(ids.subList(1,ids.size()));
}*/
Long[] gridIds = bannerDepartmentService.selectBannerDepartmentByBannerId(id);
if ( null != gridIds && NumConstant.ZERO < gridIds.length) {
Result<List<Long[]>> allDeptIdsArray = adminFeignClient.getAllDeptIdsArray(gridIds);
System.out.println(allDeptIdsArray.success());
if (allDeptIdsArray.success()) {
dto.setAllDeptIdsShow(allDeptIdsArray.getData());
}
}
return dto;
}
@ -244,4 +247,4 @@ public class BannerServiceImpl extends BaseServiceImpl<BannerDao, BannerEntity>
return entities;
}
}
}

9
esua-epdc/epdc-module/epdc-news/epdc-news-server/src/main/resources/mapper/BannerDepartmentDao.xml

@ -18,4 +18,11 @@
DELETE FROM epdc_banner_department WHERE BANNER_ID = #{bannerId}
</delete>
</mapper>
<select id="selectBannerDepartmentByBannerId" resultType="java.lang.Long">
SELECT
GRID_ID
FROM epdc_banner_department
WHERE DEL_FLAG ='0'
AND BANNER_ID = #{bannerId, jdbcType=VARCHAR}
</select>
</mapper>

Loading…
Cancel
Save