提交 6b7045c5 编写于 作者: 寒風冷度夜雨's avatar 寒風冷度夜雨 🈴

message:宠物商城项目

desc:宠物用品类型修改,宠物用品资讯列表查询修改
author:王荣力
time:20230919
上级 b42f2aee
-- 配置表数据插入
INSERT INTO pet_code (LABEL,VALUE,STAND_BY_FLAG1,STAND_BY_FLAG2,STAND_BY_FLAG3,IS_DELETED) VALUES
('玩具和游戏','0','PRODUCT_CATEGORY','product_category',NULL,NULL),
('食品和饮料','1','PRODUCT_CATEGORY','product_category',NULL,NULL),
('床上用品','2','PRODUCT_CATEGORY','product_category',NULL,NULL),
('服装和饰品','3','PRODUCT_CATEGORY','product_category',NULL,NULL),
('犬舍和猫屋','4','PRODUCT_CATEGORY','product_category',NULL,NULL),
('清洁和卫生','5','PRODUCT_CATEGORY','product_category',NULL,NULL),
('健康和护理','6','PRODUCT_CATEGORY','product_category',NULL,NULL),
('旅行和户外','7','PRODUCT_CATEGORY','product_category',NULL,NULL),
('verifyCode','Y',NULL,NULL,NULL,NULL);
package cn.youle.pet.shop.controller;
import cn.youle.pet.shop.common.JsonResponse;
import cn.youle.pet.shop.pojo.dto.news.NewsListReqDTO;
import cn.youle.pet.shop.pojo.dto.news.NewsSaveDTO;
import cn.youle.pet.shop.service.IPetNewsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -16,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
* @createTime: 2023/10/12 20:12
*/
@RestController
@RequestMapping("/pet-news")
@RequestMapping("/api/pet-news")
@Slf4j
public class PetNewsController {
......@@ -59,8 +61,12 @@ public class PetNewsController {
* @return
*/
@PostMapping("/list")
public JsonResponse list(){
return null;
public JsonResponse list(@RequestBody NewsListReqDTO newsListReqDTO){
try {
return JsonResponse.ok(petNewsService.list(newsListReqDTO));
}catch (Exception e){
return JsonResponse.failed("查询失败,原因是:" + e.getMessage());
}
}
@PostMapping("/detail")
......
package cn.youle.pet.shop.controller.front;
import cn.youle.pet.shop.common.JsonResponse;
import cn.youle.pet.shop.service.IFirstPageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -12,9 +14,12 @@ import org.springframework.web.bind.annotation.RestController;
* @createTime: 2023/10/12 20:08
*/
@RestController
@RequestMapping("/pet-front")
@RequestMapping("/api/pet-front")
public class FirstPageController {
@Autowired
private IFirstPageService firstPageService;
/**
* 宠物商品列表查询
*
......@@ -42,6 +47,10 @@ public class FirstPageController {
*/
@PostMapping("/banner/list")
public JsonResponse bannerList() {
return null;
try {
return JsonResponse.ok(firstPageService.bannerList());
}catch (Exception e){
return JsonResponse.failed(e.getMessage());
}
}
}
......@@ -8,14 +8,14 @@ package cn.youle.pet.shop.enums;
*/
public enum ENUM_CATEGORY_TYPE {
TOYS("0","玩具"),
FOODS("1","食品和零食"),
BEAUTY_PRODUCTS("2","美容用品"),
PET_LUGGAGE("3","宠物箱包"),
FOOD_BOWL("4","食盆/饮水器"),
PET_FURNITURE("5","宠物家具"),
HEALTH_PRODUCTS("6","保健品"),
ELSE("7","其他");
TOYS("0","玩具和游戏"),
FOODS("1","食品和饮料"),
BEAUTY_PRODUCTS("2","床上用品"),
PET_LUGGAGE("3","服装和饰品"),
FOOD_BOWL("4","犬舍和猫屋"),
PET_FURNITURE("5","清洁和卫生"),
HEALTH_PRODUCTS("6","健康和护理"),
ELSE("7","旅行和户外");
String code;
......
package cn.youle.pet.shop.enums;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
/**
* @projectName: pet-shop
* @description: 是否删除枚举
......@@ -20,8 +23,11 @@ public enum ENUM_DELETE_TYPE {
}
public static String getNameByCode(String code){
if(StringUtils.isEmpty(code)){
return null;
}
for (ENUM_DELETE_TYPE enumDeleteType : ENUM_DELETE_TYPE.values()){
if(enumDeleteType.getCode().equals(code)){
if(Objects.equals(enumDeleteType.getCode(), Integer.valueOf(code))){
return enumDeleteType.getName();
}
}
......
......@@ -30,7 +30,7 @@ public class NewsSaveDTO implements Serializable {
/**
* 商品图片
*/
private String pages;
private String url;
/**
* 商品简介
......
......@@ -28,7 +28,7 @@ public class NewsDetailVO implements Serializable {
/**
* 商品图片
*/
private String pages;
private String url;
/**
* 商品简介
......
......@@ -16,7 +16,7 @@ public class NewsListVO implements Serializable {
private static final long serialVersionUID = 3415949742321012766L;
private Integer pageNum;
private Integer page;
private Integer pageSize;
......
......@@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -90,7 +91,9 @@ public class BannerServiceImpl implements IBannerService {
String id = bannerSaveDTO.getId();
PetBanners petBanners = getPetBanner(id);
petBanners.setName(bannerSaveDTO.getName());
petBanners.setUrl(bannerSaveDTO.getUrl());
String url = bannerSaveDTO.getUrl();
url = showUrl + url.substring(url.lastIndexOf("\\") + 1);
petBanners.setUrl(url);
TokenVO userInfo = GetUserInfoUtils.getUserInfo();
petBanners.setUpdatedBy(userInfo.getId());
petBanners.setUpdatedTime(new Date());
......@@ -157,7 +160,13 @@ public class BannerServiceImpl implements IBannerService {
if (!CollectionUtils.isEmpty(petBanners)) {
total = petBanners.size();
petBanners = petBanners.stream().skip(page).limit(bannerListDTO.getPageSize()).collect(Collectors.toList());
petBanners = petBanners.stream().sorted(Comparator.comparing(PetBanners::getCreatedTime).reversed()).sorted(Comparator.comparing(k->{
if(ENUM_STATUS_TYPE.UP_STATUS.getCode().equals(k.getStatus())){
return 0;
}else{
return 1;
}
})).skip(page).limit(bannerListDTO.getPageSize()).collect(Collectors.toList());
for (PetBanners petBanner : petBanners) {
BannerDetailVO bannerDetailVO = new BannerDetailVO();
BeanUtils.copyProperties(petBanner, bannerDetailVO);
......
package cn.youle.pet.shop.service.impl;
import cn.youle.pet.shop.enums.ENUM_DELETE_TYPE;
import cn.youle.pet.shop.enums.ENUM_STATUS_TYPE;
import cn.youle.pet.shop.mapper.PetBannersMapper;
import cn.youle.pet.shop.pojo.entity.PetBanners;
import cn.youle.pet.shop.pojo.vo.front.BannerDetailVO;
......@@ -9,6 +10,7 @@ import cn.youle.pet.shop.pojo.vo.front.FirstPageListVO;
import cn.youle.pet.shop.service.IFirstPageService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
......@@ -22,6 +24,7 @@ import java.util.stream.Collectors;
* @author: Administrator
* @createTime: 2023/10/25 9:04
*/
@Service
public class FirstPageServiceImpl implements IFirstPageService {
@Autowired
......@@ -46,7 +49,7 @@ public class FirstPageServiceImpl implements IFirstPageService {
public BannerListVO bannerList() {
BannerListVO bannerListVO = new BannerListVO();
List<BannerDetailVO> bannerDetailList = new ArrayList<>();
List<PetBanners> petBanners = petBannersMapper.selectList(new LambdaQueryWrapper<PetBanners>().eq(PetBanners::getIsDeleted, ENUM_DELETE_TYPE.UN_DELETE.getCode()));
List<PetBanners> petBanners = petBannersMapper.selectList(new LambdaQueryWrapper<PetBanners>().eq(PetBanners::getIsDeleted, ENUM_DELETE_TYPE.UN_DELETE.getCode()).eq(PetBanners::getStatus, ENUM_STATUS_TYPE.UP_STATUS.getCode()));
if(!CollectionUtils.isEmpty(petBanners)){
// 按照创建时间降序排列,取前三条
petBanners = petBanners.stream().sorted(Comparator.comparing(PetBanners::getCreatedTime).reversed()).skip(0).limit(3).collect(Collectors.toList());
......
......@@ -18,6 +18,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
......@@ -40,6 +41,9 @@ public class PetNewsServiceImpl implements IPetNewsService {
@Autowired
private PetNewsInfoMapper petNewsInfoMapper;
@Value("${showPic.path}")
private String showUrl;
/**
* 新增宠物用品资讯
*
......@@ -52,6 +56,9 @@ public class PetNewsServiceImpl implements IPetNewsService {
PetNewsInfo petNewsInfo = new PetNewsInfo();
BeanUtils.copyProperties(newsSaveDTO, petNewsInfo);
long snowflakeNextId = IdUtil.getSnowflakeNextId();
String url = newsSaveDTO.getUrl();
url = showUrl + url.substring(url.lastIndexOf("\\") + 1);
petNewsInfo.setPages(url);
petNewsInfo.setId(snowflakeNextId);
petNewsInfo.setCreatedTime(new Date());
petNewsInfo.setCreatedBy(userInfo.getId());
......@@ -136,7 +143,7 @@ public class PetNewsServiceImpl implements IPetNewsService {
petNewsInfos = petNewsInfoMapper.selectList(new LambdaQueryWrapper<PetNewsInfo>().eq(PetNewsInfo::getIsDeleted, ENUM_DELETE_TYPE.UN_DELETE.getCode()));
}
int page = (newsListReqDTO.getCurrentPage() - 1) * newsListReqDTO.getPageSize();
newsListVO.setPageNum(newsListReqDTO.getCurrentPage());
newsListVO.setPage(newsListReqDTO.getCurrentPage());
newsListVO.setPageSize(newsListReqDTO.getPageSize());
newsListVO.setTotal(petNewsInfos.size());
if (!CollectionUtils.isEmpty(petNewsInfos)) {
......@@ -146,7 +153,7 @@ public class PetNewsServiceImpl implements IPetNewsService {
NewsDetailVO newsDetailVO = new NewsDetailVO();
newsDetailVO.setId(petNewsInfo.getId() + "");
newsDetailVO.setTitle(petNewsInfo.getTitle());
newsDetailVO.setPages(petNewsInfo.getPages());
newsDetailVO.setUrl(petNewsInfo.getPages());
newsDetailVO.setRemark(petNewsInfo.getRemark());
newsDetailList.add(newsDetailVO);
......
......@@ -2,6 +2,7 @@ package cn.youle.pet.shop.service.impl;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.IdUtil;
import cn.youle.pet.shop.enums.ENUM_CATEGORY_TYPE;
import cn.youle.pet.shop.enums.ENUM_DELETE_TYPE;
import cn.youle.pet.shop.exception.PetShopException;
import cn.youle.pet.shop.pojo.dto.CommonConfigDTO;
......@@ -17,13 +18,11 @@ import cn.youle.pet.shop.shiro.auth.TokenVO;
import cn.youle.pet.shop.utils.GetUserInfoUtils;
import cn.youle.pet.shop.utils.JWTUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
......@@ -31,7 +30,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -53,6 +51,9 @@ public class PetProductServiceImpl extends ServiceImpl<PetProductMapper, PetProd
@Resource
private CommonConfigDTO commonConfigDTO;
@Value("${showPic.path}")
private String showUrl;
/**
* 添加商品
*
......@@ -102,7 +103,9 @@ public class PetProductServiceImpl extends ServiceImpl<PetProductMapper, PetProd
petProduct.setIsDeleted(ENUM_DELETE_TYPE.UN_DELETE.getCode());
petProduct.setName(productSaveDTO.getName());
petProduct.setCategory(productSaveDTO.getType());
petProduct.setUrl(productSaveDTO.getUrl());
String url = productSaveDTO.getUrl();
url = showUrl + url.substring(url.lastIndexOf("\\") + 1);
petProduct.setUrl(url);
petProduct.setPrice(productSaveDTO.getPrice());
petProduct.setShelf(productSaveDTO.getShelf());
petProduct.setWeight(productSaveDTO.getWeight());
......@@ -199,16 +202,9 @@ public class PetProductServiceImpl extends ServiceImpl<PetProductMapper, PetProd
ProductDetailVO productDetailVO = new ProductDetailVO();
productDetailVO.setId(petProduct.getId() + "");
productDetailVO.setName(petProduct.getName());
productDetailVO.setType(ENUM_CATEGORY_TYPE.getNameByCode(petProduct.getCategory()));
productDetailVO.setStyle(petProduct.getCategory());
// String url = petProduct.getUrl();
// if(url != null && !"".equals(url)){
// url = url.replace(commonConfigDTO.getPath(),"");
// }
String url = petProduct.getUrl();
log.info("替换前获取的图片地址:{}",url);
url = url.replace("\\","/");
log.info("替换后获取的图片地址:{}",url);
productDetailVO.setUrl(url);
productDetailVO.setUrl(petProduct.getUrl());
productDetailVO.setPrice(petProduct.getPrice());
productDetailVO.setShelf(petProduct.getShelf());
productDetailVO.setWeight(petProduct.getWeight());
......
......@@ -43,6 +43,8 @@ public class ShiroConfig {
map.put("/common/upload","anon");
map.put("/common/download","anon");
map.put("/common/getCode","anon");
map.put("/api/pet-news/list","anon");
map.put("/api/pet-front/**","anon");
map.put("/img/**","anon");
Map<String, Filter> filterMap = new LinkedHashMap<>();
......
......@@ -10,41 +10,41 @@ import org.springframework.context.annotation.Configuration;
@Slf4j
public class XxlJobConfig {
@Value("${xxl.job.admin.addresses}")
private String adminAddresses;
@Value("${xxl.job.executor.appname}")
private String appName;
/*@Value("${xxl.job.executor.ip}")
private String ip;*/
@Value("${xxl.job.executor.port}")
private int port;
@Value("${xxl.job.accessToken}")
private String accessToken;
@Value("${xxl.job.executor.logpath}")
private String logPath;
@Value("${xxl.job.executor.logretentiondays}")
private int logRetentionDays;
@Bean(initMethod = "start", destroyMethod = "destroy")
public XxlJobSpringExecutor xxlJobExecutor() {
log.info(">>>>>>>>>>> xxl-job config init.");
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
xxlJobSpringExecutor.setAppname(appName);
//xxlJobSpringExecutor.setIp(ip);
xxlJobSpringExecutor.setPort(port);
xxlJobSpringExecutor.setAccessToken(accessToken);
xxlJobSpringExecutor.setLogPath(logPath);
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
return xxlJobSpringExecutor;
}
// @Value("${xxl.job.admin.addresses}")
// private String adminAddresses;
//
// @Value("${xxl.job.executor.appname}")
// private String appName;
//
// /*@Value("${xxl.job.executor.ip}")
// private String ip;*/
//
// @Value("${xxl.job.executor.port}")
// private int port;
//
// @Value("${xxl.job.accessToken}")
// private String accessToken;
//
// @Value("${xxl.job.executor.logpath}")
// private String logPath;
//
// @Value("${xxl.job.executor.logretentiondays}")
// private int logRetentionDays;
//
//
// @Bean(initMethod = "start", destroyMethod = "destroy")
// public XxlJobSpringExecutor xxlJobExecutor() {
// log.info(">>>>>>>>>>> xxl-job config init.");
// XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
// xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
// xxlJobSpringExecutor.setAppname(appName);
// //xxlJobSpringExecutor.setIp(ip);
// xxlJobSpringExecutor.setPort(port);
// xxlJobSpringExecutor.setAccessToken(accessToken);
// xxlJobSpringExecutor.setLogPath(logPath);
// xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
//
// return xxlJobSpringExecutor;
// }
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册