Browse Source

修改新闻列表功能

hotfix/yujt_opt
yujt 5 years ago
parent
commit
3841e3c010
  1. 12
      epdc-cloud-news/src/main/java/com/elink/esua/epdc/feign/AdminFeignClient.java
  2. 5
      epdc-cloud-news/src/main/java/com/elink/esua/epdc/feign/fallback/AdminFeignClientFallback.java
  3. 13
      epdc-cloud-news/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java
  4. 25
      epdc-cloud-news/src/main/resources/mapper/NewsDao.xml

12
epdc-cloud-news/src/main/java/com/elink/esua/epdc/feign/AdminFeignClient.java

@ -39,4 +39,16 @@ public interface AdminFeignClient {
*/ */
@GetMapping("/sys/dept/getParentAndAllDept/{deptId}") @GetMapping("/sys/dept/getParentAndAllDept/{deptId}")
Result<ParentAndAllDeptDTO> getParentAndAllDept(@PathVariable("deptId") String deptId); Result<ParentAndAllDeptDTO> getParentAndAllDept(@PathVariable("deptId") String deptId);
/**
* 根据部门类别过滤部门权限
*
* @param userId 用户id
* @param typeKeys 部门类别关键字{@link com.elink.esua.epdc.commons.tools.constant.OrganizationTypeConstant}
* @return com.elink.esua.epdc.commons.tools.utils.Result<java.util.List < java.lang.Long>>
* @author work@yujt.net.cn
* @date 2020/5/29 15:45
*/
@GetMapping("sys/optimize/deptScope/listByTypeKey/{userId}")
Result<List<Long>> getUserDeptScope(@PathVariable("userId") Long userId, String... typeKeys);
} }

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

@ -26,4 +26,9 @@ public class AdminFeignClientFallback implements AdminFeignClient {
public Result<ParentAndAllDeptDTO> getParentAndAllDept(String depId) { public Result<ParentAndAllDeptDTO> getParentAndAllDept(String depId) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_ADMIN_SERVER, "getParentAndAllDept", depId); return ModuleUtils.feignConError(ServiceConstant.EPDC_ADMIN_SERVER, "getParentAndAllDept", depId);
} }
@Override
public Result<List<Long>> getUserDeptScope(Long userId, String... typeKeys) {
return ModuleUtils.feignConError(ServiceConstant.EPDC_ADMIN_SERVER, "getUserDeptScope", typeKeys);
}
} }

13
epdc-cloud-news/src/main/java/com/elink/esua/epdc/service/impl/NewsServiceImpl.java

@ -18,11 +18,13 @@
package com.elink.esua.epdc.service.impl; package com.elink.esua.epdc.service.impl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
import com.elink.esua.epdc.commons.mybatis.utils.DeptEntityUtils; import com.elink.esua.epdc.commons.mybatis.utils.DeptEntityUtils;
import com.elink.esua.epdc.commons.tools.constant.NumConstant; import com.elink.esua.epdc.commons.tools.constant.NumConstant;
import com.elink.esua.epdc.commons.tools.constant.OrganizationTypeConstant;
import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum; 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.exception.RenException;
import com.elink.esua.epdc.commons.tools.page.PageData; import com.elink.esua.epdc.commons.tools.page.PageData;
@ -522,9 +524,14 @@ public class NewsServiceImpl extends BaseServiceImpl<NewsDao, NewsEntity> implem
@Override @Override
public PageData<NewsDTO> allPage(Map<String, Object> params) { public PageData<NewsDTO> allPage(Map<String, Object> params) {
UserDetail user = SecurityUser.getUser();
List<Long> deptIdList = user.getDeptIdList(); Result<List<Long>> result = adminFeignClient.getUserDeptScope(SecurityUser.getUserId(), OrganizationTypeConstant.ORG_TYPE_GRID_PARTY);
params.put("deptIdList", deptIdList); if (result.success()) {
params.put("deptIdList", result.getData());
} else {
params.put("deptIdList", SecurityUser.getUser().getDeptIdList());
}
IPage<NewsDTO> page = getPage(params); IPage<NewsDTO> page = getPage(params);
List<NewsDTO> newsDaoList = baseDao.selectAllPage(params); List<NewsDTO> newsDaoList = baseDao.selectAllPage(params);
return new PageData<>(newsDaoList, page.getTotal()); return new PageData<>(newsDaoList, page.getTotal());

25
epdc-cloud-news/src/main/resources/mapper/NewsDao.xml

@ -106,22 +106,13 @@
</update> </update>
<select id="selectAllPage" resultType="com.elink.esua.epdc.dto.NewsDTO"> <select id="selectAllPage" resultType="com.elink.esua.epdc.dto.NewsDTO">
SELECT SELECT
* *
FROM FROM
( (
SELECT DISTINCT SELECT DISTINCT nd.NEWS_ID FROM epdc_news_department nd WHERE nd.DEL_FLAG = '0'
nd.NEWS_ID <if test="deptIdList != null and deptIdList.size()>0">
FROM AND nd.DEPT_ID IN <foreach collection="deptIdList" open="(" separator="," close=")" item="deptId">#{deptId}</foreach>
epdc_news_department nd </if>
WHERE
<if test="deptIdList != null and deptIdList.size()>0">
nd.DEPT_ID IN
<foreach collection="deptIdList" open="(" separator="," close=")" item="deptId">#{deptId}</foreach>
AND
</if>
nd.DEL_FLAG = '0'
GROUP BY
nd.NEWS_ID
) t0 ) t0
LEFT JOIN epdc_news n ON t0.NEWS_ID = n.ID LEFT JOIN epdc_news n ON t0.NEWS_ID = n.ID
WHERE WHERE
@ -130,19 +121,17 @@
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''"> <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND DATE_FORMAT( n.CREATED_TIME, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} AND DATE_FORMAT( n.CREATED_TIME, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime}
</if> </if>
<if test="category != null and category != ''"> <if test="category != null and category != ''">
AND n.NEWS_CATERORY_ID like concat('%', #{category}, '%') AND n.NEWS_CATERORY_ID like concat('%', #{category}, '%')
</if> </if>
<if test="keyword != null and keyword != ''"> <if test="keyword != null and keyword != ''">
AND n.NEWS_TITLE like concat('%', #{keyword}, '%') AND n.NEWS_TITLE like concat('%', #{keyword}, '%')
</if> </if>
<if test="gridId != null and gridId != ''"> <if test="deptId != null and deptId != ''">
AND n.ALL_DEPT_IDS like concat('%', #{gridId}, '%') AND n.ALL_DEPT_IDS like concat('%', #{deptId}, '%')
</if> </if>
ORDER BY ORDER BY
n.CREATED_TIME DESC n.CREATED_TIME DESC
</select> </select>
<select id="selectListOfOrganizationInfo" resultType="com.elink.esua.epdc.dto.NewsDTO"> <select id="selectListOfOrganizationInfo" resultType="com.elink.esua.epdc.dto.NewsDTO">

Loading…
Cancel
Save