Showing
2 changed files
with
256 additions
and
7 deletions
@@ -11,11 +11,13 @@ import com.yohobuy.platform.dal.grass.model.GrassArticleImage; | @@ -11,11 +11,13 @@ import com.yohobuy.platform.dal.grass.model.GrassArticleImage; | ||
11 | import com.yohobuy.platform.dal.grass.model.GrassArticleSkn; | 11 | import com.yohobuy.platform.dal.grass.model.GrassArticleSkn; |
12 | import com.yohobuy.platform.grass.service.IGrassArticleService; | 12 | import com.yohobuy.platform.grass.service.IGrassArticleService; |
13 | import com.yohobuy.platform.model.grass.request.GrassArticleReq; | 13 | import com.yohobuy.platform.model.grass.request.GrassArticleReq; |
14 | +import org.apache.commons.lang3.StringUtils; | ||
14 | import org.slf4j.Logger; | 15 | import org.slf4j.Logger; |
15 | import org.slf4j.LoggerFactory; | 16 | import org.slf4j.LoggerFactory; |
16 | import org.springframework.stereotype.Component; | 17 | import org.springframework.stereotype.Component; |
17 | 18 | ||
18 | import javax.annotation.Resource; | 19 | import javax.annotation.Resource; |
20 | +import java.util.Arrays; | ||
19 | import java.util.List; | 21 | import java.util.List; |
20 | 22 | ||
21 | /** | 23 | /** |
@@ -53,10 +55,10 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ | @@ -53,10 +55,10 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ | ||
53 | 55 | ||
54 | try{ | 56 | try{ |
55 | List<GrassArticleImage> imageList = Lists.newArrayList(); | 57 | List<GrassArticleImage> imageList = Lists.newArrayList(); |
56 | - | ||
57 | - for (String img: req.getArticleImages()) { | 58 | + String[] urls = req.getArticleImages().split(","); |
59 | + for (String img: urls) { | ||
58 | GrassArticleImage image = new GrassArticleImage(); | 60 | GrassArticleImage image = new GrassArticleImage(); |
59 | - image.setArticleId(article.getGuangArticleId()); | 61 | + image.setArticleId(article.getId()); |
60 | image.setImgSrc(img); | 62 | image.setImgSrc(img); |
61 | image.setCreateTime(DateUtil.getCurrentTimeSeconds()); | 63 | image.setCreateTime(DateUtil.getCurrentTimeSeconds()); |
62 | imageList.add(image); | 64 | imageList.add(image); |
@@ -69,9 +71,10 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ | @@ -69,9 +71,10 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ | ||
69 | 71 | ||
70 | try{ | 72 | try{ |
71 | List<GrassArticleSkn> sknList = Lists.newArrayList(); | 73 | List<GrassArticleSkn> sknList = Lists.newArrayList(); |
72 | - for (String skn: req.getArticleSkns()) { | 74 | + String[] skns = req.getArticleSkns().split(","); |
75 | + for (String skn: skns) { | ||
73 | GrassArticleSkn grassArticleSkn = new GrassArticleSkn(); | 76 | GrassArticleSkn grassArticleSkn = new GrassArticleSkn(); |
74 | - grassArticleSkn.setArticleId(article.getGuangArticleId()); | 77 | + grassArticleSkn.setArticleId(article.getId()); |
75 | grassArticleSkn.setProductSkn(Integer.valueOf(skn)); | 78 | grassArticleSkn.setProductSkn(Integer.valueOf(skn)); |
76 | grassArticleSkn.setCreateTime(DateUtil.getCurrentTimeSeconds()); | 79 | grassArticleSkn.setCreateTime(DateUtil.getCurrentTimeSeconds()); |
77 | sknList.add(grassArticleSkn); | 80 | sknList.add(grassArticleSkn); |
@@ -90,11 +93,11 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ | @@ -90,11 +93,11 @@ public class GrassArticleServiceImpl implements IGrassArticleService{ | ||
90 | logger.info("publishCheck uid is null"); | 93 | logger.info("publishCheck uid is null"); |
91 | throw new PlatformException("publish uid is null", 403); | 94 | throw new PlatformException("publish uid is null", 403); |
92 | } | 95 | } |
93 | - if(req.getArticleImages() ==null || req.getArticleImages().size()< 1){ | 96 | + if(StringUtils.isEmpty(req.getArticleImages())){ |
94 | logger.info("publishCheck images is null"); | 97 | logger.info("publishCheck images is null"); |
95 | throw new PlatformException("publish images is null", 403); | 98 | throw new PlatformException("publish images is null", 403); |
96 | } | 99 | } |
97 | - if(req.getArticleSkns() ==null || req.getArticleSkns().size()< 1){ | 100 | + if(StringUtils.isEmpty(req.getArticleSkns())){ |
98 | logger.info("publishCheck skn is null"); | 101 | logger.info("publishCheck skn is null"); |
99 | throw new PlatformException("publish skn is null", 403); | 102 | throw new PlatformException("publish skn is null", 403); |
100 | } | 103 | } |
1 | +<!DOCTYPE html> | ||
2 | +<html> | ||
3 | +<head> | ||
4 | + <meta charset="UTF-8" /> | ||
5 | + <title>Yoho!Buy运营平台</title> | ||
6 | + <script src="/pfcms/js/include.js"></script> | ||
7 | + <script src="/pfcms/js/ajaxfileupload.js"></script> | ||
8 | + <style> | ||
9 | + .btn-long { | ||
10 | + width: 120px; | ||
11 | + height: 37px; | ||
12 | + line-height: 37px; | ||
13 | + font-size: 15px; | ||
14 | + color: white; | ||
15 | + border-radius: 5px; | ||
16 | + display: inline-block; | ||
17 | + cursor: pointer; | ||
18 | + text-align: center; | ||
19 | + } | ||
20 | + .btn-long:hover { | ||
21 | + opacity: 0.9; | ||
22 | + } | ||
23 | + | ||
24 | + </style> | ||
25 | +</head> | ||
26 | +<body class="easyui-layout" > | ||
27 | +<div region="north" style="height: 100px;"> | ||
28 | + <script> | ||
29 | + document.write(addHead('运营管理', '种草内容发布')); | ||
30 | + </script> | ||
31 | + | ||
32 | +</div> | ||
33 | +<div region="center" id="labelGroupList" style="margin-left: 20px"> | ||
34 | + <div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll"> | ||
35 | + <form name="publishArticleForm" id="publishArticleForm" method="post" > | ||
36 | + <div style="margin-top: 20px;margin-left: 30px"> | ||
37 | + <table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab"> | ||
38 | + | ||
39 | + <tr style="height: 60px"> | ||
40 | + <td > | ||
41 | + <span style="color:red">*</span><label>选择用户</label> <br> | ||
42 | + <input id="articleUid" name="articleUid" class="easyui-textbox" style="width: 380px;"/> | ||
43 | + </td> | ||
44 | + </tr> | ||
45 | + | ||
46 | + <tr style="height: 60px"> | ||
47 | + <td> | ||
48 | + <span style="color:red">*</span><label>文字内容</label> <br> | ||
49 | + <input id="content" name="content" class="easyui-textbox" style="width: 380px;"/> | ||
50 | + </td> | ||
51 | + </tr> | ||
52 | + | ||
53 | + <tr style="height: 60px"> | ||
54 | + <td> | ||
55 | + <span style="color:red">*</span><label>选择话题</label> <br> | ||
56 | + <input id="topic" name="topicId" class="easyui-combobox" style="width: 380px;"/> | ||
57 | + </td> | ||
58 | + </tr> | ||
59 | + <tr style="height: 20px"> | ||
60 | + <td > | ||
61 | + <span style="color:red">*</span><label>选择图片</label> | ||
62 | + <a id="addImage" class="btn-default" >选择图片+</a> | ||
63 | + <input id="imgs" name="articleImages" hidden="hidden"/> | ||
64 | + </td> | ||
65 | + </tr> | ||
66 | + <tr style="height: 60px"> | ||
67 | + <td id="imgTd"> | ||
68 | + <div id="imageUpload"> | ||
69 | + </div> | ||
70 | + </td> | ||
71 | + </tr> | ||
72 | + <tr style="height: 60px"> | ||
73 | + <td> | ||
74 | + <span style="color:red">*</span><label>关联商品</label> <br> | ||
75 | + <a id="addSkn" class="btn-default" >新增商品+</a> | ||
76 | + <input id="skns" name="articleSkns" hidden="hidden"/> | ||
77 | + </td> | ||
78 | + <td> | ||
79 | + <img id="good1" src="" hidden> | ||
80 | + <img id="good2" src="" hidden> | ||
81 | + </td> | ||
82 | + </tr> | ||
83 | + <tr> | ||
84 | + <td height="50" valign="bottom"> | ||
85 | + <input class="btn-primary" type="button" onclick="submit()" value="保存"/> | ||
86 | + </td> | ||
87 | + </tr> | ||
88 | + </table> | ||
89 | + </div> | ||
90 | + </form> | ||
91 | + | ||
92 | + </div> | ||
93 | + | ||
94 | +</div> | ||
95 | + | ||
96 | + | ||
97 | + | ||
98 | +</body> | ||
99 | +<script> | ||
100 | + var count = 1; | ||
101 | + | ||
102 | + $(function () { | ||
103 | + $("#articleUid").textbox({ | ||
104 | + required: true, | ||
105 | + missingMessage: "发布用户不能为空", | ||
106 | + prompt: "请输入发布用户" | ||
107 | + }); | ||
108 | + $("#content").textbox({ | ||
109 | + required: true, | ||
110 | + missingMessage: "发布内容不能为空", | ||
111 | + prompt: "请输入发布内容" | ||
112 | + }); | ||
113 | + $("#topic").combobox({ | ||
114 | + prompt: "请选择话题" | ||
115 | + }); | ||
116 | + | ||
117 | + | ||
118 | + $("#imageUpload").imageUpload({ | ||
119 | + width: 171, | ||
120 | + height: 120, | ||
121 | + realInputName: "url", | ||
122 | + url: contextPath + '/fileupload/uploadFile', | ||
123 | + queryParams: { | ||
124 | + bucket: "activity" | ||
125 | + }, | ||
126 | + onBeforeSubmit: function () { | ||
127 | + $.messager.progress({ | ||
128 | + title: "正在执行", | ||
129 | + msg: "正在执行,请稍后...", | ||
130 | + interval: 500, | ||
131 | + text: "" | ||
132 | + }); | ||
133 | + }, | ||
134 | + filterFileName: function (data) { | ||
135 | + debugger; | ||
136 | + if (!data || data.code != 200) { | ||
137 | + $.messager.progress("close"); | ||
138 | + $.messager.alert("错误",data.message); | ||
139 | + return ""; | ||
140 | + } | ||
141 | + | ||
142 | + return data.data.url; | ||
143 | + }, | ||
144 | + onLoadSuccess: function (data) { | ||
145 | + $.messager.progress("close"); | ||
146 | + $("#imageUpload").after('<div id="imageUpload1">\n' + | ||
147 | + ' </div>'); | ||
148 | + oo(1); | ||
149 | + return false; | ||
150 | + } | ||
151 | + }); | ||
152 | + function oo(num){ | ||
153 | + if(count >8){ | ||
154 | + return | ||
155 | + } | ||
156 | + $("#imageUpload"+num).imageUpload({ | ||
157 | + width: 171, | ||
158 | + height: 120, | ||
159 | + realInputName: "url", | ||
160 | + url: contextPath + '/fileupload/uploadFile', | ||
161 | + queryParams: { | ||
162 | + bucket: "activity" | ||
163 | + }, | ||
164 | + onBeforeSubmit: function () { | ||
165 | + $.messager.progress({ | ||
166 | + title: "正在执行", | ||
167 | + msg: "正在执行,请稍后...", | ||
168 | + interval: 500, | ||
169 | + text: "" | ||
170 | + }); | ||
171 | + }, | ||
172 | + filterFileName: function (data) { | ||
173 | + debugger; | ||
174 | + if (!data || data.code != 200) { | ||
175 | + $.messager.progress("close"); | ||
176 | + $.messager.alert("错误",data.message); | ||
177 | + return ""; | ||
178 | + } | ||
179 | + return data.data.url; | ||
180 | + }, | ||
181 | + onLoadSuccess: function (data) { | ||
182 | + $.messager.progress("close"); | ||
183 | + var nnum = num+1; | ||
184 | + $("#imageUpload"+num).after('<div id="imageUpload'+nnum+'"> </div>'); | ||
185 | + count = count+1; | ||
186 | + oo(nnum); | ||
187 | + return false; | ||
188 | + } | ||
189 | + }); | ||
190 | + } | ||
191 | + | ||
192 | + | ||
193 | + | ||
194 | + }); | ||
195 | + function submit(){ | ||
196 | + $("#publishArticleForm").form("submit",{ | ||
197 | + url : "http://localhost:8088/platform/grassArticle/publishArticle", | ||
198 | + onSubmit : function(param) { | ||
199 | + if (!$("#publishArticleForm").form("validate")) { | ||
200 | + return false; | ||
201 | + } | ||
202 | + var imgs = ''; | ||
203 | + $("input[name='url']").each(function(j,item){ | ||
204 | + var url = item.val(); | ||
205 | + if(imgs == ''){ | ||
206 | + imgs = url; | ||
207 | + }else{ | ||
208 | + imgs = imgs + ","+url; | ||
209 | + } | ||
210 | + }); | ||
211 | + $("#imgs").val(imgs); | ||
212 | + return true; | ||
213 | + }, | ||
214 | + success : function(data) { | ||
215 | + if (data) { | ||
216 | + data = $.parseJSON(data); | ||
217 | + if (data.code == 200) { | ||
218 | + $.messager.alert("保存成功"); | ||
219 | + } else { | ||
220 | + $.messager.alert("保存失败", data.message, "error"); | ||
221 | + } | ||
222 | + } else { | ||
223 | + $.messager.alert("保存失败", data.message, "error"); | ||
224 | + } | ||
225 | + } | ||
226 | + }); | ||
227 | + } | ||
228 | + | ||
229 | + function submit1(){ | ||
230 | + debugger | ||
231 | + | ||
232 | + var imgs = ''; | ||
233 | + $("input[name='url']").each(function(j,item){ | ||
234 | + var url = item.value; | ||
235 | + if(imgs == ''){ | ||
236 | + imgs = url; | ||
237 | + }else{ | ||
238 | + imgs = imgs + ","+url; | ||
239 | + } | ||
240 | + }); | ||
241 | + $("#imgs").val(imgs); | ||
242 | + $("#publishArticleForm").action="http://localhost:8088/platform/grassArticle/publishArticle"; | ||
243 | + $("#publishArticleForm").submit(); | ||
244 | + } | ||
245 | +</script> | ||
246 | +</html> |
-
Please register or login to post a comment