Browse Source

1、初始化

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

+ 4 - 12
src/main/java/com/lqkj/business/controller/CmsNewsController.java

@@ -121,12 +121,8 @@ public class CmsNewsController extends BaseController
121 121
     @PostMapping
122 122
     public ResultUtil add(@RequestBody CmsNews cmsNews)
123 123
     {
124
-        if(StringUtils.isNotEmpty(cmsNews.getContent())){
125
-            cmsNews.setContent(HtmlUtils.htmlUnescape(cmsNews.getContent()));
126
-        }
127
-        if(StringUtils.isNotEmpty(cmsNews.getTitle())){
128
-            cmsNews.setTitle(HtmlUtils.htmlUnescape(cmsNews.getTitle()));
129
-        }
124
+        cmsNews.setContent(htmlUnescape(cmsNews.getContent()));
125
+        cmsNews.setTitle(htmlUnescape(cmsNews.getTitle()));
130 126
         cmsNews.setCreateBy(getNickName());
131 127
         return resultByRows(cmsNewsService.insertCmsNews(cmsNews));
132 128
     }
@@ -140,12 +136,8 @@ public class CmsNewsController extends BaseController
140 136
     @PutMapping
141 137
     public ResultUtil edit(@RequestBody CmsNews cmsNews)
142 138
     {
143
-        if(StringUtils.isNotEmpty(cmsNews.getContent())){
144
-            cmsNews.setContent(HtmlUtils.htmlUnescape(cmsNews.getContent()));
145
-        }
146
-        if(StringUtils.isNotEmpty(cmsNews.getTitle())){
147
-            cmsNews.setTitle(HtmlUtils.htmlUnescape(cmsNews.getTitle()));
148
-        }
139
+        cmsNews.setContent(htmlUnescape(cmsNews.getContent()));
140
+        cmsNews.setTitle(htmlUnescape(cmsNews.getTitle()));
149 141
         cmsNews.setUpdateBy(getNickName());
150 142
         return resultByRows(cmsNewsService.updateCmsNews(cmsNews));
151 143
     }

+ 9 - 0
src/main/java/com/lqkj/common/core/controller/BaseController.java

@@ -9,6 +9,7 @@ import com.lqkj.common.utils.StringUtils;
9 9
 import com.lqkj.common.utils.sql.SqlUtil;
10 10
 import org.slf4j.Logger;
11 11
 import org.slf4j.LoggerFactory;
12
+import org.springframework.web.util.HtmlUtils;
12 13
 
13 14
 import java.time.LocalDate;
14 15
 
@@ -90,4 +91,12 @@ public class BaseController {
90 91
     public int getCurrentMonth(){
91 92
         return LocalDate.now().getMonthValue();
92 93
     }
94
+
95
+    public String htmlUnescape(String data){
96
+        if (StringUtils.isNotEmpty(data)){
97
+            return HtmlUtils.htmlUnescape(data);
98
+        }else{
99
+            return null;
100
+        }
101
+    }
93 102
 }

+ 4 - 8
src/main/java/com/lqkj/system/controller/SysApiConfigController.java

@@ -93,10 +93,8 @@ public class SysApiConfigController extends BaseController
93 93
             return ResultUtil.error("新增接口'" + sysApiConfig.getRoutePath() + "'失败,接口路由已存在");
94 94
         }
95 95
         sysApiConfig.setCreateBy(getNickName());
96
-        sysApiConfig.setSqlStr(HtmlUtils.htmlUnescape(sysApiConfig.getSqlStr()));
97
-        if (StringUtils.isNotEmpty(sysApiConfig.getParamExample())){
98
-            sysApiConfig.setParamExample(HtmlUtils.htmlUnescape(sysApiConfig.getParamExample()));
99
-        }
96
+        sysApiConfig.setSqlStr(htmlUnescape(sysApiConfig.getSqlStr()));
97
+        sysApiConfig.setParamExample(htmlUnescape(sysApiConfig.getParamExample()));
100 98
         return resultByRows(sysApiConfigService.insertSysApiConfig(sysApiConfig));
101 99
     }
102 100
 
@@ -114,10 +112,8 @@ public class SysApiConfigController extends BaseController
114 112
             return ResultUtil.error("修改接口'" + sysApiConfig.getRoutePath() + "'失败,接口路由已存在");
115 113
         }
116 114
         sysApiConfig.setUpdateBy(getNickName());
117
-        sysApiConfig.setSqlStr(HtmlUtils.htmlUnescape(sysApiConfig.getSqlStr()));
118
-        if (StringUtils.isNotEmpty(sysApiConfig.getParamExample())){
119
-            sysApiConfig.setParamExample(HtmlUtils.htmlUnescape(sysApiConfig.getParamExample()));
120
-        }
115
+        sysApiConfig.setSqlStr(htmlUnescape(sysApiConfig.getSqlStr()));
116
+        sysApiConfig.setParamExample(htmlUnescape(sysApiConfig.getParamExample()));
121 117
         return resultByRows(sysApiConfigService.updateSysApiConfig(sysApiConfig));
122 118
     }
123 119
 

+ 4 - 0
src/main/java/com/lqkj/system/controller/SysNoticeController.java

@@ -118,6 +118,8 @@ public class SysNoticeController extends BaseController
118 118
     @PostMapping
119 119
     public ResultUtil add(@Validated @RequestBody SysNotice notice)
120 120
     {
121
+        notice.setNoticeTitle(htmlUnescape(notice.getNoticeTitle()));
122
+        notice.setNoticeContent(htmlUnescape(notice.getNoticeContent()));
121 123
         notice.setCreateBy(getNickName());
122 124
         return resultByRows(noticeService.insertNotice(notice));
123 125
     }
@@ -131,6 +133,8 @@ public class SysNoticeController extends BaseController
131 133
     @PutMapping
132 134
     public ResultUtil edit(@Validated @RequestBody SysNotice notice)
133 135
     {
136
+        notice.setNoticeTitle(htmlUnescape(notice.getNoticeTitle()));
137
+        notice.setNoticeContent(htmlUnescape(notice.getNoticeContent()));
134 138
         notice.setUpdateBy(getNickName());
135 139
         return resultByRows(noticeService.updateNotice(notice));
136 140
     }