商品规格的修改
parent
db249fb121
commit
a61f71e52f
|
@ -56,6 +56,7 @@ public class RuleAttrInfo extends BaseEntity {
|
||||||
@ApiModelProperty(name = "规格值", value = "规格值")
|
@ApiModelProperty(name = "规格值", value = "规格值")
|
||||||
private String attrValue;
|
private String attrValue;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询构造器
|
* 查询构造器
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class RuleAttrAddModel extends BaseEntity {
|
||||||
* 规格属性名称
|
* 规格属性名称
|
||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
private String attrValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格属性值集合
|
* 规格属性值集合
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.muyu.product.domain.req;
|
||||||
|
|
||||||
|
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class RuleAttrInfoReq {
|
||||||
|
|
||||||
|
/** 规格名称 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 规格状态 */
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规格属性集合
|
||||||
|
*/
|
||||||
|
private List<RuleAttrAddModel> ruleAttrList;
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
package com.muyu.product.domain.req;
|
package com.muyu.product.domain.req;
|
||||||
|
|
||||||
|
import com.muyu.product.domain.AttributeInfo;
|
||||||
|
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 +10,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
|
||||||
*
|
*
|
||||||
|
@ -30,5 +34,5 @@ public class RuleInfoEditReq extends BaseEntity {
|
||||||
/** 规格状态 */
|
/** 规格状态 */
|
||||||
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
@ApiModelProperty(name = "规格状态", value = "规格状态")
|
||||||
private String status;
|
private String status;
|
||||||
|
private List<RuleAttrAddModel> ruleAttrList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.muyu.product.domain.resp;
|
||||||
|
|
||||||
|
import com.muyu.product.domain.AttributeInfo;
|
||||||
|
import com.muyu.product.domain.RuleAttrInfo;
|
||||||
|
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class RuleGroupUpdResp {
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 规格名称 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 规格状态 */
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 规格属性集合
|
||||||
|
*/
|
||||||
|
private List<RuleAttrInfo> ruleAttrList;
|
||||||
|
}
|
|
@ -5,6 +5,8 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import com.muyu.common.core.text.Convert;
|
import com.muyu.common.core.text.Convert;
|
||||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||||
|
import com.muyu.product.domain.req.RuleAttrInfoReq;
|
||||||
|
import com.muyu.product.domain.resp.RuleGroupUpdResp;
|
||||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -77,8 +79,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<RuleInfoResp> getInfo(@PathVariable("id") Long id) {
|
||||||
return Result.success(ruleInfoService.getById(id));
|
return Result.success(ruleInfoService.getUpdById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,6 +92,7 @@ public class RuleInfoController extends BaseController {
|
||||||
@ApiOperation("新增商品规格")
|
@ApiOperation("新增商品规格")
|
||||||
public Result<String> add(@RequestBody RuleInfoSaveReq ruleInfoSaveReq) {
|
public Result<String> add(@RequestBody RuleInfoSaveReq ruleInfoSaveReq) {
|
||||||
return toAjax(ruleInfoService.save(RuleInfoAddModel.saveReqBuild(ruleInfoSaveReq)));
|
return toAjax(ruleInfoService.save(RuleInfoAddModel.saveReqBuild(ruleInfoSaveReq)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,8 +102,10 @@ 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 RuleAttrInfoReq ruleInfoEditReq) {
|
||||||
return toAjax(ruleInfoService.updateById(RuleInfo.editBuild(id,ruleInfoEditReq)));
|
// return toAjax(ruleInfoService.updateById(RuleInfo.editBuild(id,ruleInfoEditReq)));
|
||||||
|
ruleInfoService.edit(id,ruleInfoEditReq);
|
||||||
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,7 @@ 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.RuleAttrInfo;
|
import com.muyu.product.domain.RuleAttrInfo;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格详情Mapper接口
|
* 规格详情Mapper接口
|
||||||
|
@ -12,4 +13,7 @@ import com.muyu.product.domain.RuleAttrInfo;
|
||||||
*/
|
*/
|
||||||
public interface RuleAttrInfoMapper extends BaseMapper<RuleAttrInfo> {
|
public interface RuleAttrInfoMapper extends BaseMapper<RuleAttrInfo> {
|
||||||
|
|
||||||
|
void shanchu(Long id);
|
||||||
|
|
||||||
|
void insertBatch(@Param("id") Long id, @Param("id1") Long id1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.RuleInfo;
|
import com.muyu.product.domain.RuleInfo;
|
||||||
|
import com.muyu.product.domain.req.RuleAttrInfoReq;
|
||||||
|
import com.muyu.product.domain.req.RuleInfoEditReq;
|
||||||
|
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品规格Mapper接口
|
* 商品规格Mapper接口
|
||||||
|
@ -12,4 +16,11 @@ import com.muyu.product.domain.RuleInfo;
|
||||||
*/
|
*/
|
||||||
public interface RuleInfoMapper extends BaseMapper<RuleInfo> {
|
public interface RuleInfoMapper extends BaseMapper<RuleInfo> {
|
||||||
|
|
||||||
|
RuleInfoResp getRuleById(Long id);
|
||||||
|
|
||||||
|
void updRule(@Param("id") Long id, @Param("ruleInfoEditReq") RuleAttrInfoReq ruleInfoEditReq);
|
||||||
|
|
||||||
|
void deleteRule(Long id);
|
||||||
|
|
||||||
|
void addRuleAttrModel(@Param("id") Long id, @Param("name") String name, @Param("valueData") String substring);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.service;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.muyu.product.domain.RuleAttrInfo;
|
import com.muyu.product.domain.RuleAttrInfo;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 规格详情Service接口
|
* 规格详情Service接口
|
||||||
|
@ -25,4 +26,8 @@ public interface RuleAttrInfoService extends IService<RuleAttrInfo> {
|
||||||
* @return 规格详情集合
|
* @return 规格详情集合
|
||||||
*/
|
*/
|
||||||
List<RuleAttrInfo> getInfoByRuleId (Long ruleId);
|
List<RuleAttrInfo> getInfoByRuleId (Long ruleId);
|
||||||
|
|
||||||
|
void delete(Long id);
|
||||||
|
|
||||||
|
void insertBatch( Long id, Long id1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,16 @@ package com.muyu.product.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
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.model.RuleInfoAddModel;
|
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||||
|
import com.muyu.product.domain.req.RuleAttrInfoReq;
|
||||||
|
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.req.RuleInfoSaveReq;
|
||||||
|
import com.muyu.product.domain.resp.RuleGroupUpdResp;
|
||||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,4 +37,9 @@ 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);
|
||||||
|
|
||||||
|
RuleInfoResp getUpdById(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
void edit(Long id, RuleAttrInfoReq ruleInfoEditReq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||||
|
|
||||||
import com.muyu.common.core.utils.ObjUtils;
|
import com.muyu.common.core.utils.ObjUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.muyu.product.mapper.RuleAttrInfoMapper;
|
import com.muyu.product.mapper.RuleAttrInfoMapper;
|
||||||
import com.muyu.product.domain.RuleAttrInfo;
|
import com.muyu.product.domain.RuleAttrInfo;
|
||||||
|
@ -21,6 +22,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@Service
|
@Service
|
||||||
public class RuleAttrInfoServiceImpl extends ServiceImpl<RuleAttrInfoMapper, RuleAttrInfo> implements RuleAttrInfoService {
|
public class RuleAttrInfoServiceImpl extends ServiceImpl<RuleAttrInfoMapper, RuleAttrInfo> implements RuleAttrInfoService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RuleAttrInfoMapper ruleAttrInfoMapper;
|
||||||
/**
|
/**
|
||||||
* 查询规格详情列表
|
* 查询规格详情列表
|
||||||
*
|
*
|
||||||
|
@ -64,4 +67,14 @@ public class RuleAttrInfoServiceImpl extends ServiceImpl<RuleAttrInfoMapper, Rul
|
||||||
queryWrapper.eq(RuleAttrInfo::getRuleId, ruleId);
|
queryWrapper.eq(RuleAttrInfo::getRuleId, ruleId);
|
||||||
return this.list(queryWrapper);
|
return this.list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(Long id) {
|
||||||
|
ruleAttrInfoMapper.shanchu(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertBatch(Long id, Long id1) {
|
||||||
|
ruleAttrInfoMapper.insertBatch(id,id1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,24 @@
|
||||||
package com.muyu.product.service.impl;
|
package com.muyu.product.service.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import com.github.pagehelper.PageHelper;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.text.Convert;
|
import com.muyu.common.core.text.Convert;
|
||||||
import com.muyu.common.core.utils.ObjUtils;
|
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.AttributeInfo;
|
||||||
import com.muyu.product.domain.RuleAttrInfo;
|
import com.muyu.product.domain.RuleAttrInfo;
|
||||||
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.RuleAttrInfoReq;
|
||||||
|
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.req.RuleInfoSaveReq;
|
||||||
|
import com.muyu.product.domain.resp.RuleGroupUpdResp;
|
||||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||||
import com.muyu.product.service.RuleAttrInfoService;
|
import com.muyu.product.service.RuleAttrInfoService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
@ -26,6 +29,7 @@ import com.muyu.product.domain.RuleInfo;
|
||||||
import com.muyu.product.service.RuleInfoService;
|
import com.muyu.product.service.RuleInfoService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品规格Service业务层处理
|
* 商品规格Service业务层处理
|
||||||
|
@ -35,10 +39,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo> implements RuleInfoService {
|
public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo> implements RuleInfoService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RuleAttrInfoService ruleAttrInfoService;
|
private RuleAttrInfoService ruleAttrInfoService;
|
||||||
|
@Autowired
|
||||||
|
private RuleInfoMapper ruleAttrInfoMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询商品规格列表
|
* 查询商品规格列表
|
||||||
|
@ -51,18 +57,14 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
||||||
LambdaQueryWrapper<RuleInfo> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<RuleInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
|
||||||
if (ObjUtils.notNull(ruleInfo.getName())){
|
if (ObjUtils.notNull(ruleInfo.getName())) {
|
||||||
queryWrapper.like(RuleInfo::getName, ruleInfo.getName());
|
queryWrapper.like(RuleInfo::getName, ruleInfo.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjUtils.notNull(ruleInfo.getStatus())){
|
if (ObjUtils.notNull(ruleInfo.getStatus())) {
|
||||||
queryWrapper.eq(RuleInfo::getStatus, ruleInfo.getStatus());
|
queryWrapper.eq(RuleInfo::getStatus, ruleInfo.getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,11 +72,10 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
||||||
* 添加规格信息
|
* 添加规格信息
|
||||||
*
|
*
|
||||||
* @param ruleInfoAddModel 规格添加模型
|
* @param ruleInfoAddModel 规格添加模型
|
||||||
*
|
|
||||||
* @return 时候成功
|
* @return 时候成功
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean save (RuleInfoAddModel ruleInfoAddModel) {
|
public boolean save(RuleInfoAddModel ruleInfoAddModel) {
|
||||||
RuleInfo ruleInfo = RuleInfo.addModelBuild(ruleInfoAddModel, SecurityUtils::getUsername);
|
RuleInfo ruleInfo = RuleInfo.addModelBuild(ruleInfoAddModel, SecurityUtils::getUsername);
|
||||||
boolean save = this.save(ruleInfo);
|
boolean save = this.save(ruleInfo);
|
||||||
ruleAttrInfoService.saveBatch(
|
ruleAttrInfoService.saveBatch(
|
||||||
|
@ -87,18 +88,19 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询规格信息
|
* 查询规格信息
|
||||||
|
*
|
||||||
* @param ruleInfoQueryReq 规格查询
|
* @param ruleInfoQueryReq 规格查询
|
||||||
* @return 规格信息
|
* @return 规格信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq) {
|
public TableDataInfo<RuleInfoResp> queryList(RuleInfoQueryReq ruleInfoQueryReq) {
|
||||||
List<RuleInfo> list = this.list(RuleInfo.queryBuild(ruleInfoQueryReq));
|
List<RuleInfo> list = this.list(RuleInfo.queryBuild(ruleInfoQueryReq));
|
||||||
List<RuleInfoResp> ruleInfoRespList = list.stream()
|
List<RuleInfoResp> ruleInfoRespList = list.stream()
|
||||||
.map(ruleInfo -> RuleInfoResp.infoBuild(ruleInfo, ruleId -> {
|
.map(ruleInfo -> RuleInfoResp.infoBuild(ruleInfo, ruleId -> {
|
||||||
LambdaQueryWrapper<RuleAttrInfo> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<RuleAttrInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(RuleAttrInfo::getRuleId, ruleId);
|
queryWrapper.eq(RuleAttrInfo::getRuleId, ruleId);
|
||||||
return ruleAttrInfoService.list(queryWrapper).stream().map(RuleAttrAddModel::infoBuild).toList();
|
return ruleAttrInfoService.list(queryWrapper).stream().map(RuleAttrAddModel::infoBuild).toList();
|
||||||
}))
|
}))
|
||||||
.toList();
|
.toList();
|
||||||
boolean isPage = ruleInfoQueryReq.getParams().get("isPage") == null || Convert.toBool(ruleInfoQueryReq.getParams().get("isPage"), true);
|
boolean isPage = ruleInfoQueryReq.getParams().get("isPage") == null || Convert.toBool(ruleInfoQueryReq.getParams().get("isPage"), true);
|
||||||
|
|
||||||
|
@ -107,4 +109,68 @@ 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 RuleInfoResp getUpdById(Long id) {
|
||||||
|
RuleInfoResp getRuleById = ruleAttrInfoMapper.getRuleById(id);
|
||||||
|
List<RuleAttrAddModel> ruleAttrList = getRuleById.getRuleAttrList();
|
||||||
|
for (RuleAttrAddModel ruleAttrAddModel : ruleAttrList) {
|
||||||
|
String attrValue = ruleAttrAddModel.getAttrValue();
|
||||||
|
String[] split = attrValue.split(",");
|
||||||
|
ruleAttrAddModel.setValueList(List.of(split));
|
||||||
|
}
|
||||||
|
return getRuleById;
|
||||||
|
|
||||||
|
// RuleInfo ruleInfo = this.getById(id);
|
||||||
|
//
|
||||||
|
// LambdaQueryWrapper<RuleAttrInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
// queryWrapper.eq(RuleAttrInfo::getRuleId,id);
|
||||||
|
// List<RuleAttrInfo> ruleAttrInfoList = ruleAttrInfoService.list(queryWrapper);
|
||||||
|
// List<Long> longList = ruleAttrInfoList.stream()
|
||||||
|
// .map(RuleAttrInfo::getRuleId)
|
||||||
|
// .toList();
|
||||||
|
// List<RuleAttrInfo> ruleAttrInfos = ruleAttrInfoService.listByIds(longList);
|
||||||
|
// return RuleGroupUpdResp.builder()
|
||||||
|
// .name(ruleInfo.getName())
|
||||||
|
// .id(ruleInfo.getId())
|
||||||
|
// .status(ruleInfo.getStatus())
|
||||||
|
// .ruleAttrList(ruleAttrInfos)
|
||||||
|
// .build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
@Override
|
||||||
|
public void edit(Long id, RuleAttrInfoReq ruleInfoEditReq) {
|
||||||
|
//修改商品规格表
|
||||||
|
ruleAttrInfoMapper.updRule(id,ruleInfoEditReq);
|
||||||
|
//删除中间表
|
||||||
|
ruleAttrInfoMapper.deleteRule(id);
|
||||||
|
//添加规格详情表
|
||||||
|
List<RuleAttrAddModel> ruleAttrList = ruleInfoEditReq.getRuleAttrList();
|
||||||
|
//遍历
|
||||||
|
for (RuleAttrAddModel ruleAttrAddModel : ruleAttrList) {
|
||||||
|
//获取集合
|
||||||
|
List<String> valueList = ruleAttrAddModel.getValueList();
|
||||||
|
//定义值
|
||||||
|
String value="";
|
||||||
|
String valueData=null;
|
||||||
|
//遍历
|
||||||
|
for (String s : valueList) {
|
||||||
|
System.out.println(s);
|
||||||
|
valueData=value+","+s;
|
||||||
|
}
|
||||||
|
System.out.println(valueData);
|
||||||
|
//截取
|
||||||
|
String substring = valueData.substring(1);
|
||||||
|
System.out.println(substring);
|
||||||
|
//添加
|
||||||
|
ruleAttrInfoMapper.addRuleAttrModel(id,ruleAttrAddModel.getName(),substring);
|
||||||
|
}
|
||||||
|
// ruleAttrInfoService.delete(id);
|
||||||
|
// List<AttributeInfo> attributeInfoList = ruleInfoEditReq.getAttributeInfoList();
|
||||||
|
// for (AttributeInfo attributeInfo : attributeInfoList) {
|
||||||
|
// ruleAttrInfoService.insertBatch(id, attributeInfo.getId());
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,4 +19,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<sql id="selectRuleAttrInfoVo">
|
<sql id="selectRuleAttrInfoVo">
|
||||||
select id, rule_id, name, attr_value, remark, create_by, create_time, update_by, update_time from rule_attr_info
|
select id, rule_id, name, attr_value, remark, create_by, create_time, update_by, update_time from rule_attr_info
|
||||||
</sql>
|
</sql>
|
||||||
|
<insert id="insertBatch">
|
||||||
|
insert into rule_attr_info(id,rule_id) values (#{id},#{id1})
|
||||||
|
</insert>
|
||||||
|
<delete id="shanchu">
|
||||||
|
delete from rule_attr_info where id =#{id}
|
||||||
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -15,7 +15,42 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap type="com.muyu.product.domain.resp.RuleInfoResp" id="RuleAttrInfo">
|
||||||
|
<result property="id" column="rid" />
|
||||||
|
<result property="name" column="name" />
|
||||||
|
<collection property="ruleAttrList" ofType="com.muyu.product.domain.model.RuleAttrAddModel">
|
||||||
|
<result property="name" column="rname" />
|
||||||
|
<result property="attrValue" column="attr_value"/>
|
||||||
|
</collection>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectRuleInfoVo">
|
<sql id="selectRuleInfoVo">
|
||||||
select id, name, status, remark, create_by, create_time, update_by, update_time from rule_info
|
select id, name, status, remark, create_by, create_time, update_by, update_time from rule_info
|
||||||
</sql>
|
</sql>
|
||||||
|
<insert id="addRuleAttrModel">
|
||||||
|
INSERT INTO rule_attr_info ( `rule_id`, `name`, `attr_value`,create_by, `create_time`)
|
||||||
|
VALUES ( #{id},#{name}, #{valueData},'admin',now());
|
||||||
|
</insert>
|
||||||
|
<update id="updRule">
|
||||||
|
UPDATE `rule_info`
|
||||||
|
SET `name` = #{ruleInfoEditReq.name},
|
||||||
|
`status` = #{ruleInfoEditReq.status},
|
||||||
|
`update_time` = now()
|
||||||
|
WHERE
|
||||||
|
`id` = #{id}
|
||||||
|
</update>
|
||||||
|
<delete id="deleteRule">
|
||||||
|
delete from rule_attr_info where rule_id=#{id}
|
||||||
|
</delete>
|
||||||
|
<select id="getRuleById" resultMap="RuleAttrInfo">
|
||||||
|
SELECT
|
||||||
|
rule_info.`id` AS rid,
|
||||||
|
rule_info.`name`,
|
||||||
|
rule_attr_info.`name` AS rname,
|
||||||
|
attr_value
|
||||||
|
FROM
|
||||||
|
rule_info
|
||||||
|
INNER JOIN rule_attr_info ON rule_info.id = rule_attr_info.rule_id
|
||||||
|
WHERE rule_info.`id`=#{id}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue