Compare commits

...

2 Commits

Author SHA1 Message Date
a233d89be3 新闻修复BUG 2025-06-27 15:47:15 +08:00
5d5523e321 产品新增描述字段 2025-06-19 09:37:18 +08:00
14 changed files with 42 additions and 34 deletions

View File

@ -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/");

View File

@ -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);
} }

View File

@ -34,7 +34,7 @@ public class ProductController {
} }
@PostMapping("/queryList") @PostMapping("/queryList")
@ApiOperation("分页查询产品列表") @ApiOperation("查询产品列表")
public Result<List<ProductVO>> queryList(@RequestBody ProductDTO dto){ public Result<List<ProductVO>> queryList(@RequestBody ProductDTO dto){
return Result.success(productService.queryList(dto)) ; return Result.success(productService.queryList(dto)) ;
} }

View File

@ -20,7 +20,7 @@ public class SolutionController {
@PostMapping("/addContact") @PostMapping("/addContact")
@ApiOperation("提交联系信息") @ApiOperation("提交联系信息")
public Result addContact(@Valid @RequestBody SolutionContactDTO contact){ public Result addContact(@RequestBody SolutionContactDTO contact){
solutionService.addContact(contact); solutionService.addContact(contact);
return Result.success() ; return Result.success() ;
} }

View File

@ -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,6 +31,7 @@ public class ProductConvert {
productVO.setSeoKeywords(product.getSeoKeywords()); productVO.setSeoKeywords(product.getSeoKeywords());
productVO.setCreateTime(product.getCreateTime()); productVO.setCreateTime(product.getCreateTime());
productVO.setUpdateTime(product.getUpdateTime()); productVO.setUpdateTime(product.getUpdateTime());
productVO.setDesc(product.getDesc());
return productVO; return productVO;
} }

View File

@ -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;
@ -70,5 +66,7 @@ public class Product {
@ApiModelProperty(value = "修改时间") @ApiModelProperty(value = "修改时间")
private Date updateTime; private Date updateTime;
@ApiModelProperty(value = "产品描述")
private String desc;
} }

View File

@ -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);
} }

View File

@ -12,4 +12,6 @@ public interface ProductMapper extends BaseMapper<Product> {
Integer getCount(@Param("dto") ProductDTO dto); Integer getCount(@Param("dto") ProductDTO dto);
List<Product> queryList(@Param("dto") ProductDTO dto); List<Product> queryList(@Param("dto") ProductDTO dto);
Product getById(Integer id);
} }

View File

@ -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);

View File

@ -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

View File

@ -20,10 +20,7 @@ import com.shenghua.vo.ProductVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Collections; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
@ -44,7 +41,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
@Override @Override
public ProductVO getDetail(Integer id) { public ProductVO getDetail(Integer id) {
Product product = this.getById(id); Product product = productMapper.getById(id);
if (Objects.isNull(product)){ if (Objects.isNull(product)){
// 可以根据实际情况处理例如抛出异常或者返回 null // 可以根据实际情况处理例如抛出异常或者返回 null
throw new RuntimeException("产品不存在"); throw new RuntimeException("产品不存在");
@ -70,6 +67,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
List<String> imgs = groupedByType.getOrDefault(1, Collections.emptyList()).stream() List<String> imgs = groupedByType.getOrDefault(1, Collections.emptyList()).stream()
.map(ProductImg::getUrl) .map(ProductImg::getUrl)
.collect(Collectors.toList()); .collect(Collectors.toList());
imgs.add(product.getCover());
productVO.setImgs(imgs); productVO.setImgs(imgs);

View File

@ -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;
@ -83,6 +79,10 @@ public class ProductVO {
@ApiModelProperty(value = "规格参数图-详情") @ApiModelProperty(value = "规格参数图-详情")
private List<String> specsImgs; private List<String> specsImgs;
@TableField("desc")
@ApiModelProperty(value = "产品描述")
private String desc;
// @ApiModelProperty(value = "通用规格") // @ApiModelProperty(value = "通用规格")
// private ProductSpecs productSpecs; // private ProductSpecs productSpecs;
@ -90,8 +90,4 @@ public class ProductVO {
// @TableField("other_specs") // @TableField("other_specs")
// @ApiModelProperty(value = "其他额外规格") // @ApiModelProperty(value = "其他额外规格")
// private String[] otherSpecs; // private String[] otherSpecs;
} }

View File

@ -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 &gt; (SELECT id FROM news WHERE category_id = #{categoryId} AND id=#{id} ORDER BY id ASC LIMIT 1) WHERE id &gt; (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>

View File

@ -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,
@ -18,7 +17,8 @@
p.seo_description AS seoDescription, p.seo_description AS seoDescription,
p.seo_keywords AS seoKeywords, p.seo_keywords AS seoKeywords,
p.create_time AS createTime, p.create_time AS createTime,
p.update_time AS updateTime p.update_time AS updateTime,
p.desc AS `desc`
FROM product AS p FROM product AS p
</sql> </sql>
@ -42,7 +42,11 @@
</if> </if>
</if> </if>
</where> </where>
ORDER BY p.id DESC
</select> </select>
<select id="getById" resultType="com.shenghua.entitys.product.Product">
SELECT * FROM product WHERE id = #{id};
</select>
</mapper> </mapper>