Compare commits
No commits in common. "master-v" and "master" have entirely different histories.
@ -23,10 +23,6 @@ public class WebConfiguration implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
// 新增对 本地映射,访问图片 的支持
|
||||
registry.addResourceHandler("/images/**")
|
||||
.addResourceLocations("file:C:/upload/images/");
|
||||
|
||||
registry.addResourceHandler("/doc.html**")
|
||||
.addResourceLocations("classpath:/META-INF/resources/");
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.shenghua.controller;
|
||||
|
||||
import com.shenghua.dto.NewsDto;
|
||||
import com.shenghua.dto.PageDto;
|
||||
import com.shenghua.entitys.Page;
|
||||
import com.shenghua.entitys.Result;
|
||||
@ -44,8 +43,8 @@ public class NewsController {
|
||||
|
||||
@PostMapping("/query")
|
||||
@ApiOperation(value = "分页查询新闻列表")
|
||||
public Result<Page<List<NewsVo>>> query(@RequestBody NewsDto dto){
|
||||
Page<List<NewsVo>> listPage = newsService.queryList(dto);
|
||||
public Result<Page<List<NewsVo>>> query(@RequestBody PageDto page){
|
||||
Page<List<NewsVo>> listPage = newsService.queryList(page);
|
||||
return Result.success(listPage);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class ProductController {
|
||||
}
|
||||
|
||||
@PostMapping("/queryList")
|
||||
@ApiOperation("查询产品列表")
|
||||
@ApiOperation("分页查询产品列表")
|
||||
public Result<List<ProductVO>> queryList(@RequestBody ProductDTO dto){
|
||||
return Result.success(productService.queryList(dto)) ;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class SolutionController {
|
||||
|
||||
@PostMapping("/addContact")
|
||||
@ApiOperation("提交联系信息")
|
||||
public Result addContact(@RequestBody SolutionContactDTO contact){
|
||||
public Result addContact(@Valid @RequestBody SolutionContactDTO contact){
|
||||
solutionService.addContact(contact);
|
||||
return Result.success() ;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ public class ProductConvert {
|
||||
productVO.setTypeArr(typeArr);
|
||||
}
|
||||
productVO.setCover(product.getCover());
|
||||
productVO.setImgsRelationId(product.getImgsRelationId());
|
||||
productVO.setContent(product.getContent());
|
||||
productVO.setPrice(product.getPrice());
|
||||
productVO.setSeoTitle(product.getSeoTitle());
|
||||
@ -31,7 +32,6 @@ public class ProductConvert {
|
||||
productVO.setSeoKeywords(product.getSeoKeywords());
|
||||
productVO.setCreateTime(product.getCreateTime());
|
||||
productVO.setUpdateTime(product.getUpdateTime());
|
||||
productVO.setDesc(product.getDesc());
|
||||
return productVO;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,10 @@ public class Product {
|
||||
@ApiModelProperty(value = "封面图路径")
|
||||
private String cover;
|
||||
|
||||
@TableField("imgs_relation_id")
|
||||
@ApiModelProperty(value = "详情图片关联ID")
|
||||
private Integer imgsRelationId;
|
||||
|
||||
@TableField("content")
|
||||
@ApiModelProperty(value = "产品介绍")
|
||||
private String content;
|
||||
@ -66,7 +70,5 @@ public class Product {
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private Date updateTime;
|
||||
|
||||
@ApiModelProperty(value = "产品描述")
|
||||
private String desc;
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,5 @@ public interface NewsMapper extends BaseMapper<News> {
|
||||
|
||||
List<NewsVo> getHomeNewsList();
|
||||
|
||||
List<NewsVo> queryList(@Param("startNum")Integer startNum, @Param("pageSize")Integer pageSize,
|
||||
@Param("categoryId")Integer categoryId);
|
||||
List<NewsVo> queryList(@Param("startNum")Integer startNum, @Param("pageSize")Integer pageSize);
|
||||
}
|
||||
|
@ -12,6 +12,4 @@ public interface ProductMapper extends BaseMapper<Product> {
|
||||
Integer getCount(@Param("dto") ProductDTO dto);
|
||||
|
||||
List<Product> queryList(@Param("dto") ProductDTO dto);
|
||||
|
||||
Product getById(Integer id);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public interface NewsService extends IService<News> {
|
||||
//
|
||||
// NewsDetailsVo getNewsById(Integer id);
|
||||
|
||||
Page<List<NewsVo>> queryList(NewsDto dto);
|
||||
Page<List<NewsVo>> queryList(PageDto page);
|
||||
|
||||
int saveNews(News news);
|
||||
|
||||
|
@ -84,22 +84,20 @@ public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements Ne
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Page<List<NewsVo>> queryList(NewsDto dto) {
|
||||
Integer pageSize = dto.getPageSize();
|
||||
Integer pageNum = dto.getPageNum();
|
||||
public Page<List<NewsVo>> queryList(PageDto page) {
|
||||
// 查询总记录数
|
||||
Integer count = super.baseMapper.getAllNewsCount(dto.getCategoryId()); // 假设 Mapper 中有 getNewsCount() 方法
|
||||
Integer count = super.baseMapper.getAllNewsCount(null); // 假设 Mapper 中有 getNewsCount() 方法
|
||||
if (count == 0){
|
||||
return new Page<>(pageNum, 0, pageSize, null);
|
||||
return new Page<>(page.getPageNum(), 0, page.getPageSize(), null);
|
||||
}
|
||||
// 计算起始位置
|
||||
Integer startNum = (pageNum - 1) * pageSize;
|
||||
Integer startNum = (page.getPageNum() - 1) * page.getPageSize();
|
||||
|
||||
// 查询当前页数据
|
||||
List<NewsVo> list = super.baseMapper.queryList(startNum, pageSize, dto.getCategoryId());
|
||||
List<NewsVo> list = super.baseMapper.queryList(page.getPageNum(), page.getPageSize());
|
||||
|
||||
// 返回分页对象
|
||||
return new Page<>(pageNum, count, pageSize, list);
|
||||
return new Page<>(page.getPageNum(), count, page.getPageSize(), list);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,7 +20,10 @@ import com.shenghua.vo.ProductVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@ -41,7 +44,7 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
|
||||
@Override
|
||||
public ProductVO getDetail(Integer id) {
|
||||
Product product = productMapper.getById(id);
|
||||
Product product = this.getById(id);
|
||||
if (Objects.isNull(product)){
|
||||
// 可以根据实际情况处理,例如抛出异常或者返回 null
|
||||
throw new RuntimeException("产品不存在");
|
||||
@ -67,7 +70,6 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
List<String> imgs = groupedByType.getOrDefault(1, Collections.emptyList()).stream()
|
||||
.map(ProductImg::getUrl)
|
||||
.collect(Collectors.toList());
|
||||
imgs.add(product.getCover());
|
||||
productVO.setImgs(imgs);
|
||||
|
||||
|
||||
|
@ -45,6 +45,10 @@ public class ProductVO {
|
||||
@ApiModelProperty(value = "商品详情图片")
|
||||
private List<String> imgs;
|
||||
|
||||
@TableField("imgs_relation_id")
|
||||
@ApiModelProperty(value = "详情图片关联ID")
|
||||
private Integer imgsRelationId;
|
||||
|
||||
@TableField("content")
|
||||
@ApiModelProperty(value = "产品介绍")
|
||||
private String content;
|
||||
@ -79,10 +83,6 @@ public class ProductVO {
|
||||
@ApiModelProperty(value = "规格参数图-详情")
|
||||
private List<String> specsImgs;
|
||||
|
||||
@TableField("desc")
|
||||
@ApiModelProperty(value = "产品描述")
|
||||
private String desc;
|
||||
|
||||
|
||||
// @ApiModelProperty(value = "通用规格")
|
||||
// private ProductSpecs productSpecs;
|
||||
@ -90,4 +90,8 @@ public class ProductVO {
|
||||
// @TableField("other_specs")
|
||||
// @ApiModelProperty(value = "其他额外规格")
|
||||
// private String[] otherSpecs;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
</select>
|
||||
|
||||
<select id="getQueryDownChapterId" resultType="com.shenghua.vo.NewsVo">
|
||||
|
||||
SELECT *
|
||||
FROM news
|
||||
WHERE id > (SELECT id FROM news WHERE category_id = #{categoryId} AND id=#{id} ORDER BY id ASC LIMIT 1)
|
||||
@ -49,9 +50,6 @@
|
||||
|
||||
<select id="queryList" resultType="com.shenghua.vo.NewsVo">
|
||||
SELECT * FROM news
|
||||
<if test="categoryId!=null and categoryId!=''">
|
||||
where category_id= #{categoryId}
|
||||
</if>
|
||||
order by create_time desc
|
||||
limit #{startNum},#{pageSize}
|
||||
</select>
|
||||
|
@ -9,6 +9,7 @@
|
||||
p.category_id AS categoryId,
|
||||
p.type_arr AS typeArr,
|
||||
p.cover,
|
||||
p.imgs_relation_id AS imgsRelationId,
|
||||
p.content,
|
||||
p.price,
|
||||
p.specs_id AS specsId,
|
||||
@ -17,8 +18,7 @@
|
||||
p.seo_description AS seoDescription,
|
||||
p.seo_keywords AS seoKeywords,
|
||||
p.create_time AS createTime,
|
||||
p.update_time AS updateTime,
|
||||
p.desc AS `desc`
|
||||
p.update_time AS updateTime
|
||||
FROM product AS p
|
||||
</sql>
|
||||
|
||||
@ -42,11 +42,7 @@
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY p.id DESC
|
||||
</select>
|
||||
|
||||
<select id="getById" resultType="com.shenghua.entitys.product.Product">
|
||||
SELECT * FROM product WHERE id = #{id};
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user