本月框架1

main
wuchang2 2024-11-15 11:57:07 +08:00
parent 08f006ac35
commit e6c30b5574
38 changed files with 891 additions and 24 deletions

View File

@ -1,10 +1,9 @@
package com.muyu.product.domain; package com.muyu.product.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;

View File

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.product.domain.model.CategoryInfoSaveModel; import com.muyu.product.domain.model.CategoryInfoSaveModel;
import com.muyu.product.domain.req.CategoryInfoUpdReq;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -92,13 +93,13 @@ public class CategoryInfo extends TreeEntity {
/** /**
* *
*/ */
public static CategoryInfo editBuild(Long id, CategoryInfoEditReq categoryInfoEditReq){ public static CategoryInfo editBuild(Long id, CategoryInfoUpdReq categoryInfoUpdReq){
return CategoryInfo.builder() return CategoryInfo.builder()
.id(id) .id(id)
.name(categoryInfoEditReq.getName()) .name(categoryInfoUpdReq.getName())
.image(categoryInfoEditReq.getImage()) .image(categoryInfoUpdReq.getImage())
.start(categoryInfoEditReq.getStart()) .start(categoryInfoUpdReq.getStart())
.introduction(categoryInfoEditReq.getIntroduction()) .introduction(categoryInfoUpdReq.getIntroduction())
.build(); .build();
} }

View File

@ -74,11 +74,11 @@ public class RuleInfo extends BaseEntity {
/** /**
* *
*/ */
public static RuleInfo editBuild(Long id, RuleInfoEditReq ruleInfoEditReq){ public static RuleInfo editBuild(Long id, RuleInfoUpdRes ruleInfoUpdRes){
return RuleInfo.builder() return RuleInfo.builder()
.id(id) .id(id)
.name(ruleInfoEditReq.getName()) .name(ruleInfoUpdRes.getName())
.status(ruleInfoEditReq.getStatus()) .status(ruleInfoUpdRes.getStatus())
.build(); .build();
} }

View File

@ -0,0 +1,33 @@
package com.muyu.product.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel;
import com.muyu.product.domain.model.RuleAttrAddModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.List;
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class RuleInfoUpdRes {
/** 主键 */
private Long id;
/** 规格名称 */
private String name;
/** 规格状态 */
private String status;
private String remark;
private List<RuleAttrAddModel> ruleAttrList;
}

View File

@ -1,6 +1,8 @@
package com.muyu.product.domain.req; package com.muyu.product.domain.req;
import java.util.Date; import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -34,4 +36,6 @@ public class AttributeGroupEditReq extends BaseEntity {
private String states; private String states;
private List<AttributeInfoSaveReq> attributeList;
} }

View File

@ -0,0 +1,50 @@
package com.muyu.product.domain.req;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.List;
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class CategoryInfoUpdReq {
/** 主键 */
private Long id;
/** 品类名称 */
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;
}

View File

@ -1,5 +1,6 @@
package com.muyu.product.domain.req; package com.muyu.product.domain.req;
import com.muyu.product.domain.model.RuleAttrAddModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -8,6 +9,8 @@ import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import com.muyu.common.core.web.domain.BaseEntity; import com.muyu.common.core.web.domain.BaseEntity;
import java.util.List;
/** /**
* rule_info * rule_info
* *

View File

@ -1,4 +1,30 @@
package com.muyu.product.domain.resp; package com.muyu.product.domain.resp;
import com.muyu.product.domain.AttributeInfo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.List;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AttributeGroupUpdResp { public class AttributeGroupUpdResp {
/** 属性组编号 */
private Long id;
/** 组名称 */
private String name;
/** 状态 */
private String states;
/**
*
*/
private List<AttributeInfo> attributeList;
} }

View File

@ -5,6 +5,7 @@ import javax.servlet.http.HttpServletResponse;
import com.muyu.product.domain.model.AttributeGroupSaveModel; import com.muyu.product.domain.model.AttributeGroupSaveModel;
import com.muyu.product.domain.resp.AttributeGroupPageResp; import com.muyu.product.domain.resp.AttributeGroupPageResp;
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -74,8 +75,8 @@ public class AttributeGroupController extends BaseController {
@RequiresPermissions("product:attributeGroup:query") @RequiresPermissions("product:attributeGroup:query")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<AttributeGroup> getInfo(@PathVariable("id") Long id) { public Result<AttributeGroupUpdResp> getInfo(@PathVariable("id") Long id) {
return Result.success(attributeGroupService.getById(id)); return Result.success(attributeGroupService.getUpdById(id));
} }
/** /**
@ -99,7 +100,9 @@ public class AttributeGroupController extends BaseController {
@PutMapping("/{id}") @PutMapping("/{id}")
@ApiOperation("修改属性组") @ApiOperation("修改属性组")
public Result<String> edit(@PathVariable Long id, @RequestBody AttributeGroupEditReq attributeGroupEditReq) { public Result<String> edit(@PathVariable Long id, @RequestBody AttributeGroupEditReq attributeGroupEditReq) {
attributeGroupService.updAs(id,attributeGroupEditReq);
return toAjax(attributeGroupService.updateById(AttributeGroup.editBuild(id,attributeGroupEditReq))); return toAjax(attributeGroupService.updateById(AttributeGroup.editBuild(id,attributeGroupEditReq)));
} }
/** /**

View File

@ -9,6 +9,7 @@ import com.muyu.product.domain.AttributeGroup;
import com.muyu.product.domain.AttributeInfo; import com.muyu.product.domain.AttributeInfo;
import com.muyu.product.domain.BrandInfo; import com.muyu.product.domain.BrandInfo;
import com.muyu.product.domain.model.CategoryInfoSaveModel; import com.muyu.product.domain.model.CategoryInfoSaveModel;
import com.muyu.product.domain.req.CategoryInfoUpdReq;
import com.muyu.product.domain.resp.CategoryCommonElementResp; import com.muyu.product.domain.resp.CategoryCommonElementResp;
import com.muyu.product.domain.resp.CategoryParentCommonElementResp; import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
import io.swagger.annotations.*; import io.swagger.annotations.*;
@ -77,8 +78,8 @@ public class CategoryInfoController extends BaseController {
@RequiresPermissions("product:category:query") @RequiresPermissions("product:category:query")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<CategoryInfo> getInfo(@PathVariable("id") Long id) { public Result<CategoryInfoUpdReq> getInfo(@PathVariable("id") Long id) {
return Result.success(categoryInfoService.getById(id)); return Result.success(categoryInfoService.getUpdById(id));
} }
/** /**
@ -112,8 +113,9 @@ public class CategoryInfoController extends BaseController {
@Log(title = "品类信息", businessType = BusinessType.UPDATE) @Log(title = "品类信息", businessType = BusinessType.UPDATE)
@PutMapping("/{id}") @PutMapping("/{id}")
@ApiOperation("修改品类信息") @ApiOperation("修改品类信息")
public Result<String> edit(@PathVariable Long id, @RequestBody CategoryInfoEditReq categoryInfoEditReq) { public Result<String> edit(@PathVariable Long id, @RequestBody CategoryInfoUpdReq categoryInfoUpdReq) {
return toAjax(categoryInfoService.updateById(CategoryInfo.editBuild(id,categoryInfoEditReq))); Boolean b= categoryInfoService.updId(id,categoryInfoUpdReq);
return toAjax(categoryInfoService.updateById(CategoryInfo.editBuild(id,categoryInfoUpdReq)));
} }
/** /**
@ -124,8 +126,9 @@ public class CategoryInfoController extends BaseController {
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
@ApiOperation("删除品类信息") @ApiOperation("删除品类信息")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4") @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result<String> remove(@PathVariable List<Long> ids) { public Result<String> remove(@PathVariable Long ids) {
return toAjax(categoryInfoService.removeBatchByIds(ids)); Result result = categoryInfoService.del(ids);
return result;
} }
/** /**

View File

@ -4,6 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.muyu.common.core.text.Convert; import com.muyu.common.core.text.Convert;
import com.muyu.product.domain.RuleInfoUpdRes;
import com.muyu.product.domain.model.RuleInfoAddModel; import com.muyu.product.domain.model.RuleInfoAddModel;
import com.muyu.product.domain.resp.RuleInfoResp; import com.muyu.product.domain.resp.RuleInfoResp;
import io.swagger.annotations.*; import io.swagger.annotations.*;
@ -77,8 +78,8 @@ public class RuleInfoController extends BaseController {
@RequiresPermissions("product:rule:query") @RequiresPermissions("product:rule:query")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class) @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<RuleInfo> getInfo(@PathVariable("id") Long id) { public Result<RuleInfoUpdRes> getInfo(@PathVariable("id") Long id) {
return Result.success(ruleInfoService.getById(id)); return Result.success(ruleInfoService.getByRuleId(id));
} }
/** /**
@ -99,8 +100,9 @@ public class RuleInfoController extends BaseController {
@Log(title = "商品规格", businessType = BusinessType.UPDATE) @Log(title = "商品规格", businessType = BusinessType.UPDATE)
@PutMapping("/{id}") @PutMapping("/{id}")
@ApiOperation("修改商品规格") @ApiOperation("修改商品规格")
public Result<String> edit(@PathVariable Long id, @RequestBody RuleInfoEditReq ruleInfoEditReq) { public Result<String> edit(@PathVariable Long id, @RequestBody RuleInfoUpdRes ruleInfoUpdRes) {
return toAjax(ruleInfoService.updateById(RuleInfo.editBuild(id,ruleInfoEditReq))); ruleInfoService.updRuleId(id,ruleInfoUpdRes);
return toAjax(ruleInfoService.updateById(RuleInfo.editBuild(id,ruleInfoUpdRes)));
} }
/** /**

View File

@ -3,6 +3,8 @@ package com.muyu.product.mapper;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.product.domain.AsCategoryAttributeGroup; import com.muyu.product.domain.AsCategoryAttributeGroup;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* Mapper * Mapper
@ -10,6 +12,8 @@ import com.muyu.product.domain.AsCategoryAttributeGroup;
* @author DongZeLiang * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Mapper
public interface AsCategoryAttributeGroupMapper extends BaseMapper<AsCategoryAttributeGroup> { public interface AsCategoryAttributeGroupMapper extends BaseMapper<AsCategoryAttributeGroup> {
void addAttributeGroup(@Param("id") Long id, @Param("attributeGroupId") Long attributeGroupId);
} }

View File

@ -1,8 +1,9 @@
package com.muyu.product.mapper; package com.muyu.product.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.product.domain.AsCategoryAttribute; import com.muyu.product.domain.AsCategoryAttribute;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* Mapper * Mapper
@ -10,6 +11,7 @@ import com.muyu.product.domain.AsCategoryAttribute;
* @author DongZeLiang * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Mapper
public interface AsCategoryAttributeMapper extends BaseMapper<AsCategoryAttribute> { public interface AsCategoryAttributeMapper extends BaseMapper<AsCategoryAttribute> {
void addAttribute(@Param("id") Long id, @Param("attributeId") Long attributeId);
} }

View File

@ -3,6 +3,8 @@ package com.muyu.product.mapper;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.product.domain.AsCategoryBrand; import com.muyu.product.domain.AsCategoryBrand;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* Mapper * Mapper
@ -10,6 +12,8 @@ import com.muyu.product.domain.AsCategoryBrand;
* @author DongZeLiang * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Mapper
public interface AsCategoryBrandMapper extends BaseMapper<AsCategoryBrand> { public interface AsCategoryBrandMapper extends BaseMapper<AsCategoryBrand> {
void addGoryBrand(@Param("id") Long id, @Param("brandId") Long brandId);
} }

View File

@ -0,0 +1,22 @@
package com.muyu.product.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface AttributeGroupUpdMapper {
/**
*
* @param id
* @return
*/
Integer del(@Param("id") Long id);
/**
*
* @param id
* @param ids
*/
void attriAddGroup(@Param("id") Long id, @Param("ids") Long ids);
}

View File

@ -3,6 +3,10 @@ package com.muyu.product.mapper;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.product.domain.CategoryInfo; import com.muyu.product.domain.CategoryInfo;
import com.muyu.product.domain.ProjectInfo;
import com.muyu.product.domain.req.CategoryInfoUpdReq;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/** /**
* Mapper * Mapper
@ -10,6 +14,11 @@ import com.muyu.product.domain.CategoryInfo;
* @author DongZeLiang * @author DongZeLiang
* @date 2024-02-27 * @date 2024-02-27
*/ */
@Mapper
public interface CategoryInfoMapper extends BaseMapper<CategoryInfo> { public interface CategoryInfoMapper extends BaseMapper<CategoryInfo> {
Boolean updById(@Param("id") Long id, @Param("categoryInfoUpdReq") CategoryInfoUpdReq categoryInfoUpdReq);
List<ProjectInfo> selectProjectInfoById(@Param("ids") Long ids);
} }

View File

@ -0,0 +1,12 @@
package com.muyu.product.mapper;
import com.muyu.product.domain.RuleInfoUpdRes;
import com.muyu.product.domain.req.RuleInfoEditReq;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface RuleInfoUpdMapper {
int del(@Param("id") Long id);
void addRuleInfo(@Param("id") Long id, @Param("name") String name, @Param("attrValue") String attrValue);
}

View File

@ -7,7 +7,9 @@ import com.muyu.product.domain.AttributeGroup;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.product.domain.AttributeInfo; import com.muyu.product.domain.AttributeInfo;
import com.muyu.product.domain.model.AttributeGroupSaveModel; import com.muyu.product.domain.model.AttributeGroupSaveModel;
import com.muyu.product.domain.req.AttributeGroupEditReq;
import com.muyu.product.domain.resp.AttributeGroupPageResp; import com.muyu.product.domain.resp.AttributeGroupPageResp;
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
/** /**
* Service * Service
@ -39,4 +41,26 @@ public interface AttributeGroupService extends IService<AttributeGroup> {
*/ */
public Boolean save(AttributeGroupSaveModel attributeGroupSaveModel); public Boolean save(AttributeGroupSaveModel attributeGroupSaveModel);
/**
* 西
* @param id
* @return
*/
AttributeGroupUpdResp getUpdById(Long id);
/**
*
* @param attributeGroupEditReq
* @return
*/
void updAs(Long id, AttributeGroupEditReq attributeGroupEditReq);
//
// /**
// * 修改属性组数据 自己改的
// * @param attributeGroup
// * @return
// */
// AttributeGroupUpdResp updByids(AttributeGroup attributeGroup);
} }

View File

@ -2,12 +2,14 @@ package com.muyu.product.service;
import java.util.List; import java.util.List;
import com.muyu.common.core.domain.Result;
import com.muyu.product.domain.AttributeGroup; import com.muyu.product.domain.AttributeGroup;
import com.muyu.product.domain.AttributeInfo; import com.muyu.product.domain.AttributeInfo;
import com.muyu.product.domain.BrandInfo; import com.muyu.product.domain.BrandInfo;
import com.muyu.product.domain.CategoryInfo; import com.muyu.product.domain.CategoryInfo;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.product.domain.model.CategoryInfoSaveModel; import com.muyu.product.domain.model.CategoryInfoSaveModel;
import com.muyu.product.domain.req.CategoryInfoUpdReq;
import com.muyu.product.domain.resp.CategoryCommonElementResp; import com.muyu.product.domain.resp.CategoryCommonElementResp;
import com.muyu.product.domain.resp.CategoryParentCommonElementResp; import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
@ -69,4 +71,11 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId); CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId);
public <T, AS> List<T> getCommon (Long categoryId, IService<AS> iService, IService<T> bsiService); public <T, AS> List<T> getCommon (Long categoryId, IService<AS> iService, IService<T> bsiService);
Boolean updId(Long id, CategoryInfoUpdReq categoryInfoUpdReq);
Result del(Long ids);
CategoryInfoUpdReq getUpdById(Long id);
} }

View File

@ -5,7 +5,9 @@ import java.util.List;
import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.product.domain.RuleInfo; import com.muyu.product.domain.RuleInfo;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.product.domain.RuleInfoUpdRes;
import com.muyu.product.domain.model.RuleInfoAddModel; import com.muyu.product.domain.model.RuleInfoAddModel;
import com.muyu.product.domain.req.RuleInfoEditReq;
import com.muyu.product.domain.req.RuleInfoQueryReq; import com.muyu.product.domain.req.RuleInfoQueryReq;
import com.muyu.product.domain.resp.RuleInfoResp; import com.muyu.product.domain.resp.RuleInfoResp;
@ -32,4 +34,8 @@ public interface RuleInfoService extends IService<RuleInfo> {
public boolean save(RuleInfoAddModel ruleInfoAddModel); public boolean save(RuleInfoAddModel ruleInfoAddModel);
TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq); TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq);
RuleInfoUpdRes getByRuleId(Long id);
void updRuleId(Long id, RuleInfoUpdRes ruleInfoUpdRes);
} }

View File

@ -9,8 +9,12 @@ import com.muyu.product.domain.AsAttributeGroup;
import com.muyu.product.domain.AttributeGroup; import com.muyu.product.domain.AttributeGroup;
import com.muyu.product.domain.AttributeInfo; import com.muyu.product.domain.AttributeInfo;
import com.muyu.product.domain.model.AttributeGroupSaveModel; import com.muyu.product.domain.model.AttributeGroupSaveModel;
import com.muyu.product.domain.req.AttributeGroupEditReq;
import com.muyu.product.domain.req.AttributeInfoSaveReq;
import com.muyu.product.domain.resp.AttributeGroupPageResp; import com.muyu.product.domain.resp.AttributeGroupPageResp;
import com.muyu.product.domain.resp.AttributeGroupUpdResp;
import com.muyu.product.mapper.AttributeGroupMapper; import com.muyu.product.mapper.AttributeGroupMapper;
import com.muyu.product.mapper.AttributeGroupUpdMapper;
import com.muyu.product.service.AsAttributeGroupService; import com.muyu.product.service.AsAttributeGroupService;
import com.muyu.product.service.AttributeGroupService; import com.muyu.product.service.AttributeGroupService;
import com.muyu.product.service.AttributeInfoService; import com.muyu.product.service.AttributeInfoService;
@ -39,6 +43,9 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
@Autowired @Autowired
private AttributeInfoService attributeInfoService; private AttributeInfoService attributeInfoService;
@Autowired
private AttributeGroupUpdMapper attributeGroupUpdMapper;
/** /**
* *
* *
@ -107,4 +114,40 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
); );
return save; return save;
} }
/**
* 西
* @param id
* @return
*/
@Override
public AttributeGroupUpdResp getUpdById(Long id) {
AttributeGroup attributeGroup = this.getById(id);
LambdaQueryWrapper<AsAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AsAttributeGroup::getGroupId,id);
List<AsAttributeGroup> asAttributeGroupList = attributeGroupService.list(queryWrapper);
List<Long> list = asAttributeGroupList.stream().map(AsAttributeGroup::getAttributeId).toList();
List<AttributeInfo> attributeInfos = attributeInfoService.listByIds(list);
return AttributeGroupUpdResp.builder()
.id(attributeGroup.getId())
.name(attributeGroup.getName())
.states(attributeGroup.getStates())
.attributeList(attributeInfos).build();
}
@Override
public void updAs(Long id, AttributeGroupEditReq attributeGroupEditReq) {
attributeGroupUpdMapper.del(id);
List<AttributeInfoSaveReq> attributeList = attributeGroupEditReq.getAttributeList();
for (AttributeInfoSaveReq attributeInfoSaveReq : attributeList) {
attributeGroupUpdMapper.attriAddGroup(id,attributeInfoSaveReq.getId());
}
}
} }

View File

@ -4,14 +4,19 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.ObjUtils; import com.muyu.common.core.utils.ObjUtils;
import com.muyu.product.domain.*; import com.muyu.product.domain.*;
import com.muyu.product.domain.base.CategoryBase; import com.muyu.product.domain.base.CategoryBase;
import com.muyu.product.domain.model.CategoryInfoSaveModel; import com.muyu.product.domain.model.CategoryInfoSaveModel;
import com.muyu.product.domain.model.TemplateAttributeGroupModel; import com.muyu.product.domain.model.TemplateAttributeGroupModel;
import com.muyu.product.domain.model.TemplateAttributeModel; import com.muyu.product.domain.model.TemplateAttributeModel;
import com.muyu.product.domain.req.CategoryInfoUpdReq;
import com.muyu.product.domain.resp.CategoryCommonElementResp; import com.muyu.product.domain.resp.CategoryCommonElementResp;
import com.muyu.product.domain.resp.CategoryParentCommonElementResp; import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
import com.muyu.product.mapper.AsCategoryAttributeGroupMapper;
import com.muyu.product.mapper.AsCategoryAttributeMapper;
import com.muyu.product.mapper.AsCategoryBrandMapper;
import com.muyu.product.mapper.CategoryInfoMapper; import com.muyu.product.mapper.CategoryInfoMapper;
import com.muyu.product.service.*; import com.muyu.product.service.*;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -58,6 +63,18 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
@Autowired @Autowired
private AttributeGroupService attributeGroupService; private AttributeGroupService attributeGroupService;
@Autowired
private CategoryInfoMapper categoryInfoMapper;
@Autowired
private AsCategoryAttributeGroupMapper asCategoryAttributeGroupMapper;
@Autowired
private AsCategoryBrandMapper asCategoryBrandMapper;
@Autowired
private AsCategoryAttributeMapper asCategoryAttributeMapper;
/** /**
* *
* *
@ -270,6 +287,88 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
return list; return list;
} }
@Override
public Boolean updId(Long id, CategoryInfoUpdReq categoryInfoUpdReq) {
Boolean b = categoryInfoMapper.updById(id, categoryInfoUpdReq);
asCategoryAttributeGroupService.remove(new LambdaQueryWrapper<AsCategoryAttributeGroup>().eq(AsCategoryAttributeGroup::getCategoryId,id));
asCategoryAttributeService.remove(new LambdaQueryWrapper<AsCategoryAttribute>().eq(AsCategoryAttribute::getCategoryId,id));
asCategoryBrandService.remove(new LambdaQueryWrapper<AsCategoryBrand>().eq(AsCategoryBrand::getCategoryId,id));
if (null!=categoryInfoUpdReq.getBrandIdList()){
categoryInfoUpdReq.getBrandIdList().stream().forEach(brandId->{
asCategoryBrandMapper.addGoryBrand(id,brandId);
});
}
if (null!=categoryInfoUpdReq.getAttributeGroupIdList()){
categoryInfoUpdReq.getAttributeGroupIdList().stream().forEach(attributeGroupId->{
asCategoryAttributeGroupMapper.addAttributeGroup(id,attributeGroupId);
});
}
if (null!=categoryInfoUpdReq.getAttributeIdList()){
categoryInfoUpdReq.getAttributeIdList().stream().forEach(attributeId->{
asCategoryAttributeMapper.addAttribute(id,attributeId);
});
}
return b;
}
@Override
public Result del(Long ids) {
//判断有没有子集
QueryWrapper<CategoryInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("parent_id",ids);
List<CategoryInfo> categoryInfos = categoryInfoMapper.selectList(queryWrapper);
if(0 == categoryInfos.size()){//无子级
//是否有商品关联关系
List<ProjectInfo> list = categoryInfoMapper.selectProjectInfoById(ids); // 商品信息对象 project_info
if(0 == list.size()) {//无商品关联
categoryInfoMapper.delete(new LambdaQueryWrapper<CategoryInfo>().eq(CategoryInfo::getId, ids));
return Result.success("删除成功");
}
return Result.error("有商品关联关系无法删除....");
}
return Result.error("有子级无法删除.....");
}
@Override
public CategoryInfoUpdReq getUpdById(Long id) {
CategoryInfo byId = this.getById(id);
LambdaQueryWrapper<AsCategoryAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AsCategoryAttributeGroup::getCategoryId,id);
List<AsCategoryAttributeGroup> attributeGroupList = asCategoryAttributeGroupService.list(queryWrapper);
List<Long> list = attributeGroupList.stream().map(AsCategoryAttributeGroup::getAttributeGroupId).toList();
LambdaQueryWrapper<AsCategoryAttribute> attributeLambdaQueryWrapper = new LambdaQueryWrapper<>();
attributeLambdaQueryWrapper.eq(AsCategoryAttribute::getCategoryId,id);
List<AsCategoryAttribute> attributeList = asCategoryAttributeService.list(attributeLambdaQueryWrapper);
List<Long> list1 = attributeList.stream().map(AsCategoryAttribute::getAttributeId).toList();
LambdaQueryWrapper<AsCategoryBrand> asCategoryBrandLambdaQueryWrapper = new LambdaQueryWrapper<>();
asCategoryBrandLambdaQueryWrapper.eq(AsCategoryBrand::getCategoryId,id);
List<AsCategoryBrand> brandList = asCategoryBrandService.list(asCategoryBrandLambdaQueryWrapper);
List<Long> list2 = brandList.stream().map(AsCategoryBrand::getBrandId).toList();
return CategoryInfoUpdReq.builder()
.id(byId.getId())
.name(byId.getName())
.start(byId.getStart())
.attributeGroupIdList(list)
.attributeIdList(list1)
.brandIdList(list2)
.build();
}
/** /**
* ID * ID
* *

View File

@ -13,10 +13,14 @@ import com.muyu.common.core.utils.ObjUtils;
import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.product.domain.RuleAttrInfo; import com.muyu.product.domain.RuleAttrInfo;
import com.muyu.product.domain.RuleInfoUpdRes;
import com.muyu.product.domain.model.RuleAttrAddModel; import com.muyu.product.domain.model.RuleAttrAddModel;
import com.muyu.product.domain.model.RuleInfoAddModel; import com.muyu.product.domain.model.RuleInfoAddModel;
import com.muyu.product.domain.req.RuleInfoEditReq;
import com.muyu.product.domain.req.RuleInfoQueryReq; import com.muyu.product.domain.req.RuleInfoQueryReq;
import com.muyu.product.domain.resp.RuleInfoResp; import com.muyu.product.domain.resp.RuleInfoResp;
import com.muyu.product.mapper.RuleInfoUpdMapper;
import com.muyu.product.service.RuleAttrInfoService; import com.muyu.product.service.RuleAttrInfoService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -39,6 +43,9 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
@Autowired @Autowired
private RuleAttrInfoService ruleAttrInfoService; private RuleAttrInfoService ruleAttrInfoService;
@Autowired
private RuleInfoUpdMapper ruleInfoUpdMapper;
/** /**
* *
@ -107,4 +114,29 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
.total(isPage ? new PageInfo<>(list).getTotal() : 0) .total(isPage ? new PageInfo<>(list).getTotal() : 0)
.build(); .build();
} }
@Override
public RuleInfoUpdRes getByRuleId(Long id) {
RuleInfo byId = this.getById(id);// 商品规格对象 rule_info
LambdaQueryWrapper<RuleAttrInfo> queryWrapper = new LambdaQueryWrapper<>();//创建构造器对象 规格详情对象 rule_attr_info
queryWrapper.eq(RuleAttrInfo::getRuleId,id);//
List<RuleAttrInfo> list = ruleAttrInfoService.list(queryWrapper);
return RuleInfoUpdRes.builder()
.id(byId.getId())
.name(byId.getName())
.remark(byId.getRemark())
.ruleAttrList(list.stream().map(RuleAttrAddModel::infoBuild).toList()).build();
}
@Override
public void updRuleId(Long id, RuleInfoUpdRes ruleInfoUpdRes) {
ruleInfoUpdMapper.del(id);
List<RuleAttrAddModel> ruleAttrList = ruleInfoUpdRes.getRuleAttrList();
for (RuleAttrAddModel ruleAttrAddModel : ruleAttrList) {
List<String> valueList = ruleAttrAddModel.getValueList();
String join = String.join(",",valueList);
ruleInfoUpdMapper.addRuleInfo(id,ruleAttrAddModel.getName(),join);
}
}
} }

View File

@ -18,4 +18,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectAsCategoryAttributeGroupVo"> <sql id="selectAsCategoryAttributeGroupVo">
select id, category_id, attribute_group_id, remark, create_by, create_time, update_by, update_time from as_category_attribute_group select id, category_id, attribute_group_id, remark, create_by, create_time, update_by, update_time from as_category_attribute_group
</sql> </sql>
<insert id="addAttributeGroup">
insert into as_category_attribute(category_id,attribute_id) values
(#{id},#{attributeGroupId})
</insert>
</mapper> </mapper>

View File

@ -18,4 +18,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectAsCategoryAttributeVo"> <sql id="selectAsCategoryAttributeVo">
select id, category_id, attribute_id, remark, create_by, create_time, update_by, update_time from as_category_attribute select id, category_id, attribute_id, remark, create_by, create_time, update_by, update_time from as_category_attribute
</sql> </sql>
<insert id="addAttribute">
insert into as_category_attribute(category_id, attribute_id) values
(#{id},#{attributeId})
</insert>
</mapper> </mapper>

View File

@ -18,4 +18,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectAsCategoryBrandVo"> <sql id="selectAsCategoryBrandVo">
select id, category_id, brand_id, remark, create_by, create_time, update_by, update_time from as_category_brand select id, category_id, brand_id, remark, create_by, create_time, update_by, update_time from as_category_brand
</sql> </sql>
<insert id="addGoryBrand">
insert into as_category_brand(category_id,brand_id) values
(#{id},#{brandId})
</insert>
</mapper> </mapper>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.product.mapper.AttributeGroupUpdMapper">
<insert id="attriAddGroup">
insert into as_attribute_group(group_id,attribute_id) values
(#{id},#{ids})
</insert>
<delete id="del">
delete from as_attribute_group where group_id=#{id}
</delete>
</mapper>

View File

@ -21,4 +21,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectCategoryInfoVo"> <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, parent_id, start, introduction, remark, create_by, create_time, update_by, update_time from category_info
</sql> </sql>
<update id="updById">
UPDATE category_info SET `name` =#{categoryInfoUpdReq.name} , `start` = #{categoryInfoUpdReq.start}, `introduction` = #{categoryInfoUpdReq.introduction} WHERE `id` = #{id};
</update>
<select id="selectProjectInfoById" resultType="com.muyu.product.domain.ProjectInfo">
select * from project_info where parent_type=#{ids}
</select>
</mapper> </mapper>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.product.mapper.RuleInfoUpdMapper">
<insert id="addRuleInfo">
INSERT INTO rule_attr_info ( rule_id,name,attr_value,create_by,create_time,update_by,update_time) VALUES
(#{id},#{name},#{attrValue},"admin",now(),"admin",now());
</insert>
<delete id="del">
delete from rule_attr_info where rule_id=#{id}
</delete>
</mapper>

View File

@ -0,0 +1,112 @@
package com.muyu.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.muyu.system.domain.Product;
import com.muyu.system.domain.req.ProductEditReq;
import com.muyu.system.domain.req.ProductQueryReq;
import com.muyu.system.domain.req.ProductSaveReq;
import com.muyu.system.service.ProductService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author DongZeLiang
* @date 2024-11-14
*/
@Api(tags = "【请填写功能名称】")
@RestController
@RequestMapping("/product")
public class ProductController extends BaseController {
@Autowired
private ProductService productService;
/**
*
*/
@ApiOperation("获取【请填写功能名称】列表")
@RequiresPermissions("product:product:list")
@GetMapping("/list")
public Result<TableDataInfo<Product>> list(ProductQueryReq productQueryReq) {
startPage();
List<Product> list = productService.list(Product.queryBuild(productQueryReq));
return getDataTable(list);
}
/**
*
*/
@ApiOperation("导出【请填写功能名称】列表")
@RequiresPermissions("product:product:export")
@Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, Product product) {
List<Product> list = productService.list(product);
ExcelUtil<Product> util = new ExcelUtil<Product>(Product.class);
util.exportExcel(response, list, "【请填写功能名称】数据");
}
/**
*
*/
@ApiOperation("获取【请填写功能名称】详细信息")
@RequiresPermissions("product:product:query")
@GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<Product> getInfo(@PathVariable("id") Long id) {
return Result.success(productService.getById(id));
}
/**
*
*/
@RequiresPermissions("product:product:add")
@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("新增【请填写功能名称】")
public Result<String> add(@RequestBody ProductSaveReq productSaveReq) {
return toAjax(productService.save(Product.saveBuild(productSaveReq)));
}
/**
*
*/
@RequiresPermissions("product:product:edit")
@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
@PutMapping("/{id}")
@ApiOperation("修改【请填写功能名称】")
public Result<String> edit(@PathVariable Long id, @RequestBody ProductEditReq productEditReq) {
return toAjax(productService.updateById(Product.editBuild(id,productEditReq)));
}
/**
*
*/
@RequiresPermissions("product:product:remove")
@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
@ApiOperation("删除【请填写功能名称】")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
public Result<String> remove(@PathVariable List<Long> ids) {
return toAjax(productService.removeBatchByIds(ids));
}
}

View File

@ -0,0 +1,91 @@
package com.muyu.system.domain;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.system.domain.req.ProductEditReq;
import com.muyu.system.domain.req.ProductQueryReq;
import com.muyu.system.domain.req.ProductSaveReq;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* product
*
* @author DongZeLiang
* @date 2024-11-14
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("product")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Product", description = "【请填写功能名称】")
public class Product extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(name = "主键", value = "主键")
private Long id;
/** 商品名称 */
@Excel(name = "商品名称")
@ApiModelProperty(name = "商品名称", value = "商品名称")
private String name;
/** 原价 */
@Excel(name = "原价")
@ApiModelProperty(name = "原价", value = "原价")
private BigDecimal price;
/** 拼团价格 */
@Excel(name = "拼团价格")
@ApiModelProperty(name = "拼团价格", value = "拼团价格")
private BigDecimal groupPrice;
/**
*
*/
public static Product queryBuild( ProductQueryReq productQueryReq){
return Product.builder()
.name(productQueryReq.getName())
.price(productQueryReq.getPrice())
.groupPrice(productQueryReq.getGroupPrice())
.build();
}
/**
*
*/
public static Product saveBuild(ProductSaveReq productSaveReq){
return Product.builder()
.name(productSaveReq.getName())
.price(productSaveReq.getPrice())
.groupPrice(productSaveReq.getGroupPrice())
.build();
}
/**
*
*/
public static Product editBuild(Long id, ProductEditReq productEditReq){
return Product.builder()
.id(id)
.name(productEditReq.getName())
.price(productEditReq.getPrice())
.groupPrice(productEditReq.getGroupPrice())
.build();
}
}

View File

@ -0,0 +1,39 @@
package com.muyu.system.domain.req;
import java.math.BigDecimal;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* product
*
* @author DongZeLiang
* @date 2024-11-14
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "ProductEditReq", description = "【请填写功能名称】")
public class ProductEditReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 商品名称 */
@ApiModelProperty(name = "商品名称", value = "商品名称")
private String name;
/** 原价 */
@ApiModelProperty(name = "原价", value = "原价")
private BigDecimal price;
/** 拼团价格 */
@ApiModelProperty(name = "拼团价格", value = "拼团价格")
private BigDecimal groupPrice;
}

View File

@ -0,0 +1,39 @@
package com.muyu.system.domain.req;
import java.math.BigDecimal;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* product
*
* @author DongZeLiang
* @date 2024-11-14
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "ProductQueryReq", description = "【请填写功能名称】")
public class ProductQueryReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 商品名称 */
@ApiModelProperty(name = "商品名称", value = "商品名称")
private String name;
/** 原价 */
@ApiModelProperty(name = "原价", value = "原价")
private BigDecimal price;
/** 拼团价格 */
@ApiModelProperty(name = "拼团价格", value = "拼团价格")
private BigDecimal groupPrice;
}

View File

@ -0,0 +1,47 @@
package com.muyu.system.domain.req;
import java.math.BigDecimal;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.web.domain.BaseEntity;
/**
* product
*
* @author DongZeLiang
* @date 2024-11-14
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "ProductSaveReq", description = "【请填写功能名称】")
public class ProductSaveReq extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 主键 */
@ApiModelProperty(name = "主键", value = "主键")
private Long id;
/** 商品名称 */
@ApiModelProperty(name = "商品名称", value = "商品名称")
private String name;
/** 原价 */
@ApiModelProperty(name = "原价", value = "原价")
private BigDecimal price;
/** 拼团价格 */
@ApiModelProperty(name = "拼团价格", value = "拼团价格")
private BigDecimal groupPrice;
}

View File

@ -0,0 +1,16 @@
package com.muyu.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.system.domain.Product;
/**
* Mapper
*
* @author DongZeLiang
* @date 2024-11-14
*/
public interface ProductMapper extends BaseMapper<Product> {
}

View File

@ -0,0 +1,23 @@
package com.muyu.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.system.domain.Product;
/**
* Service
*
* @author DongZeLiang
* @date 2024-11-14
*/
public interface ProductService extends IService<Product> {
/**
*
*
* @param product
* @return
*/
public List<Product> list(Product product);
}

View File

@ -0,0 +1,49 @@
package com.muyu.system.service.impl;
import java.util.List;
import com.muyu.common.core.utils.ObjUtils;
import com.muyu.system.domain.Product;
import com.muyu.system.mapper.ProductMapper;
import com.muyu.system.service.ProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/**
* Service
*
* @author DongZeLiang
* @date 2024-11-14
*/
@Slf4j
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
/**
*
*
* @param product
* @return
*/
@Override
public List<Product> list(Product product) {
LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
if (ObjUtils.notNull(product.getName())){
queryWrapper.like(Product::getName, product.getName());
}
if (ObjUtils.notNull(product.getPrice())){
queryWrapper.eq(Product::getPrice, product.getPrice());
}
if (ObjUtils.notNull(product.getGroupPrice())){
queryWrapper.eq(Product::getGroupPrice, product.getGroupPrice());
}
return list(queryWrapper);
}
}

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.system.mapper.ProductMapper">
<resultMap type="com.muyu.system.domain.Product" id="ProductResult">
<result property="id" column="id" />
<result property="name" column="name" />
<result property="price" column="price" />
<result property="groupPrice" column="group_price" />
</resultMap>
<sql id="selectProductVo">
select id, name, price, group_price from product
</sql>
</mapper>