新闻修复BUG
This commit is contained in:
parent
5d5523e321
commit
a233d89be3
@ -23,6 +23,10 @@ public class WebConfiguration implements WebMvcConfigurer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
// 新增对 本地映射,访问图片 的支持
|
||||||
|
registry.addResourceHandler("/images/**")
|
||||||
|
.addResourceLocations("file:C:/upload/images/");
|
||||||
|
|
||||||
registry.addResourceHandler("/doc.html**")
|
registry.addResourceHandler("/doc.html**")
|
||||||
.addResourceLocations("classpath:/META-INF/resources/");
|
.addResourceLocations("classpath:/META-INF/resources/");
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.shenghua.controller;
|
package com.shenghua.controller;
|
||||||
|
|
||||||
|
import com.shenghua.dto.NewsDto;
|
||||||
import com.shenghua.dto.PageDto;
|
import com.shenghua.dto.PageDto;
|
||||||
import com.shenghua.entitys.Page;
|
import com.shenghua.entitys.Page;
|
||||||
import com.shenghua.entitys.Result;
|
import com.shenghua.entitys.Result;
|
||||||
@ -43,8 +44,8 @@ public class NewsController {
|
|||||||
|
|
||||||
@PostMapping("/query")
|
@PostMapping("/query")
|
||||||
@ApiOperation(value = "分页查询新闻列表")
|
@ApiOperation(value = "分页查询新闻列表")
|
||||||
public Result<Page<List<NewsVo>>> query(@RequestBody PageDto page){
|
public Result<Page<List<NewsVo>>> query(@RequestBody NewsDto dto){
|
||||||
Page<List<NewsVo>> listPage = newsService.queryList(page);
|
Page<List<NewsVo>> listPage = newsService.queryList(dto);
|
||||||
return Result.success(listPage);
|
return Result.success(listPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ public class ProductConvert {
|
|||||||
productVO.setTypeArr(typeArr);
|
productVO.setTypeArr(typeArr);
|
||||||
}
|
}
|
||||||
productVO.setCover(product.getCover());
|
productVO.setCover(product.getCover());
|
||||||
productVO.setImgsRelationId(product.getImgsRelationId());
|
|
||||||
productVO.setContent(product.getContent());
|
productVO.setContent(product.getContent());
|
||||||
productVO.setPrice(product.getPrice());
|
productVO.setPrice(product.getPrice());
|
||||||
productVO.setSeoTitle(product.getSeoTitle());
|
productVO.setSeoTitle(product.getSeoTitle());
|
||||||
|
@ -32,10 +32,6 @@ public class Product {
|
|||||||
@ApiModelProperty(value = "封面图路径")
|
@ApiModelProperty(value = "封面图路径")
|
||||||
private String cover;
|
private String cover;
|
||||||
|
|
||||||
@TableField("imgs_relation_id")
|
|
||||||
@ApiModelProperty(value = "详情图片关联ID")
|
|
||||||
private Integer imgsRelationId;
|
|
||||||
|
|
||||||
@TableField("content")
|
@TableField("content")
|
||||||
@ApiModelProperty(value = "产品介绍")
|
@ApiModelProperty(value = "产品介绍")
|
||||||
private String content;
|
private String content;
|
||||||
|
@ -23,5 +23,6 @@ public interface NewsMapper extends BaseMapper<News> {
|
|||||||
|
|
||||||
List<NewsVo> getHomeNewsList();
|
List<NewsVo> getHomeNewsList();
|
||||||
|
|
||||||
List<NewsVo> queryList(@Param("startNum")Integer startNum, @Param("pageSize")Integer pageSize);
|
List<NewsVo> queryList(@Param("startNum")Integer startNum, @Param("pageSize")Integer pageSize,
|
||||||
|
@Param("categoryId")Integer categoryId);
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public interface NewsService extends IService<News> {
|
|||||||
//
|
//
|
||||||
// NewsDetailsVo getNewsById(Integer id);
|
// NewsDetailsVo getNewsById(Integer id);
|
||||||
|
|
||||||
Page<List<NewsVo>> queryList(PageDto page);
|
Page<List<NewsVo>> queryList(NewsDto dto);
|
||||||
|
|
||||||
int saveNews(News news);
|
int saveNews(News news);
|
||||||
|
|
||||||
|
@ -84,20 +84,22 @@ public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements Ne
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<List<NewsVo>> queryList(PageDto page) {
|
public Page<List<NewsVo>> queryList(NewsDto dto) {
|
||||||
|
Integer pageSize = dto.getPageSize();
|
||||||
|
Integer pageNum = dto.getPageNum();
|
||||||
// 查询总记录数
|
// 查询总记录数
|
||||||
Integer count = super.baseMapper.getAllNewsCount(null); // 假设 Mapper 中有 getNewsCount() 方法
|
Integer count = super.baseMapper.getAllNewsCount(dto.getCategoryId()); // 假设 Mapper 中有 getNewsCount() 方法
|
||||||
if (count == 0){
|
if (count == 0){
|
||||||
return new Page<>(page.getPageNum(), 0, page.getPageSize(), null);
|
return new Page<>(pageNum, 0, pageSize, null);
|
||||||
}
|
}
|
||||||
// 计算起始位置
|
// 计算起始位置
|
||||||
Integer startNum = (page.getPageNum() - 1) * page.getPageSize();
|
Integer startNum = (pageNum - 1) * pageSize;
|
||||||
|
|
||||||
// 查询当前页数据
|
// 查询当前页数据
|
||||||
List<NewsVo> list = super.baseMapper.queryList(page.getPageNum(), page.getPageSize());
|
List<NewsVo> list = super.baseMapper.queryList(startNum, pageSize, dto.getCategoryId());
|
||||||
|
|
||||||
// 返回分页对象
|
// 返回分页对象
|
||||||
return new Page<>(page.getPageNum(), count, page.getPageSize(), list);
|
return new Page<>(pageNum, count, pageSize, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -45,10 +45,6 @@ public class ProductVO {
|
|||||||
@ApiModelProperty(value = "商品详情图片")
|
@ApiModelProperty(value = "商品详情图片")
|
||||||
private List<String> imgs;
|
private List<String> imgs;
|
||||||
|
|
||||||
@TableField("imgs_relation_id")
|
|
||||||
@ApiModelProperty(value = "详情图片关联ID")
|
|
||||||
private Integer imgsRelationId;
|
|
||||||
|
|
||||||
@TableField("content")
|
@TableField("content")
|
||||||
@ApiModelProperty(value = "产品介绍")
|
@ApiModelProperty(value = "产品介绍")
|
||||||
private String content;
|
private String content;
|
||||||
@ -94,8 +90,4 @@ public class ProductVO {
|
|||||||
// @TableField("other_specs")
|
// @TableField("other_specs")
|
||||||
// @ApiModelProperty(value = "其他额外规格")
|
// @ApiModelProperty(value = "其他额外规格")
|
||||||
// private String[] otherSpecs;
|
// private String[] otherSpecs;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getQueryDownChapterId" resultType="com.shenghua.vo.NewsVo">
|
<select id="getQueryDownChapterId" resultType="com.shenghua.vo.NewsVo">
|
||||||
|
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM news
|
FROM news
|
||||||
WHERE id > (SELECT id FROM news WHERE category_id = #{categoryId} AND id=#{id} ORDER BY id ASC LIMIT 1)
|
WHERE id > (SELECT id FROM news WHERE category_id = #{categoryId} AND id=#{id} ORDER BY id ASC LIMIT 1)
|
||||||
@ -50,6 +49,9 @@
|
|||||||
|
|
||||||
<select id="queryList" resultType="com.shenghua.vo.NewsVo">
|
<select id="queryList" resultType="com.shenghua.vo.NewsVo">
|
||||||
SELECT * FROM news
|
SELECT * FROM news
|
||||||
|
<if test="categoryId!=null and categoryId!=''">
|
||||||
|
where category_id= #{categoryId}
|
||||||
|
</if>
|
||||||
order by create_time desc
|
order by create_time desc
|
||||||
limit #{startNum},#{pageSize}
|
limit #{startNum},#{pageSize}
|
||||||
</select>
|
</select>
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
p.category_id AS categoryId,
|
p.category_id AS categoryId,
|
||||||
p.type_arr AS typeArr,
|
p.type_arr AS typeArr,
|
||||||
p.cover,
|
p.cover,
|
||||||
p.imgs_relation_id AS imgsRelationId,
|
|
||||||
p.content,
|
p.content,
|
||||||
p.price,
|
p.price,
|
||||||
p.specs_id AS specsId,
|
p.specs_id AS specsId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user