Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
9d1459b1bd
|
@ -75,5 +75,5 @@ public interface ArticleMapper
|
|||
|
||||
public List<ArticleVO> selectChildrenById(Long id);
|
||||
|
||||
ArticleVO selectArticleByCode(ArticleCategoryQuery articleCategoryQuery);
|
||||
ArticleVO selectArticleByCode(ArticleQuery articleQuery);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="content" column="content" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="code" column="code" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectArticleVo">
|
||||
|
@ -34,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="query.brief != null "> and bart.brief = #{query.brief}</if>
|
||||
<if test="query.title != null and query.title != ''"> and bart.title like concat ('',#{query.title},'') </if>
|
||||
<if test="query.content != null and query.content != ''"> and bart.content = #{query.content}</if>
|
||||
<if test="query.code != null and query.code != ''"> and bart.code = #{query.code}</if>
|
||||
${query.params.dataScope}
|
||||
</sql>
|
||||
|
||||
|
@ -55,8 +57,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</select>
|
||||
|
||||
<select id="selectArticleByCode" resultType="com.ruoyi.bst.article.domain.ArticleVO">
|
||||
<include refid="selectArticleVo"/>
|
||||
where code = #{code}
|
||||
<include refid="selectArticleVo"></include>
|
||||
where bart.code = #{code} and bart.id != #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertArticle" parameterType="Article" useGeneratedKeys="true" keyProperty="id">
|
||||
|
@ -68,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="brief != null">brief,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="code != null">code,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="categoryId != null">#{categoryId},</if>
|
||||
|
@ -76,6 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="brief != null">#{brief},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="code != null">#{code},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
@ -182,6 +186,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="data.content != null">content = #{data.content},</if>
|
||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||
<if test="data.updateTime != null">update_time = #{data.updateTime},</if>
|
||||
<if test="data.code != null">code = #{data.code},</if>
|
||||
</sql>
|
||||
|
||||
<delete id="deleteArticleById" parameterType="Long">
|
||||
|
|
|
@ -63,7 +63,7 @@ public interface ArticleService
|
|||
public int deleteArticleById(Long id);
|
||||
|
||||
|
||||
ArticleVO selectArticleByCode(ArticleCategoryQuery articleCategoryQuery);
|
||||
ArticleVO selectArticleByCode(ArticleQuery articleQuery);
|
||||
|
||||
List<ArticleVO> selectArticleByCategoryId(Long categoryId);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.ruoyi.bst.articleCategory.domain.ArticleCategoryQuery;
|
|||
import com.ruoyi.bst.articleCategory.domain.ArticleCategoryVO;
|
||||
import com.ruoyi.bst.articleCategory.domain.enums.ArticleCategoryStatus;
|
||||
import com.ruoyi.bst.articleCategory.service.ArticleCategoryService;
|
||||
import com.ruoyi.bst.device.domain.DeviceVO;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.common.utils.ServiceUtil;
|
||||
|
@ -18,6 +19,7 @@ import com.ruoyi.bst.article.domain.Article;
|
|||
import com.ruoyi.bst.article.domain.ArticleVO;
|
||||
import com.ruoyi.bst.article.domain.ArticleQuery;
|
||||
import com.ruoyi.bst.article.service.ArticleService;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import javax.print.ServiceUI;
|
||||
|
||||
|
@ -35,6 +37,9 @@ public class ArticleServiceImpl implements ArticleService
|
|||
|
||||
@Autowired
|
||||
private ArticleCategoryService articleCategoryService;
|
||||
|
||||
@Autowired
|
||||
private TransactionTemplate transactionTemplate;
|
||||
|
||||
/**
|
||||
* 查询文章
|
||||
|
@ -74,8 +79,21 @@ public class ArticleServiceImpl implements ArticleService
|
|||
if (articleCategoryVO.getCategoryStatus().equals(ArticleCategoryStatus.DISABLED.getCode())){
|
||||
ServiceUtil.assertion(true,"该分类已被禁用");
|
||||
}
|
||||
article.setCreateTime(DateUtils.getNowDate());
|
||||
return articleMapper.insertArticle(article);
|
||||
|
||||
Integer result = transactionTemplate.execute(status -> {
|
||||
|
||||
int insert = articleMapper.insertArticle(article);
|
||||
ServiceUtil.assertion(insert != 1,"新增文章失败");
|
||||
ArticleVO vo = this.selectArticleById(article.getId());
|
||||
|
||||
ArticleQuery articleQuery = new ArticleQuery();
|
||||
articleQuery.setId(vo.getId());
|
||||
articleQuery.setCode(vo.getCode());
|
||||
ArticleVO articleVO = articleMapper.selectArticleByCode(articleQuery);
|
||||
ServiceUtil.assertion(articleVO != null,"该指南已存在");
|
||||
return insert;
|
||||
});
|
||||
return result == null ? 0:result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,6 +111,11 @@ public class ArticleServiceImpl implements ArticleService
|
|||
ServiceUtil.assertion(true,"该分类已被禁用");
|
||||
}
|
||||
article.setUpdateTime(DateUtils.getNowDate());
|
||||
ArticleQuery articleQuery = new ArticleQuery();
|
||||
articleQuery.setId(article.getId());
|
||||
articleQuery.setCode(article.getCode());
|
||||
ArticleVO articleVO = articleMapper.selectArticleByCode(articleQuery);
|
||||
ServiceUtil.assertion(articleVO != null,"该指南已存在");
|
||||
return articleMapper.updateArticle(article);
|
||||
}
|
||||
|
||||
|
@ -122,8 +145,8 @@ public class ArticleServiceImpl implements ArticleService
|
|||
|
||||
|
||||
@Override
|
||||
public ArticleVO selectArticleByCode(ArticleCategoryQuery articleCategoryQuery) {
|
||||
return articleMapper.selectArticleByCode(articleCategoryQuery);
|
||||
public ArticleVO selectArticleByCode(ArticleQuery articleQuery) {
|
||||
return articleMapper.selectArticleByCode(articleQuery);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,6 +6,5 @@ import lombok.Data;
|
|||
@Data
|
||||
public class ArticleCategoryQuery extends ArticleCategoryVO {
|
||||
|
||||
@ApiModelProperty("指南编号")
|
||||
private String code;
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||
|
||||
@RestController
|
||||
@RequestMapping("/app/articleCategory")
|
||||
public class AppAtricleCategoryController extends BaseController {
|
||||
public class AppArticleCategoryController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ArticleCategoryService articleCategoryService;
|
||||
|
@ -33,13 +33,6 @@ public class AppAtricleCategoryController extends BaseController {
|
|||
@Autowired
|
||||
private ArticleService articleService;
|
||||
|
||||
@ApiOperation("租/用车指南")
|
||||
@GetMapping("/{code}")
|
||||
@Anonymous
|
||||
public AjaxResult getGuide(ArticleCategoryQuery articleCategoryQuery) {
|
||||
startPage();
|
||||
return AjaxResult.success(articleService.selectArticleByCode(articleCategoryQuery));
|
||||
}
|
||||
|
||||
@ApiOperation("查询所有文章分类信息")
|
||||
@GetMapping("/list")
|
|
@ -0,0 +1,32 @@
|
|||
package com.ruoyi.web.app;
|
||||
|
||||
import com.ruoyi.bst.article.domain.ArticleQuery;
|
||||
import com.ruoyi.bst.article.service.ArticleService;
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/app/article")
|
||||
public class AppArticleController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ArticleService articleService;
|
||||
|
||||
@ApiOperation("租/用车指南")
|
||||
@GetMapping("/guide")
|
||||
@Anonymous
|
||||
public AjaxResult getGuide(ArticleQuery articleQuery) {
|
||||
startPage();
|
||||
return AjaxResult.success(articleService.selectArticleList(articleQuery));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user