From b4362059b97ac88c100462c01c87c7481b7b3781 Mon Sep 17 00:00:00 2001
From: LiuY <1622779752@qq.com>
Date: Mon, 17 Apr 2023 14:30:44 +0800
Subject: [PATCH] =?UTF-8?q?1.=E5=8F=91=E5=B8=83=E6=96=B0=E9=97=BB=E5=A2=9E?=
=?UTF-8?q?=E5=8A=A0=E9=85=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 3 +-
.../NewsDirectoriesController.java | 2 +-
.../newsdirectories/NewsDirectoriesVO.java | 10 +++
.../impl/NewsContentServiceImpl.java | 90 ++++++++++++++++---
.../INewsDirectoriesService.java | 2 +-
.../impl/NewsDirectoriesServiceImpl.java | 4 +-
.../news/newscontent/newscontent-mapper.xml | 7 +-
.../newsdirectories-mapper.xml | 5 ++
.../newsdirectories/list-newsdirectories.html | 62 ++++++++++---
.../newsdirectories/save-newsdirectories.html | 14 ++-
.../update-newsdirectories.html | 12 +++
11 files changed, 179 insertions(+), 32 deletions(-)
diff --git a/pom.xml b/pom.xml
index 0c6ff4b..c5ce03f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -86,7 +86,7 @@
ink.wgink
login-wechat
1.0-SNAPSHOT
- provided
+
@@ -187,7 +187,6 @@
ZIP
-
non-exists
non-exists
diff --git a/src/main/java/cn/com/tenlion/xzszwhy/news/controller/apis/newsdirectories/NewsDirectoriesController.java b/src/main/java/cn/com/tenlion/xzszwhy/news/controller/apis/newsdirectories/NewsDirectoriesController.java
index 4d9d7ad..3914414 100644
--- a/src/main/java/cn/com/tenlion/xzszwhy/news/controller/apis/newsdirectories/NewsDirectoriesController.java
+++ b/src/main/java/cn/com/tenlion/xzszwhy/news/controller/apis/newsdirectories/NewsDirectoriesController.java
@@ -54,7 +54,7 @@ public class NewsDirectoriesController extends DefaultBaseController {
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PutMapping("update/dataauth/{newsDirectoriesId}/{directoriesDataAuth}")
@CheckRequestBodyAnnotation
- public SuccessResult updateDirectoriesDataAuth(@PathVariable("newsDirectoriesId") String newsDirectoriesId, @PathVariable("directoriesDataAuth") Boolean directoriesDataAuth) throws Exception {
+ public SuccessResult updateDirectoriesDataAuth(@PathVariable("newsDirectoriesId") String newsDirectoriesId, @PathVariable("directoriesDataAuth") String directoriesDataAuth) throws Exception {
return newsDirectoriesService.updateDirectoriesDataAuth(newsDirectoriesId, directoriesDataAuth);
}
diff --git a/src/main/java/cn/com/tenlion/xzszwhy/news/pojo/vos/newsdirectories/NewsDirectoriesVO.java b/src/main/java/cn/com/tenlion/xzszwhy/news/pojo/vos/newsdirectories/NewsDirectoriesVO.java
index c4f3ba7..e79d58c 100644
--- a/src/main/java/cn/com/tenlion/xzszwhy/news/pojo/vos/newsdirectories/NewsDirectoriesVO.java
+++ b/src/main/java/cn/com/tenlion/xzszwhy/news/pojo/vos/newsdirectories/NewsDirectoriesVO.java
@@ -56,6 +56,8 @@ public class NewsDirectoriesVO {
private String directoriesPlateShow;
@ApiModelProperty(name = "directoriesWebView", value = "web端列表显示方式")
private String directoriesWebView;
+ @ApiModelProperty(name = "directoriesDataAuth", value = "数据权限")
+ private String directoriesDataAuth;
public String getDirectoriesTarget1() {
return directoriesTarget1 == null ? "" : directoriesTarget1;
@@ -184,4 +186,12 @@ public class NewsDirectoriesVO {
public void setDirectoriesWebView(String directoriesWebView) {
this.directoriesWebView = directoriesWebView;
}
+
+ public String getDirectoriesDataAuth() {
+ return directoriesDataAuth;
+ }
+
+ public void setDirectoriesDataAuth(String directoriesDataAuth) {
+ this.directoriesDataAuth = directoriesDataAuth;
+ }
}
diff --git a/src/main/java/cn/com/tenlion/xzszwhy/news/service/newscontent/impl/NewsContentServiceImpl.java b/src/main/java/cn/com/tenlion/xzszwhy/news/service/newscontent/impl/NewsContentServiceImpl.java
index 7f7de8c..421fd34 100644
--- a/src/main/java/cn/com/tenlion/xzszwhy/news/service/newscontent/impl/NewsContentServiceImpl.java
+++ b/src/main/java/cn/com/tenlion/xzszwhy/news/service/newscontent/impl/NewsContentServiceImpl.java
@@ -39,6 +39,8 @@ import ink.wgink.exceptions.SaveException;
import ink.wgink.exceptions.SearchException;
import ink.wgink.interfaces.department.IDepartmentUserBaseService;
import ink.wgink.interfaces.user.IUserBaseService;
+import ink.wgink.module.dictionary.pojo.dtos.AreaDTO;
+import ink.wgink.module.dictionary.service.IAreaService;
import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.app.AppTokenUser;
import ink.wgink.pojo.dtos.department.DepartmentDTO;
@@ -91,6 +93,8 @@ public class NewsContentServiceImpl extends DefaultBaseService implements INewsC
private TemplateProperties templateProperties;
@Autowired
private IUserExpandService userExpandService;
+ @Autowired
+ private IAreaService areaService;
@@ -415,7 +419,8 @@ public class NewsContentServiceImpl extends DefaultBaseService implements INewsC
public SuccessResultList> listPageNewsContentToAppByAreaCode(ListPage page,String areaCode) throws SearchException {
Map params = page.getParams();
//按新闻区域查询
- params.put("newsContertAreaCode",this.checkAreaCode(areaCode,params));
+ //params.put("newsContertAreaCode",this.checkDataAreaAuth(areaCode,params));
+ params.put("areaCodeList",this.checkDataAreaAuth(areaCode,params));
/**
* start
* 废弃 新增字段 newsContertAreaCode-新闻区域
@@ -803,24 +808,87 @@ public class NewsContentServiceImpl extends DefaultBaseService implements INewsC
* @param params
* @return
*/
- private String checkAreaCode(String areaCode,Map params){
+ private List checkDataAreaAuth(String areaCode,Map params){
Object newsDirectoriesId = params.get("newsDirectoriesId");
Object newsDirectoriesParentId = params.get("newsDirectoriesParentId");
- //只查询本级新闻
+
if(newsDirectoriesId != null){
NewsDirectoriesDTO newsDirectories = iNewsDirectoriesService.getNewsDirectoriesById(newsDirectoriesId.toString());
- if("1".equals(newsDirectories.getDirectoriesDataAuth())){
- return areaCode;
- }
+ String directoriesDataAuth = newsDirectories.getDirectoriesDataAuth();
+ return checkDataAuth(directoriesDataAuth,areaCode);
}
if(newsDirectoriesParentId != null){
NewsDirectoriesDTO newsDirectories = iNewsDirectoriesService.getNewsDirectoriesById(newsDirectoriesParentId.toString());
- if("1".equals(newsDirectories.getDirectoriesDataAuth())){
- return areaCode;
- }
+ String directoriesDataAuth = newsDirectories.getDirectoriesDataAuth();
+ return checkDataAuth(directoriesDataAuth,areaCode);
}
- //查询下级新闻
- return areaCode.replaceAll("(0)+$", "");
+ return new ArrayList<>();
}
+
+ private List checkDataAuth(String directoriesDataAuth, String areaCode){
+ List areaList = new ArrayList<>();
+ // 上级显示
+ if("1".equals(directoriesDataAuth)){
+ return downAllArea(areaCode,areaList);
+ }
+ // 本级显示
+ if("2".equals(directoriesDataAuth)){
+ areaList.add(areaCode);
+ }
+ // 下级显示
+ if("3".equals(directoriesDataAuth)){
+ return onAllArea(areaCode,areaList);
+ }
+ // 全部展示
+ if("4".equals(directoriesDataAuth)){
+ return areaList;
+ }
+ // 没配置默认本级显示
+ return areaList;
+ }
+
+
+ /**
+ * 获得所有上级区域编码(截止到市级)
+ * @param areaCode
+ * @param onAreaList
+ * @return
+ */
+ private List onAllArea(String areaCode,List onAreaList){
+ onAreaList.add(areaCode);
+ AreaDTO area = areaService.getByCode(areaCode);
+ if(area == null){
+ return onAreaList;
+ }
+ // 到市级截止
+ if("1".equals(area.getAreaLevel())){
+ return onAreaList;
+ }
+ AreaDTO areaParent = areaService.get(area.getAreaParentId());
+ if(areaParent == null){
+ return onAreaList;
+ }
+ return onAllArea(areaParent.getAreaCode(),onAreaList);
+ }
+
+ /**
+ * 获取所有下级区域编码
+ * @param areaCode
+ * @param downAreaList
+ * @return
+ */
+ private List downAllArea(String areaCode,List downAreaList){
+ downAreaList.add(areaCode);
+ List areaDTOS = areaService.listSubByCode(areaCode);
+ areaDTOS.forEach( data -> {
+ downAreaList.add(data.getAreaCode());
+ });
+ return downAreaList;
+
+ }
+
+
+
+
}
diff --git a/src/main/java/cn/com/tenlion/xzszwhy/news/service/newsdirectories/INewsDirectoriesService.java b/src/main/java/cn/com/tenlion/xzszwhy/news/service/newsdirectories/INewsDirectoriesService.java
index 79ac153..255dc07 100644
--- a/src/main/java/cn/com/tenlion/xzszwhy/news/service/newsdirectories/INewsDirectoriesService.java
+++ b/src/main/java/cn/com/tenlion/xzszwhy/news/service/newsdirectories/INewsDirectoriesService.java
@@ -34,7 +34,7 @@ public interface INewsDirectoriesService {
* @return
* @throws Exception
*/
- SuccessResult updateDirectoriesDataAuth(String newsDirectoriesId, Boolean directoriesDataAuth) throws Exception;
+ SuccessResult updateDirectoriesDataAuth(String newsDirectoriesId, String directoriesDataAuth) throws Exception;
/**
diff --git a/src/main/java/cn/com/tenlion/xzszwhy/news/service/newsdirectories/impl/NewsDirectoriesServiceImpl.java b/src/main/java/cn/com/tenlion/xzszwhy/news/service/newsdirectories/impl/NewsDirectoriesServiceImpl.java
index 03226a1..06b342c 100644
--- a/src/main/java/cn/com/tenlion/xzszwhy/news/service/newsdirectories/impl/NewsDirectoriesServiceImpl.java
+++ b/src/main/java/cn/com/tenlion/xzszwhy/news/service/newsdirectories/impl/NewsDirectoriesServiceImpl.java
@@ -103,10 +103,10 @@ public class NewsDirectoriesServiceImpl extends DefaultBaseService implements IN
@Override
- public SuccessResult updateDirectoriesDataAuth(String newsDirectoriesId, Boolean directoriesDataAuth) throws Exception {
+ public SuccessResult updateDirectoriesDataAuth(String newsDirectoriesId, String directoriesDataAuth) throws Exception {
Map params = HashMapUtil.beanToMap(3);
params.put("newsDirectoriesId", newsDirectoriesId);
- params.put("directoriesDataAuth", directoriesDataAuth ? "1" : "0");
+ params.put("directoriesDataAuth", directoriesDataAuth);
setUpdateInfo(params);
newsDirectoriesDao.updateDirectoriesDataAuth(params);
return new SuccessResult();
diff --git a/src/main/resources/mybatis/mapper/news/newscontent/newscontent-mapper.xml b/src/main/resources/mybatis/mapper/news/newscontent/newscontent-mapper.xml
index b8dff67..30465ba 100644
--- a/src/main/resources/mybatis/mapper/news/newscontent/newscontent-mapper.xml
+++ b/src/main/resources/mybatis/mapper/news/newscontent/newscontent-mapper.xml
@@ -442,7 +442,12 @@
AND t1.news_contert_area_code LIKE CONCAT('%', #{newsContertAreaCode}, '%')
-
+
+ AND t1.news_contert_area_code IN
+
+ #{areaCodeList[${index}]}
+
+
) app
ORDER BY app.news_config_top DESC, app.news_config_hot DESC, app.news_content_score DESC , app.news_content_publish_time DESC, app.gmt_create DESC
diff --git a/src/main/resources/mybatis/mapper/news/newsdirectories/newsdirectories-mapper.xml b/src/main/resources/mybatis/mapper/news/newsdirectories/newsdirectories-mapper.xml
index e5b2ae2..6b066e1 100644
--- a/src/main/resources/mybatis/mapper/news/newsdirectories/newsdirectories-mapper.xml
+++ b/src/main/resources/mybatis/mapper/news/newsdirectories/newsdirectories-mapper.xml
@@ -166,6 +166,7 @@
directories_menu_show,
directories_plate_show,
directories_web_view,
+ directories_data_auth,
creator,
gmt_create,
modifier,
@@ -189,6 +190,7 @@
#{directoriesMenuShow},
#{directoriesPlateShow},
#{directoriesWebView},
+ #{directoriesDataAuth},
#{creator},
#{gmtCreate},
#{modifier},
@@ -264,6 +266,9 @@
directories_web_view = #{directoriesWebView},
+
+
+ directories_data_auth = #{directoriesDataAuth},
modifier = #{modifier},
gmt_modified = #{gmtModified}
diff --git a/src/main/resources/static/route/news/newsdirectories/list-newsdirectories.html b/src/main/resources/static/route/news/newsdirectories/list-newsdirectories.html
index 44f067a..5b2f9a3 100644
--- a/src/main/resources/static/route/news/newsdirectories/list-newsdirectories.html
+++ b/src/main/resources/static/route/news/newsdirectories/list-newsdirectories.html
@@ -9,9 +9,10 @@
+
-