Compare commits

...

4 Commits
dev ... SS

Author SHA1 Message Date
zhang xu 013b02c652 还差商品信息 2024-03-03 15:33:30 +08:00
DongZeLiang 342647b13a 封装了一下品类获取父级所有的公共元素 2024-03-03 15:32:12 +08:00
DongZeLiang fd66219ea5 品类获取父级所有的公共元素 2024-03-03 15:32:12 +08:00
DongZeLiang 2b54282abe 品类添加 2024-03-03 15:32:12 +08:00
35 changed files with 649 additions and 39 deletions

View File

@ -66,6 +66,8 @@ public class SysLoginService {
}
// 查询用户信息
Result<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
LoginUser data = userResult.getData();
System.out.println(data);
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");

View File

@ -15,6 +15,7 @@ spring:
discovery:
# 服务注册地址
server-addr: 115.159.67.205:8848
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
config:
# 配置中心地址
server-addr: 115.159.67.205:8848
@ -23,3 +24,4 @@ spring:
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3

View File

@ -6,6 +6,7 @@ package com.muyu.common.core.exception;
* @author muyu
*/
public final class ServiceException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**

View File

@ -88,6 +88,7 @@
<version>${swagger.fox.version}</version>
</dependency>
</dependencies>
<build>

View File

@ -15,6 +15,7 @@ spring:
discovery:
# 服务注册地址
server-addr: 115.159.67.205:8848
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
config:
# 配置中心地址
server-addr: 115.159.67.205:8848
@ -23,6 +24,7 @@ spring:
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
sentinel:
# 取消控制台懒加载
eager: true

View File

@ -15,6 +15,7 @@ spring:
discovery:
# 服务注册地址
server-addr: 115.159.67.205:8848
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
config:
# 配置中心地址
server-addr: 115.159.67.205:8848
@ -23,3 +24,4 @@ spring:
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3

View File

@ -15,6 +15,7 @@ spring:
discovery:
# 服务注册地址
server-addr: 115.159.67.205:8848
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
config:
# 配置中心地址
server-addr: 115.159.67.205:8848
@ -23,3 +24,4 @@ spring:
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3

View File

@ -15,6 +15,7 @@ spring:
discovery:
# 服务注册地址
server-addr: 115.159.67.205:8848
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
config:
# 配置中心地址
server-addr: 115.159.67.205:8848
@ -23,3 +24,4 @@ spring:
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3

View File

@ -3,6 +3,7 @@ package com.muyu.product.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.product.domain.base.CategoryBase;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@ -25,7 +26,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
@TableName("as_category_attribute")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "AsCategoryAttribute", description = "品类属性中间")
public class AsCategoryAttribute extends BaseEntity {
public class AsCategoryAttribute extends BaseEntity implements CategoryBase {
private static final long serialVersionUID = 1L;
@ -45,4 +46,15 @@ public class AsCategoryAttribute extends BaseEntity {
private Long attributeId;
public static AsCategoryAttribute categoryBuild(Long categoryInfoId, Long attributeId) {
return AsCategoryAttribute.builder()
.categoryId(categoryInfoId)
.attributeId(attributeId)
.build();
}
@Override
public Long getBaseId () {
return this.attributeId;
}
}

View File

@ -3,6 +3,7 @@ package com.muyu.product.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.product.domain.base.CategoryBase;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@ -25,7 +26,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
@TableName("as_category_attribute_group")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "AsCategoryAttributeGroup", description = "品类属性组中间")
public class AsCategoryAttributeGroup extends BaseEntity {
public class AsCategoryAttributeGroup extends BaseEntity implements CategoryBase {
private static final long serialVersionUID = 1L;
@ -45,4 +46,15 @@ public class AsCategoryAttributeGroup extends BaseEntity {
private Long attributeGroupId;
public static AsCategoryAttributeGroup categoryBuild(Long categoryInfoId, Long attributeGroupId) {
return AsCategoryAttributeGroup.builder()
.attributeGroupId(attributeGroupId)
.categoryId(categoryInfoId)
.build();
}
@Override
public Long getBaseId () {
return this.attributeGroupId;
}
}

View File

@ -3,6 +3,7 @@ package com.muyu.product.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.product.domain.base.CategoryBase;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@ -25,7 +26,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
@TableName("as_category_brand")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "AsCategoryBrand", description = "品类品牌中间")
public class AsCategoryBrand extends BaseEntity {
public class AsCategoryBrand extends BaseEntity implements CategoryBase {
private static final long serialVersionUID = 1L;
@ -44,4 +45,15 @@ public class AsCategoryBrand extends BaseEntity {
@ApiModelProperty(name = "品牌id", value = "品牌id", required = true)
private Long brandId;
public static AsCategoryBrand categoryBuild(Long categoryInfoId, Long brandId) {
return AsCategoryBrand.builder()
.brandId(brandId)
.categoryId(categoryInfoId)
.build();
}
@Override
public Long getBaseId () {
return this.brandId;
}
}

View File

@ -3,6 +3,7 @@ package com.muyu.product.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.product.domain.model.CategoryInfoSaveModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@ -15,6 +16,10 @@ import com.muyu.product.domain.req.CategoryInfoSaveReq;
import com.muyu.product.domain.req.CategoryInfoEditReq;
import com.muyu.common.core.web.domain.TreeEntity;
import java.util.Date;
import java.util.function.Function;
import java.util.function.Supplier;
/**
* category_info
*
@ -57,6 +62,11 @@ public class CategoryInfo extends TreeEntity {
@ApiModelProperty(name = "介绍", value = "介绍")
private String introduction;
@Excel(name = "父级id")
@ApiModelProperty(name = "父级id", value = "父级id")
private Long parentId;
/**
*
*/
@ -64,6 +74,7 @@ public class CategoryInfo extends TreeEntity {
return CategoryInfo.builder()
.name(categoryInfoQueryReq.getName())
.image(categoryInfoQueryReq.getImage())
.parentId(categoryInfoQueryReq.getParentId())
.start(categoryInfoQueryReq.getStart())
.introduction(categoryInfoQueryReq.getIntroduction())
.build();
@ -72,12 +83,15 @@ public class CategoryInfo extends TreeEntity {
/**
*
*/
public static CategoryInfo saveBuild(CategoryInfoSaveReq categoryInfoSaveReq){
public static CategoryInfo saveBuild(CategoryInfoSaveReq categoryInfoSaveReq, Supplier<String> supplier){
return CategoryInfo.builder()
.name(categoryInfoSaveReq.getName())
.image(categoryInfoSaveReq.getImage())
.start(categoryInfoSaveReq.getStart())
.introduction(categoryInfoSaveReq.getIntroduction())
.parentId(categoryInfoSaveReq.getParentId())
.createBy(supplier.get())
.createTime(new Date())
.build();
}
@ -90,8 +104,20 @@ public class CategoryInfo extends TreeEntity {
.name(categoryInfoEditReq.getName())
.image(categoryInfoEditReq.getImage())
.start(categoryInfoEditReq.getStart())
.parentId(categoryInfoEditReq.getParentId())
.introduction(categoryInfoEditReq.getIntroduction())
.build();
}
public static CategoryInfo saveModelBuild(CategoryInfoSaveModel categoryInfoSaveModel) {
return CategoryInfo.builder()
.name(categoryInfoSaveModel.getName())
.image(categoryInfoSaveModel.getImage())
.start(categoryInfoSaveModel.getStart())
.introduction(categoryInfoSaveModel.getIntroduction())
.parentId(categoryInfoSaveModel.getParentId())
.createBy(categoryInfoSaveModel.getCreateBy())
.createTime(new Date())
.build();
}
}

View File

@ -50,7 +50,7 @@ public class CommentInfo extends BaseEntity {
/** 图片 */
@Excel(name = "图片")
@ApiModelProperty(name = "图片", value = "图片")
private String images;
private String image;
/** 父类id */
@Excel(name = "父类id")
@ -64,7 +64,7 @@ public class CommentInfo extends BaseEntity {
return CommentInfo.builder()
.projectId(commentInfoQueryReq.getProjectId())
.comment(commentInfoQueryReq.getComment())
.images(commentInfoQueryReq.getImages())
.image(commentInfoQueryReq.getImages())
.parentId(commentInfoQueryReq.getParentId())
.build();
}
@ -76,7 +76,7 @@ public class CommentInfo extends BaseEntity {
return CommentInfo.builder()
.projectId(commentInfoSaveReq.getProjectId())
.comment(commentInfoSaveReq.getComment())
.images(commentInfoSaveReq.getImages())
.image(commentInfoSaveReq.getImages())
.parentId(commentInfoSaveReq.getParentId())
.build();
}
@ -89,7 +89,7 @@ public class CommentInfo extends BaseEntity {
.id(id)
.projectId(commentInfoEditReq.getProjectId())
.comment(commentInfoEditReq.getComment())
.images(commentInfoEditReq.getImages())
.image(commentInfoEditReq.getImages())
.parentId(commentInfoEditReq.getParentId())
.build();
}

View File

@ -0,0 +1,11 @@
package com.muyu.product.domain.base;
/**
* @author DongZl
* @description: attribute
* @Date 2024-3-1 02:28
*/
public interface CategoryBase {
public Long getBaseId();
}

View File

@ -0,0 +1,78 @@
package com.muyu.product.domain.model;
import com.muyu.common.core.web.domain.TreeEntity;
import com.muyu.product.domain.CategoryInfo;
import com.muyu.product.domain.req.CategoryInfoSaveReq;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.Date;
import java.util.List;
import java.util.function.Supplier;
/**
* category_info
*
* @author DongZeLiang
* @date 2024-02-27
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class CategoryInfoSaveModel extends TreeEntity {
private static final long serialVersionUID = 1L;
/** 品类名称 */
private String name;
/** 图片 */
private String image;
/** 是否启用 */
private String start;
/** 介绍 */
private String introduction;
/**
* ID
*/
private List<Long> attributeGroupIdList;
/**
* ID
*/
private List<Long> attributeIdList;
/**
* ID
*/
private List<Long> brandIdList;
/**
*
*/
public static CategoryInfoSaveModel saveBuild(CategoryInfoSaveReq categoryInfoSaveReq, Supplier<String> supplier){
return CategoryInfoSaveModel.builder()
.name(categoryInfoSaveReq.getName())
.image(categoryInfoSaveReq.getImage())
.start(categoryInfoSaveReq.getStart())
.introduction(categoryInfoSaveReq.getIntroduction())
.parentId(categoryInfoSaveReq.getParentId())
.attributeGroupIdList(categoryInfoSaveReq.getAttributeGroupIdList())
.attributeIdList(categoryInfoSaveReq.getAttributeIdList())
.brandIdList(categoryInfoSaveReq.getBrandIdList())
.createBy(supplier.get())
.createTime(new Date())
.build();
}
}

View File

@ -8,6 +8,8 @@ import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.web.domain.TreeEntity;
import java.util.List;
/**
* category_info
*
@ -48,4 +50,18 @@ public class CategoryInfoSaveReq extends TreeEntity {
@ApiModelProperty(name = "介绍", value = "介绍")
private String introduction;
/**
* ID
*/
private List<Long> attributeGroupIdList;
/**
* ID
*/
private List<Long> attributeIdList;
/**
* ID
*/
private List<Long> brandIdList;
}

View File

@ -0,0 +1,39 @@
package com.muyu.product.domain.resp;
import com.muyu.product.domain.AttributeGroup;
import com.muyu.product.domain.AttributeInfo;
import com.muyu.product.domain.BrandInfo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author DongZl
* @description:
* @Date 2024-3-1 11:02
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CategoryParentCommonElementResp {
/**
*
*/
private List<AttributeInfo> attributeInfoList;
/**
*
*/
private List<AttributeGroup> attributeGroupList;
/**
*
*/
private List<BrandInfo> brandInfoList;
}

View File

@ -1,8 +1,15 @@
package com.muyu.product.controller;
import java.util.List;
import java.util.function.Supplier;
import javax.servlet.http.HttpServletResponse;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.product.domain.AttributeGroup;
import com.muyu.product.domain.AttributeInfo;
import com.muyu.product.domain.BrandInfo;
import com.muyu.product.domain.model.CategoryInfoSaveModel;
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -81,7 +88,9 @@ public class CategoryInfoController extends BaseController {
@PostMapping
@ApiOperation("新增品类信息")
public Result<String> add(@RequestBody CategoryInfoSaveReq categoryInfoSaveReq) {
return toAjax(categoryInfoService.save(CategoryInfo.saveBuild(categoryInfoSaveReq)));
return toAjax(categoryInfoService.save(
CategoryInfoSaveModel.saveBuild(categoryInfoSaveReq, SecurityUtils::getUsername)
));
}
/**
@ -106,4 +115,18 @@ public class CategoryInfoController extends BaseController {
public Result<String> remove(@PathVariable List<Long> ids) {
return toAjax(categoryInfoService.removeBatchByIds(ids));
}
/**
* ID
* @param categoryId ID
* @return
*/
@GetMapping("/parentCommonElement/{categoryId}")
@ApiOperation("通过品类ID获取父级以上的属性集合")
@ApiImplicitParam(name = "categoryId", value = "categoryId", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class, example = "1")
public Result<CategoryParentCommonElementResp> parentCommonElement(
@PathVariable(value = "categoryId") Long categoryId
) {
return Result.success(categoryInfoService.parentCommonElement(categoryId));
}
}

View File

@ -1,8 +1,11 @@
package com.muyu.product.service;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.muyu.product.domain.AsAttributeGroup;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.product.domain.AsCategoryAttribute;
/**
* Service
@ -17,6 +20,6 @@ public interface AsAttributeGroupService extends IService<AsAttributeGroup> {
* @param asAttributeGroup
* @return
*/
public List<AsAttributeGroup> list(AsAttributeGroup asAttributeGroup);
public List<AsAttributeGroup> list(LambdaQueryWrapper<AsCategoryAttribute> asAttributeGroup);
}

View File

@ -1,8 +1,14 @@
package com.muyu.product.service;
import java.util.List;
import com.muyu.product.domain.AttributeGroup;
import com.muyu.product.domain.AttributeInfo;
import com.muyu.product.domain.BrandInfo;
import com.muyu.product.domain.CategoryInfo;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.product.domain.model.CategoryInfoSaveModel;
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
/**
* Service
@ -19,4 +25,38 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
*/
public List<CategoryInfo> list(CategoryInfo categoryInfo);
/**
*
* @param categoryInfoSaveModel
* @return
*/
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel);
/**
* ID
* @param categoryId ID
* @return
*/
List<AttributeGroup> getAttributeGroup (Long categoryId);
/**
* ID
* @param categoryId ID
* @return
*/
List<BrandInfo> getBrand (Long categoryId);
/**
* ID
* @param categoryId ID
* @return
*/
List<AttributeInfo> getAttribute (Long categoryId);
/**
* ID
* @param categoryId ID
* @return
*/
CategoryParentCommonElementResp parentCommonElement (Long categoryId);
}

View File

@ -3,6 +3,7 @@ package com.muyu.product.service.impl;
import java.util.List;
import com.muyu.common.core.utils.ObjUtils;
import com.muyu.product.domain.AsCategoryAttribute;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.muyu.product.mapper.AsAttributeGroupMapper;
@ -28,20 +29,18 @@ public class AsAttributeGroupServiceImpl extends ServiceImpl<AsAttributeGroupMap
* @return
*/
@Override
public List<AsAttributeGroup> list(AsAttributeGroup asAttributeGroup) {
public List<AsAttributeGroup> list(LambdaQueryWrapper<AsCategoryAttribute> asAttributeGroup) {
LambdaQueryWrapper<AsAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
if (ObjUtils.notNull(asAttributeGroup.getGroupId())){
queryWrapper.eq(AsAttributeGroup::getGroupId, asAttributeGroup.getGroupId());
}
if (ObjUtils.notNull(asAttributeGroup.getAttributeId())){
queryWrapper.eq(AsAttributeGroup::getAttributeId, asAttributeGroup.getAttributeId());
}
// if (ObjUtils.notNull(asAttributeGroup.getGroupId())){
// queryWrapper.eq(AsAttributeGroup::getGroupId, asAttributeGroup.getGroupId());
// }
//
//
// if (ObjUtils.notNull(asAttributeGroup.getAttributeId())){
// queryWrapper.eq(AsAttributeGroup::getAttributeId, asAttributeGroup.getAttributeId());
// }
return list(queryWrapper);

View File

@ -62,6 +62,8 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
.build();
}
/**
*
*

View File

@ -64,10 +64,14 @@ public class AttributeInfoServiceImpl extends ServiceImpl<AttributeInfoMapper, A
}
LambdaQueryWrapper<AsAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AsAttributeGroup::getGroupId, groupId);
List<Long> list = asAttributeGroupService.list(queryWrapper).stream()
.map(AsAttributeGroup::getAttributeId)
.toList();
if (list == null || list.isEmpty()){
return null;
}
return this.listByIds(
asAttributeGroupService.list(queryWrapper).stream()
.map(AsAttributeGroup::getAttributeId)
.toList()
list
);
}
}

View File

@ -1,15 +1,24 @@
package com.muyu.product.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.common.core.utils.ObjUtils;
import com.muyu.product.domain.*;
import com.muyu.product.domain.base.CategoryBase;
import com.muyu.product.domain.model.CategoryInfoSaveModel;
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
import com.muyu.product.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.muyu.product.mapper.CategoryInfoMapper;
import com.muyu.product.domain.CategoryInfo;
import com.muyu.product.service.CategoryInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
@ -21,6 +30,25 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@Service
public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, CategoryInfo> implements CategoryInfoService {
@Autowired
private AsCategoryAttributeService asCategoryAttributeService;
@Autowired
private AsCategoryAttributeGroupService asCategoryAttributeGroupService;
@Autowired
private AsCategoryBrandService asCategoryBrandService;
@Autowired
private AttributeInfoService attributeInfoService;
@Autowired
private BrandInfoService brandInfoService;
@Autowired
private AttributeGroupService attributeGroupService;
/**
*
*
@ -52,10 +80,195 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
queryWrapper.eq(CategoryInfo::getIntroduction, categoryInfo.getIntroduction());
}
return list(queryWrapper);
}
@Override
@Transactional
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel) {
CategoryInfo categoryInfo = CategoryInfo.saveModelBuild(categoryInfoSaveModel);
boolean save = this.save(categoryInfo);
Long categoryInfoId = categoryInfo.getId();
List<Long> attributeIdList = categoryInfoSaveModel.getAttributeIdList();
if (attributeIdList != null && !attributeIdList.isEmpty()){
asCategoryAttributeService.saveBatch(
attributeIdList.stream()
.map(attributeId -> AsCategoryAttribute.categoryBuild(categoryInfoId, attributeId))
.toList()
);
}
List<Long> attributeGroupIdList = categoryInfoSaveModel.getAttributeGroupIdList();
if (attributeGroupIdList != null && !attributeGroupIdList.isEmpty()){
asCategoryAttributeGroupService.saveBatch(
attributeGroupIdList.stream()
.map(attributeGroupId -> AsCategoryAttributeGroup.categoryBuild(categoryInfoId, attributeGroupId))
.toList()
);
}
List<Long> brandIdList = categoryInfoSaveModel.getBrandIdList();
if (brandIdList != null && !brandIdList.isEmpty()){
asCategoryBrandService.saveBatch(
brandIdList.stream()
.map(brandId -> AsCategoryBrand.categoryBuild(categoryInfoId, brandId))
.toList()
);
}
return save;
}
/**
* ID
*
* @param categoryId ID
*
* @return
*/
@Override
public List<AttributeGroup> getAttributeGroup (Long categoryId) {
List<AttributeGroup> attributeGroupList = new ArrayList<>();
LambdaQueryWrapper<AsCategoryAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AsCategoryAttributeGroup::getCategoryId, categoryId);
List<AsCategoryAttributeGroup> asCategoryAttributeGroupList = asCategoryAttributeGroupService.list(queryWrapper);
if (asCategoryAttributeGroupList != null && !asCategoryAttributeGroupList.isEmpty()){
List<Long> attributeGroupIdList = asCategoryAttributeGroupList.stream()
.map(AsCategoryAttributeGroup::getAttributeGroupId)
.toList();
attributeGroupList.addAll(attributeGroupService.listByIds(attributeGroupIdList));
}
CategoryInfo categoryInfo = this.getById(categoryId);
if (categoryInfo.getParentId() != 0){
if (attributeGroupList.isEmpty()){
attributeGroupList.addAll(getAttributeGroup(categoryInfo.getParentId()));
}else {
List<AttributeGroup> attributeGroups = getAttributeGroup(categoryInfo.getParentId());
attributeGroups.forEach(attributeGroup -> {
if (!attributeGroupList.contains(attributeGroup)){
attributeGroupList.add(attributeGroup);
}
});
}
}
return attributeGroupList;
}
/**
* ID
*
* @param categoryId ID
*
* @return
*/
@Override
public List<BrandInfo> getBrand (Long categoryId) {
List<BrandInfo> brandInfoList = new ArrayList<>();
LambdaQueryWrapper<AsCategoryBrand> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AsCategoryBrand::getCategoryId, categoryId);
List<AsCategoryBrand> asCategoryBrandList = asCategoryBrandService.list(queryWrapper);
if (asCategoryBrandList != null && !asCategoryBrandList.isEmpty()){
List<Long> brandIdList = asCategoryBrandList.stream()
.map(AsCategoryBrand::getBrandId)
.toList();
brandInfoList.addAll(brandInfoService.listByIds(brandIdList));
}
CategoryInfo categoryInfo = this.getById(categoryId);
if (categoryInfo.getParentId() != 0){
if (brandInfoList.isEmpty()){
brandInfoList.addAll(getBrand(categoryInfo.getParentId()));
}else {
List<BrandInfo> brandInfos = getBrand(categoryInfo.getParentId());
brandInfos.forEach(brandInfo -> {
if (!brandInfoList.contains(brandInfo)){
brandInfoList.add(brandInfo);
}
});
}
}
return brandInfoList;
}
/**
* ID
*
* @param categoryId ID
*
* @return
*/
@Override
public List<AttributeInfo> getAttribute (Long categoryId) {
List<AttributeInfo> attributeInfoList = new ArrayList<>();
LambdaQueryWrapper<AsCategoryAttribute> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AsCategoryAttribute::getCategoryId, categoryId);
List<AsCategoryAttribute> asCategoryAttributeList = asCategoryAttributeService.list(queryWrapper);
if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()){
List<Long> attributeIdList = asCategoryAttributeList.stream()
.map(AsCategoryAttribute::getAttributeId)
.toList();
attributeInfoList.addAll(attributeInfoService.listByIds(attributeIdList));
}
CategoryInfo categoryInfo = this.getById(categoryId);
if (categoryInfo.getParentId() != 0){
if (attributeInfoList.isEmpty()){
attributeInfoList.addAll(getAttribute(categoryInfo.getParentId()));
}else {
List<AttributeInfo> attributeInfos = getAttribute(categoryInfo.getParentId());
attributeInfos.forEach(attributeInfoQuery -> {
if (!attributeInfoList.contains(attributeInfoQuery)){
attributeInfoList.add(attributeInfoQuery);
}
});
}
}
return attributeInfoList;
}
public <T,AS> List<T> getCommon(Long categoryId,IService<AS> iService,IService<T> bsiService){
List<T> list = new ArrayList();
QueryWrapper<AS> asQueryWrapper = new QueryWrapper<>();
asQueryWrapper.eq("category_id", categoryId);
List<AS> asList = iService.list(asQueryWrapper);
if (asList != null && !asList.isEmpty()){
List<Long> baseIdList = asList.stream()
.map(as -> {
if (as instanceof CategoryBase categoryBase){
return categoryBase.getBaseId();
}
return null;
})
.toList();
list.addAll(bsiService.listByIds(baseIdList));
}
CategoryInfo categoryInfo = this.getById(categoryId);
if (categoryInfo.getParentId() != 0){
if (list.isEmpty()){
list.addAll(getCommon(categoryInfo.getParentId(), iService, bsiService));
}else {
List<T> commonList = getCommon(categoryInfo.getParentId(), iService, bsiService);
commonList.forEach(common -> {
if (!list.contains(common)){
list.add(common);
}
});
}
}
return list;
}
/**
* ID
*
* @param categoryId ID
*
* @return
*/
@Override
public CategoryParentCommonElementResp parentCommonElement (Long categoryId) {
return CategoryParentCommonElementResp.builder()
.attributeInfoList(getCommon(categoryId, asCategoryAttributeService, attributeInfoService))
.attributeGroupList(getCommon(categoryId, asCategoryAttributeGroupService, attributeGroupService))
.brandInfoList(getCommon(categoryId, asCategoryBrandService, brandInfoService))
.build();
}
}

View File

@ -0,0 +1,99 @@
package com.muyu.product.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.product.domain.*;
import com.muyu.product.domain.model.CategoryInfoSaveModel;
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
import com.muyu.product.mapper.CategoryInfoMapper;
import com.muyu.product.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class CategoryInfoServiceImpl1 extends ServiceImpl<CategoryInfoMapper, CategoryInfo> implements CategoryInfoService {
@Autowired
private AsAttributeGroupService asAttributeGroupService;
@Autowired
private AsCategoryAttributeService asCategoryAttributeService;
@Autowired
private AsCategoryBrandService asCategoryBrandService;
@Autowired
private BrandInfoService brandInfoService;
@Autowired
private AttributeInfoService attributeInfoService;
@Override
public List<CategoryInfo> list(CategoryInfo categoryInfo) {
//创建一个查询条件
LambdaQueryWrapper<CategoryInfo> queryWrapper = new LambdaQueryWrapper<>();
if (Objects.nonNull(categoryInfo.getName())){
queryWrapper.like(CategoryInfo::getName,categoryInfo.getName());
}
if (Objects.nonNull(categoryInfo.getImage())){
queryWrapper.eq(CategoryInfo::getImage,categoryInfo.getImage());
}
if (Objects.nonNull(categoryInfo.getParentId())){
queryWrapper.eq(CategoryInfo::getParentId,categoryInfo.getParentId());
}
if (Objects.nonNull(categoryInfo.getStart())){
queryWrapper.eq(CategoryInfo::getStart,categoryInfo.getStart());
}
if (Objects.nonNull(categoryInfo.getIntroduction())){
queryWrapper.eq(CategoryInfo::getIntroduction,categoryInfo.getIntroduction());
}
return list(queryWrapper);
}
@Override
@Transactional
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel) {
//创建对象
CategoryInfo categoryInfo = CategoryInfo.saveModelBuild(categoryInfoSaveModel);
boolean save = this.save(categoryInfo);
Long categoryInfoId = categoryInfo.getId();
List<Long> attributeIdList = categoryInfoSaveModel.getAttributeIdList();
if (attributeIdList!=null&& !attributeIdList.isEmpty()){
}
return false;
}
@Override
public List<AttributeGroup> getAttributeGroup(Long categoryId) {
return null;
}
@Override
public List<BrandInfo> getBrand(Long categoryId) {
return null;
}
@Override
public List<AttributeInfo> getAttribute(Long categoryId) {
List<AttributeInfo> attributeInfos = new ArrayList<>();
LambdaQueryWrapper<AsCategoryAttribute> queryWrapper = new LambdaQueryWrapper<>();
asAttributeGroupService.list(queryWrapper);
return null;
}
@Override
public CategoryParentCommonElementResp parentCommonElement(Long categoryId) {
return null;
}
}

View File

@ -40,8 +40,8 @@ public class CommentInfoServiceImpl extends ServiceImpl<CommentInfoMapper, Comme
queryWrapper.eq(CommentInfo::getComment, commentInfo.getComment());
}
if (ObjUtils.notNull(commentInfo.getImages())){
queryWrapper.eq(CommentInfo::getImages, commentInfo.getImages());
if (ObjUtils.notNull(commentInfo.getImage())){
queryWrapper.eq(CommentInfo::getImage, commentInfo.getImage());
}
if (ObjUtils.notNull(commentInfo.getParentId())){
@ -49,9 +49,6 @@ public class CommentInfoServiceImpl extends ServiceImpl<CommentInfoMapper, Comme
}
return list(queryWrapper);
}
}

View File

@ -15,9 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 115.159.67.205:8848
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
config:
# 配置中心地址
server-addr: 115.159.67.205:8848
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -19,6 +19,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectCategoryInfoVo">
select id, name, image, parent_id, start, introduction, remark, create_by, create_time, update_by, update_time from category_info
select id, name, image, start,parent_id, start, introduction, remark, create_by, create_time, update_by, update_time from category_info
</sql>
</mapper>

View File

@ -8,7 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="id" column="id" />
<result property="projectId" column="project_id" />
<result property="comment" column="comment" />
<result property="images" column="images" />
<result property="image" column="images" />
<result property="parentId" column="parent_id" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />

View File

@ -5,6 +5,7 @@ import com.muyu.common.security.annotation.EnableMyFeignClients;
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
/**
*

View File

@ -36,7 +36,7 @@ public class SysDictDataController extends BaseController {
@RequiresPermissions("system:dict:list")
@GetMapping("/list")
public Result<TableDataInfo<SysDictData>> list (SysDictData dictData) {
public Result<TableDataInfo<SysDictData>> list (@RequestBody SysDictData dictData) {
startPage();
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return getDataTable(list);
@ -45,7 +45,7 @@ public class SysDictDataController extends BaseController {
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:dict:export")
@PostMapping("/export")
public void export (HttpServletResponse response, SysDictData dictData) {
public void export (HttpServletResponse response,@RequestBody SysDictData dictData) {
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
util.exportExcel(response, list, "字典数据");

View File

@ -2,6 +2,7 @@ package com.muyu.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.common.system.domain.SysDictData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -11,6 +12,7 @@ import java.util.List;
*
* @author muyu
*/
@Mapper
public interface SysDictDataMapper extends BaseMapper<SysDictData> {
/**
*

View File

@ -2,6 +2,7 @@ package com.muyu.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.common.system.domain.SysDictType;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@ -10,6 +11,7 @@ import java.util.List;
*
* @author muyu
*/
@Mapper
public interface SysDictTypeMapper extends BaseMapper<SysDictType> {
/**
*

View File

@ -15,6 +15,7 @@ spring:
discovery:
# 服务注册地址
server-addr: 115.159.67.205:8848
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
config:
# 配置中心地址
server-addr: 115.159.67.205:8848
@ -23,6 +24,7 @@ spring:
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
logging:
level:
com.muyu.system.mapper: DEBUG

View File

@ -23,3 +23,4 @@ spring:
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3