master
ck 5 years ago
parent 614281bc5d
commit 49c2d115ab

@ -47,4 +47,9 @@ public class Article extends BaseEntity{
*
*/
private String videoUrl;
/**
*
*/
private Integer isRecommend;
}

@ -2,13 +2,11 @@ package com.jingcheng.cms.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.generator.config.IFileCreate;
import com.jingcheng.cms.constants.Constants;
import com.jingcheng.cms.mapper.ArticleMapper;
import com.jingcheng.cms.mapper.CategoryMapper;
import com.jingcheng.cms.model.Article;
import com.jingcheng.cms.model.Category;
import com.jingcheng.cms.model.Users;
import com.jingcheng.cms.service.ArticleSerive;
import com.jingcheng.cms.util.AjaxResult;
import com.jingcheng.cms.util.PageUtils;
@ -44,6 +42,7 @@ public class ArticleSerivceImpl implements ArticleSerive {
Integer state = jsonObject.getInteger("state");
String describe = jsonObject.getString("describe");
String videoUrl = jsonObject.getString("videoUrl");
Integer isRecommend = jsonObject.getInteger("isRecommend") == null ? 0 : jsonObject.getInteger("isRecommend");
if (null == state){
ajaxResult.setRetcode(AjaxResult.FAILED);
@ -85,6 +84,7 @@ public class ArticleSerivceImpl implements ArticleSerive {
article.setContent(content);
article.setDescribe(describe);
article.setVideoUrl(videoUrl);
article.setIsRecommend(isRecommend);
articleMapper.addArticle(article);
ajaxResult.setRetmsg("成功新增文章");
}else {
@ -108,6 +108,7 @@ public class ArticleSerivceImpl implements ArticleSerive {
article.setContent(content);
article.setDescribe(describe);
article.setVideoUrl(videoUrl);
article.setIsRecommend(isRecommend);
articleMapper.updateByExampleSelective(article,example);
ajaxResult.setRetmsg("成功修改文章");
}

@ -3,15 +3,15 @@
<mapper namespace="com.jingcheng.cms.mapper.ArticleMapper">
<insert id="addArticle" parameterType="com.jingcheng.cms.model.Article">
INSERT INTO article(`title`,`first_category`,`second_category`,`keyword`,`file_type`,`content`,`state`,`describe`,`video_url`)
values (#{title},#{firstCategory},#{secondCategory},#{keyword},#{fileType},#{content},#{state},#{describe},#{videoUrl})
INSERT INTO article(`title`,`first_category`,`second_category`,`keyword`,`file_type`,`content`,`state`,`describe`,`video_url`,`is_recommend`)
values (#{title},#{firstCategory},#{secondCategory},#{keyword},#{fileType},#{content},#{state},#{describe},#{videoUrl},#{isRecommend})
</insert>
<select id="getArticleListByCondition" resultType="com.jingcheng.cms.vo.ArticleVo">
select ar.`id`,ar.`title`,c1.`name` as `first_category_name`,c2.`name` as `second_category_name`,
ar.`keyword`,ar.`file_type`,ar.`content`,ar.`create_date_time`,ar.`update_date_time`,ar.`state`,
c1.level as `first_level`,c2.level as `second_level`,c1.`sort_num` as `first_sort_num`,c2.`sort_num` as `second_sort_num`,
ar.`keyword`,ar.`file_type`,ar.`describe`,ar.`video_url`
ar.`keyword`,ar.`file_type`,ar.`describe`,ar.`video_url`,ar.`is_recommend`
FROM article ar
left join category c1
on
@ -36,6 +36,7 @@
<if test="state != null ">
and ar.state = #{state}
</if>
ORDER BY is_recommend Desc
</select>
<select id="getFirstCategory" resultType="com.jingcheng.cms.model.Category">
@ -67,7 +68,7 @@
select ar.`id`,ar.`title`,c1.`name` as `first_category_name`,c2.`name` as `second_category_name`,
ar.`keyword`,ar.`file_type`,ar.`content`,ar.`create_date_time`,ar.`update_date_time`,ar.`state`,
c1.level as `first_level`,c2.level as `second_level`,c1.`sort_num` as `first_sort_num`,c2.`sort_num` as `second_sort_num`,
ar.`keyword`,ar.`file_type`,ar.`describe`,ar.`video_url`
ar.`keyword`,ar.`file_type`,ar.`describe`,ar.`video_url`,ar.`is_recommend`
FROM article ar
left join category c1
on
@ -90,5 +91,6 @@
and ar.second_category = #{secondCategory}
</if>
and ar.state = 1
ORDER BY is_recommend Desc
</select>
</mapper>
Loading…
Cancel
Save