Browse Source

1、初始化

lqkj@you07.com 1 year ago
parent
commit
4a16c75a37

+ 7 - 0
src/main/java/com/lqkj/business/controller/CmsCategoryController.java

@@ -37,6 +37,13 @@ public class CmsCategoryController extends BaseController
37 37
     @Autowired
38 38
     private CmsCategoryService cmsCategoryService;
39 39
 
40
+    @ApiOperation("根据父分类编号查询")
41
+    @GetMapping("/front/child/{categoryId}")
42
+    public ResultUtil selectByParentId(@PathVariable("categoryId") Long categoryId){
43
+        CmsCategory category = new CmsCategory();
44
+        category.setParentId(categoryId);
45
+        return ResultUtil.success(cmsCategoryService.selectCmsCategoryList(category));
46
+    }
40 47
     @ApiOperation("查询一级分类列表")
41 48
     @GetMapping("/parentList")
42 49
     public ResultUtil selectParentList(){

+ 18 - 0
src/main/java/com/lqkj/business/controller/CmsNewsController.java

@@ -124,6 +124,9 @@ public class CmsNewsController extends BaseController
124 124
         if(StringUtils.isNotEmpty(cmsNews.getContent())){
125 125
             cmsNews.setContent(HtmlUtils.htmlUnescape(cmsNews.getContent()));
126 126
         }
127
+        if(StringUtils.isNotEmpty(cmsNews.getTitle())){
128
+            cmsNews.setTitle(HtmlUtils.htmlUnescape(cmsNews.getTitle()));
129
+        }
127 130
         cmsNews.setCreateBy(getNickName());
128 131
         return resultByRows(cmsNewsService.insertCmsNews(cmsNews));
129 132
     }
@@ -140,6 +143,9 @@ public class CmsNewsController extends BaseController
140 143
         if(StringUtils.isNotEmpty(cmsNews.getContent())){
141 144
             cmsNews.setContent(HtmlUtils.htmlUnescape(cmsNews.getContent()));
142 145
         }
146
+        if(StringUtils.isNotEmpty(cmsNews.getTitle())){
147
+            cmsNews.setTitle(HtmlUtils.htmlUnescape(cmsNews.getTitle()));
148
+        }
143 149
         cmsNews.setUpdateBy(getNickName());
144 150
         return resultByRows(cmsNewsService.updateCmsNews(cmsNews));
145 151
     }
@@ -154,6 +160,18 @@ public class CmsNewsController extends BaseController
154 160
     public ResultUtil updateTopStatus(@RequestBody CmsNews cmsNews){
155 161
         return resultByRows(cmsNewsService.updateTopStatus(cmsNews));
156 162
     }
163
+
164
+    /**
165
+     * 轮播操作
166
+     */
167
+    @ApiOperation("轮播状态")
168
+    @PreAuthorize("@ss.hasPermi('business:cmsNews:edit')")
169
+    @Log(title = "信息管理", businessType = BusinessType.UPDATE)
170
+    @PutMapping("/updateCarouselStatus")
171
+    public ResultUtil updateCarouselStatus(@RequestBody CmsNews cmsNews){
172
+        return resultByRows(cmsNewsService.updateCarouselStatus(cmsNews));
173
+    }
174
+
157 175
     /**
158 176
      * 删除信息
159 177
      */

+ 29 - 18
src/main/java/com/lqkj/business/entity/CmsNews.java

@@ -20,7 +20,7 @@ public class CmsNews extends BaseEntity
20 20
     private String newsId;
21 21
 
22 22
     /** 所属分类 */
23
-    @Excel(name = "所属分类")
23
+//    @Excel(name = "所属分类")
24 24
     private Integer categoryId;
25 25
 
26 26
     /** 标题 */
@@ -35,9 +35,13 @@ public class CmsNews extends BaseEntity
35 35
     private Integer viewCount;
36 36
 
37 37
     /** 是否置顶 */
38
-    @Excel(name = "是否置顶")
38
+    @Excel(name = "是否置顶", readConverterExp = "true=是,false=否")
39 39
     private Boolean isTop;
40 40
 
41
+    /** 是否轮播 */
42
+    @Excel(name = "是否轮播", readConverterExp = "true=是,false=否")
43
+    private Boolean carousel;
44
+
41 45
     /** 缩略图 */
42 46
     @Excel(name = "缩略图")
43 47
     private String thumbnail;
@@ -49,7 +53,7 @@ public class CmsNews extends BaseEntity
49 53
     private Object focusImgs;
50 54
 
51 55
     @Excels({
52
-            @Excel(name = "分类", targetAttr = "name", type = Excel.Type.EXPORT)})
56
+            @Excel(name = "分类名称", targetAttr = "name", type = Excel.Type.EXPORT)})
53 57
     private CmsCategory cmsCategory;
54 58
 
55 59
     public void setNewsId(String newsId)
@@ -141,22 +145,29 @@ public class CmsNews extends BaseEntity
141 145
         this.focusImgs = focusImgs;
142 146
     }
143 147
 
148
+
149
+    public Boolean getCarousel() {
150
+        return carousel;
151
+    }
152
+
153
+    public void setCarousel(Boolean carousel) {
154
+        this.carousel = carousel;
155
+    }
156
+
144 157
     @Override
145 158
     public String toString() {
146
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
147
-                .append("newsId", getNewsId())
148
-                .append("categoryId", getCategoryId())
149
-                .append("title", getTitle())
150
-                .append("content", getContent())
151
-                .append("viewCount", getViewCount())
152
-                .append("isTop", getIsTop())
153
-                .append("thumbnail", getThumbnail())
154
-                .append("videoUrl", getVideoUrl())
155
-                .append("createBy", getCreateBy())
156
-                .append("createTime", getCreateTime())
157
-                .append("updateBy", getUpdateBy())
158
-                .append("updateTime", getUpdateTime())
159
-                .append("remark", getRemark())
160
-                .toString();
159
+        return "CmsNews{" +
160
+                "newsId='" + newsId + '\'' +
161
+                ", categoryId=" + categoryId +
162
+                ", title='" + title + '\'' +
163
+                ", content='" + content + '\'' +
164
+                ", viewCount=" + viewCount +
165
+                ", isTop=" + isTop +
166
+                ", carousel=" + carousel +
167
+                ", thumbnail='" + thumbnail + '\'' +
168
+                ", videoUrl='" + videoUrl + '\'' +
169
+                ", focusImgs=" + focusImgs +
170
+                ", cmsCategory=" + cmsCategory +
171
+                '}';
161 172
     }
162 173
 }

+ 2 - 0
src/main/java/com/lqkj/business/mapper/CmsNewsMapper.java

@@ -66,4 +66,6 @@ public interface CmsNewsMapper
66 66
     public int updateTopStatus(CmsNews cmsNews);
67 67
 
68 68
     public int plusViewCount(String newsId);
69
+
70
+    public int updateCarouselStatus(CmsNews cmsNews);
69 71
 }

+ 4 - 0
src/main/java/com/lqkj/business/service/CmsNewsService.java

@@ -101,6 +101,10 @@ public class CmsNewsService
101 101
         return cmsNewsMapper.updateTopStatus(cmsNews);
102 102
     }
103 103
 
104
+    public int updateCarouselStatus(CmsNews cmsNews){
105
+        return cmsNewsMapper.updateCarouselStatus(cmsNews);
106
+    }
107
+
104 108
     public int plusViewCount(String newsId){
105 109
         return cmsNewsMapper.plusViewCount(newsId);
106 110
     }

+ 1 - 0
src/main/java/com/lqkj/framework/security/ResourceServerConfig.java

@@ -45,6 +45,7 @@ public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
45 45
                 .antMatchers("/oauth/**",
46 46
                 "/v1/captchaImage",
47 47
                 "/business/cmsNews/front/**",
48
+                "/business/cmsCategory/front/**",
48 49
                 "/login",
49 50
                 "/**/*.css",
50 51
                 "/**/*.js",

+ 4 - 0
src/main/resources/db/migration/V1_1__init.sql

@@ -1320,6 +1320,7 @@ create table cms_news (
1320 1320
       content              TEXT                 null,
1321 1321
       view_count           INT4                 null,
1322 1322
       is_top               BOOL                 null,
1323
+      is_carousel             BOOL                 null,
1323 1324
       thumbnail            VARCHAR(255)         null,
1324 1325
       focus_imgs           JSONB                null,
1325 1326
       video_url            VARCHAR(255)         null,
@@ -1352,6 +1353,9 @@ comment on column cms_news.view_count is
1352 1353
 comment on column cms_news.is_top is
1353 1354
 '是否置顶';
1354 1355
 
1356
+comment on column cms_news.is_carousel is
1357
+'是否轮播';
1358
+
1355 1359
 comment on column cms_news.thumbnail is
1356 1360
 '缩略图';
1357 1361
 

+ 20 - 0
src/main/resources/db/migration/V1_2__20230202.sql

@@ -1,3 +1,23 @@
1 1
 update sys_config set config_value = '白玉县水利局管理系统' where config_key = 'sys.index.title';
2 2
 
3
+delete from cms_category;
4
+insert into cms_category values(1, 0, null, '新闻资讯', 0, null, 1, '超级管理员', now());
5
+insert into cms_category values(2, 0, null, '关于我们', 0, null, 2, '超级管理员', now());
6
+insert into cms_category values(3, 0, null, '水电站简介', 0, null, 3, '超级管理员', now());
3 7
 
8
+insert into cms_category values(4, 1, null, '水利要闻', 0, null, 1, '超级管理员', now());
9
+insert into cms_category values(5, 1, null, '通知公告', 0, null, 2, '超级管理员', now());
10
+insert into cms_category values(6, 1, null, '政策文件', 0, null, 3, '超级管理员', now());
11
+
12
+insert into cms_category values(7, 2, null, '单位简介', 1, null, 1, '超级管理员', now());
13
+insert into cms_category values(8, 2, null, '机构设置', 1, null, 2, '超级管理员', now());
14
+insert into cms_category values(9, 2, null, '河湖长简介', 1, null, 3, '超级管理员', now());
15
+
16
+insert into cms_category values(10, 3, null, '叶巴滩水电站', 1, null, 1, '超级管理员', now());
17
+insert into cms_category values(11, 3, null, '松雪水电站', 1, null, 2, '超级管理员', now());
18
+insert into cms_category values(12, 3, null, '拉哇水电站', 1, null, 3, '超级管理员', now());
19
+
20
+SELECT setval('cms_category_category_id_seq', 100, true);
21
+
22
+delete from sys_menu where parent_id = 107 or parent_id = 120 or parent_id = 123;
23
+delete from sys_menu where menu_id = 107 or menu_id = 120 or menu_id = 123;

+ 1 - 0
src/main/resources/mapper/business/CmsCategoryMapper.xml

@@ -32,6 +32,7 @@
32 32
         <where>
33 33
             <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
34 34
             <if test="categoryType != null "> and category_type = #{categoryType}</if>
35
+            <if test="parentId != null"> and parent_id = #{parentId}</if>
35 36
         </where>
36 37
         order by order_num, create_time
37 38
 

+ 10 - 3
src/main/resources/mapper/business/CmsNewsMapper.xml

@@ -11,6 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
11 11
         <result property="content"    column="content"    />
12 12
         <result property="viewCount"    column="view_count"    />
13 13
         <result property="isTop"    column="is_top"    />
14
+        <result property="carousel" column="is_carousel" />
14 15
         <result property="thumbnail"    column="thumbnail"    />
15 16
         <result property="videoUrl"    column="video_url"    />
16 17
         <result property="createBy"    column="create_by"    />
@@ -28,7 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
28 29
     </resultMap>
29 30
 
30 31
     <sql id="selectCmsNewsVo">
31
-        select t1.news_id, t1.category_id, t1.title, t1.content, t1.view_count, t1.is_top, t1.thumbnail, t1.focus_imgs, t1.video_url, t1.create_by, t1.create_time, t1.update_by, t1.update_time, t1.remark, t2.name as category_name from cms_news as t1
32
+        select t1.news_id, t1.category_id, t1.title, t1.content, t1.view_count, t1.is_top, t1.is_carousel, t1.thumbnail, t1.focus_imgs, t1.video_url, t1.create_by, t1.create_time, t1.update_by, t1.update_time, t1.remark, t2.name as category_name from cms_news as t1
32 33
         left join cms_category as t2 on t1.category_id = t2.category_id
33 34
     </sql>
34 35
 
@@ -37,10 +38,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
37 38
         <where>  
38 39
             <if test="title != null  and title != ''"> and t1.title like concat('%', #{title}, '%')</if>
39 40
             <if test="isTop != null "> and t1.is_top = #{isTop}</if>
41
+            <if test="carousel != null"> and t1.is_carousel = #{carousel}</if>
40 42
             <if test="categoryId != null"> and (t1.category_id = #{categoryId} or t1.category_id in ( SELECT t.category_id FROM cms_category t WHERE parent_id = #{categoryId} ))</if>
41 43
         </where>
42
-        order by t1.create_time desc
43
-
44
+        order by t1.is_top desc, t1.create_time desc
44 45
     </select>
45 46
     
46 47
     <select id="selectCmsNewsByNewsId" parameterType="String" resultMap="CmsNewsResult">
@@ -62,6 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
62 63
             <if test="title != null and title != ''">content,</if>
63 64
             <if test="viewCount != null">view_count,</if>
64 65
             <if test="isTop != null">is_top,</if>
66
+            <if test="carousel != null">is_carousel,</if>
65 67
             <if test="thumbnail != null and thumbnail != ''">thumbnail,</if>
66 68
             <if test="focusImgs != null">focus_imgs,</if>
67 69
             <if test="videoUrl != null and videoUrl != ''">video_url,</if>
@@ -78,6 +80,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
78 80
             <if test="content != null and content != ''">#{content},</if>
79 81
             <if test="viewCount != null">#{viewCount},</if>
80 82
             <if test="isTop != null">#{isTop},</if>
83
+            <if test="carousel != null">#{carousel},</if>
81 84
             <if test="thumbnail != null and thumbnail != ''">#{thumbnail},</if>
82 85
             <if test="focusImgs != null">#{focusImgs,jdbcType=OTHER,typeHandler=com.lqkj.framework.sql.JsonbTypeHandler},</if>
83 86
             <if test="videoUrl != null and videoUrl != ''">#{videoUrl},</if>
@@ -88,6 +91,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
88 91
             <if test="remark != null and remark != ''">#{remark},</if>
89 92
          </trim>
90 93
     </insert>
94
+    <update id="updateCarouselStatus" parameterType="CmsNews">
95
+        update cms_news set is_carousel = #{carousel} where news_id = #{newsId}
96
+    </update>
91 97
     <update id="updateTopStatus" parameterType="CmsNews">
92 98
         update cms_news set is_top = #{isTop} where news_id = #{newsId}
93 99
     </update>
@@ -102,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
102 108
             content = #{content},
103 109
             <if test="viewCount != null ">view_count = #{viewCount},</if>
104 110
             <if test="isTop != null ">is_top = #{isTop},</if>
111
+            <if test="carousel != null ">is_carousel = #{carousel},</if>
105 112
             thumbnail = #{thumbnail},
106 113
             focus_imgs = #{focusImgs, jdbcType=OTHER, typeHandler=com.lqkj.framework.sql.JsonbTypeHandler},
107 114
             video_url = #{videoUrl},