feat(cms): 添加根据code查询文章功能
- 在CmsArticleController中新增getByCode接口,支持通过文章编号查询文章- 在CmsArticle实体类中添加code字段,用于存储文章编号 - 在CmsArticleMapper.xml中添加code字段的查询条件支持 - 在CmsArticleParam参数类中添加code字段及查询注解 - 在CmsArticleService接口及实现类中添加getByIdCode方法 - 优化CmsAdServiceImpl中的默认排序规则,优先按sort_number排序
This commit is contained in:
@@ -88,6 +88,13 @@ public class CmsArticleController extends BaseController {
|
||||
return fail("文章ID不存在",null);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据code查询文章")
|
||||
@GetMapping("/getByCode/{code}")
|
||||
public ApiResult<CmsArticle> getByCode(@PathVariable("code") String code) {
|
||||
final CmsArticle article = cmsArticleService.getByIdCode(code);
|
||||
return success(article);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('cms:cmsArticle:save')")
|
||||
@Operation(summary = "添加文章")
|
||||
@PostMapping()
|
||||
|
||||
@@ -40,6 +40,9 @@ public class CmsArticle implements Serializable {
|
||||
@Schema(description = "文章模型")
|
||||
private String model;
|
||||
|
||||
@Schema(description = "文章编号")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "内容模板页面")
|
||||
private String detail;
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
<if test="param.model != null">
|
||||
AND a.model = #{param.model}
|
||||
</if>
|
||||
<if test="param.code != null">
|
||||
AND a.code = #{param.code}
|
||||
</if>
|
||||
<if test="param.detail != null">
|
||||
AND a.detail = #{param.detail}
|
||||
</if>
|
||||
|
||||
@@ -45,6 +45,10 @@ public class CmsArticleParam extends BaseParam {
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private String model;
|
||||
|
||||
@Schema(description = "文章编号")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private String code;
|
||||
|
||||
@Schema(description = "详情页标识")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private String detail;
|
||||
|
||||
@@ -45,4 +45,6 @@ public interface CmsArticleService extends IService<CmsArticle> {
|
||||
boolean saveRel(@Valid CmsArticle article);
|
||||
|
||||
boolean updateByIdRel(CmsArticle article);
|
||||
|
||||
CmsArticle getByIdCode(String code);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class CmsAdServiceImpl extends ServiceImpl<CmsAdMapper, CmsAd> implements
|
||||
@Override
|
||||
public PageResult<CmsAd> pageRel(CmsAdParam param) {
|
||||
PageParam<CmsAd, CmsAdParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time asc");
|
||||
page.setDefaultOrder("sort_number asc, create_time asc");
|
||||
List<CmsAd> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class CmsAdServiceImpl extends ServiceImpl<CmsAdMapper, CmsAd> implements
|
||||
List<CmsAd> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<CmsAd, CmsAdParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("create_time asc");
|
||||
page.setDefaultOrder("sort_number asc, create_time asc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,13 +5,11 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.cms.entity.CmsArticleContent;
|
||||
import com.gxwebsoft.cms.entity.CmsModel;
|
||||
import com.gxwebsoft.cms.entity.CmsNavigation;
|
||||
import com.gxwebsoft.cms.entity.*;
|
||||
import com.gxwebsoft.cms.mapper.CmsArticleMapper;
|
||||
import com.gxwebsoft.cms.param.CmsAdParam;
|
||||
import com.gxwebsoft.cms.service.CmsArticleContentService;
|
||||
import com.gxwebsoft.cms.service.CmsArticleService;
|
||||
import com.gxwebsoft.cms.entity.CmsArticle;
|
||||
import com.gxwebsoft.cms.param.CmsArticleParam;
|
||||
import com.gxwebsoft.cms.service.CmsModelService;
|
||||
import com.gxwebsoft.cms.service.CmsNavigationService;
|
||||
@@ -243,4 +241,10 @@ public class CmsArticleServiceImpl extends ServiceImpl<CmsArticleMapper, CmsArti
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CmsArticle getByIdCode(String code) {
|
||||
CmsArticleParam param = new CmsArticleParam();
|
||||
param.setCode(code);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user