Authored by 李奇

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

... ... @@ -198,14 +198,16 @@ const activity = {
const userName = req.body.name;
const content = req.body.content;
const imgUrl = req.body.imgUrl;
const createTime = req.body.createTime || (new Date());
req.ctx(ActivityModel).createArticle({
actId,
userName,
content
content,
createTime
})
.then(artId => {
req.ctx(ActivityModel).createArticleImg(artId, imgUrl)
req.ctx(ActivityModel).createArticleImg(artId, imgUrl, createTime)
.then(() => {
res.json({
code: 200,
... ...
... ... @@ -123,13 +123,15 @@ class AdminModel extends global.yoho.BaseModel {
* @param id 文章ID
* @returns {*}
*/
createArticle({actId, userName, content}) {
createArticle({actId, userName, content, createTime}) {
return mysqlCli.insert(
`insert into ${TB_ACT_ARTICLE} (act_id, user_name, content) values (:actId, :userName, :content);`,
`insert into ${TB_ACT_ARTICLE}
(act_id, user_name, content, create_time) values (:actId, :userName, :content, :createTime);`,
{
actId,
userName,
content
content,
createTime
}
);
}
... ... @@ -139,12 +141,14 @@ class AdminModel extends global.yoho.BaseModel {
* @param id 文章ID
* @returns {*}
*/
createArticleImg(artId, imgUrl) {
createArticleImg(artId, imgUrl, createTime) {
return mysqlCli.insert(
`insert into ${TB_ACT_ARTICLE_IMG} (article_id, img_url) values (:artId, :imgUrl);`,
`insert into ${TB_ACT_ARTICLE_IMG}
(article_id, img_url, create_time) values (:artId, :imgUrl, :createTime);`,
{
artId,
imgUrl
imgUrl,
createTime
}
);
}
... ...
... ... @@ -11,7 +11,7 @@
<div class="x_content">
<form id="createArticleForm" class="form-horizontal form-label-left">
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">姓名<span
<label class="control-label col-md-3 col-sm-3 col-xs-12">姓名<span
class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
... ... @@ -20,7 +20,7 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">内容<span
<label class="control-label col-md-3 col-sm-3 col-xs-12">内容<span
class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
... ... @@ -29,7 +29,7 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="last-name">图片<span
<label class="control-label col-md-3 col-sm-3 col-xs-12">图片<span
class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
... ... @@ -45,6 +45,14 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">创建时间
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" name="createTime" required="required"
class="form-control col-md-7 col-xs-12">
</div>
</div>
<div class="ln_solid"></div>
<div class="form-group">
<div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
... ...