Authored by 李奇

管理后台上传图片创建时间添加

@@ -198,14 +198,16 @@ const activity = { @@ -198,14 +198,16 @@ const activity = {
198 const userName = req.body.name; 198 const userName = req.body.name;
199 const content = req.body.content; 199 const content = req.body.content;
200 const imgUrl = req.body.imgUrl; 200 const imgUrl = req.body.imgUrl;
  201 + const createTime = req.body.createTime || (new Date());
201 202
202 req.ctx(ActivityModel).createArticle({ 203 req.ctx(ActivityModel).createArticle({
203 actId, 204 actId,
204 userName, 205 userName,
205 - content 206 + content,
  207 + createTime
206 }) 208 })
207 .then(artId => { 209 .then(artId => {
208 - req.ctx(ActivityModel).createArticleImg(artId, imgUrl) 210 + req.ctx(ActivityModel).createArticleImg(artId, imgUrl, createTime)
209 .then(() => { 211 .then(() => {
210 res.json({ 212 res.json({
211 code: 200, 213 code: 200,
@@ -123,13 +123,15 @@ class AdminModel extends global.yoho.BaseModel { @@ -123,13 +123,15 @@ class AdminModel extends global.yoho.BaseModel {
123 * @param id 文章ID 123 * @param id 文章ID
124 * @returns {*} 124 * @returns {*}
125 */ 125 */
126 - createArticle({actId, userName, content}) { 126 + createArticle({actId, userName, content, createTime}) {
127 return mysqlCli.insert( 127 return mysqlCli.insert(
128 - `insert into ${TB_ACT_ARTICLE} (act_id, user_name, content) values (:actId, :userName, :content);`, 128 + `insert into ${TB_ACT_ARTICLE}
  129 + (act_id, user_name, content, create_time) values (:actId, :userName, :content, :createTime);`,
129 { 130 {
130 actId, 131 actId,
131 userName, 132 userName,
132 - content 133 + content,
  134 + createTime
133 } 135 }
134 ); 136 );
135 } 137 }
@@ -139,12 +141,14 @@ class AdminModel extends global.yoho.BaseModel { @@ -139,12 +141,14 @@ class AdminModel extends global.yoho.BaseModel {
139 * @param id 文章ID 141 * @param id 文章ID
140 * @returns {*} 142 * @returns {*}
141 */ 143 */
142 - createArticleImg(artId, imgUrl) { 144 + createArticleImg(artId, imgUrl, createTime) {
143 return mysqlCli.insert( 145 return mysqlCli.insert(
144 - `insert into ${TB_ACT_ARTICLE_IMG} (article_id, img_url) values (:artId, :imgUrl);`, 146 + `insert into ${TB_ACT_ARTICLE_IMG}
  147 + (article_id, img_url, create_time) values (:artId, :imgUrl, :createTime);`,
145 { 148 {
146 artId, 149 artId,
147 - imgUrl 150 + imgUrl,
  151 + createTime
148 } 152 }
149 ); 153 );
150 } 154 }
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 <div class="x_content"> 11 <div class="x_content">
12 <form id="createArticleForm" class="form-horizontal form-label-left"> 12 <form id="createArticleForm" class="form-horizontal form-label-left">
13 <div class="form-group"> 13 <div class="form-group">
14 - <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">姓名<span 14 + <label class="control-label col-md-3 col-sm-3 col-xs-12">姓名<span
15 class="required">*</span> 15 class="required">*</span>
16 </label> 16 </label>
17 <div class="col-md-6 col-sm-6 col-xs-12"> 17 <div class="col-md-6 col-sm-6 col-xs-12">
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 </div> 20 </div>
21 </div> 21 </div>
22 <div class="form-group"> 22 <div class="form-group">
23 - <label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">内容<span 23 + <label class="control-label col-md-3 col-sm-3 col-xs-12">内容<span
24 class="required">*</span> 24 class="required">*</span>
25 </label> 25 </label>
26 <div class="col-md-6 col-sm-6 col-xs-12"> 26 <div class="col-md-6 col-sm-6 col-xs-12">
@@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
29 </div> 29 </div>
30 </div> 30 </div>
31 <div class="form-group"> 31 <div class="form-group">
32 - <label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">图片<span 32 + <label class="control-label col-md-3 col-sm-3 col-xs-12">图片<span
33 class="required">*</span> 33 class="required">*</span>
34 </label> 34 </label>
35 <div class="col-md-6 col-sm-6 col-xs-12"> 35 <div class="col-md-6 col-sm-6 col-xs-12">
@@ -45,6 +45,14 @@ @@ -45,6 +45,14 @@
45 45
46 </div> 46 </div>
47 </div> 47 </div>
  48 + <div class="form-group">
  49 + <label class="control-label col-md-3 col-sm-3 col-xs-12">创建时间
  50 + </label>
  51 + <div class="col-md-6 col-sm-6 col-xs-12">
  52 + <input type="text" name="createTime" required="required"
  53 + class="form-control col-md-7 col-xs-12">
  54 + </div>
  55 + </div>
48 <div class="ln_solid"></div> 56 <div class="ln_solid"></div>
49 <div class="form-group"> 57 <div class="form-group">
50 <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3"> 58 <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">