Merge branch 'master' of https://gitee.com/beijing_hongye_huicheng/lilishop
This commit is contained in:
commit
8a10382787
@ -89,8 +89,8 @@ public class GoodsBuyerController {
|
||||
Map<String, Object> map = goodsSkuService.getGoodsSkuDetail(goodsId, skuId);
|
||||
return ResultUtil.data(map);
|
||||
} catch (ServiceException se) {
|
||||
log.error(se.getMsg(), se);
|
||||
return ResultUtil.error(se.getResultCode().code(), se.getResultCode().message());
|
||||
log.info(se.getMsg(), se);
|
||||
throw se;
|
||||
} catch (Exception e) {
|
||||
log.error(ResultCode.GOODS_ERROR.message(), e);
|
||||
return ResultUtil.error(ResultCode.GOODS_ERROR);
|
||||
|
@ -56,7 +56,7 @@ public class CartController {
|
||||
return ResultUtil.success();
|
||||
} catch (ServiceException se) {
|
||||
log.info(se.getMsg(), se);
|
||||
return ResultUtil.error(se.getResultCode().code(), se.getResultCode().message());
|
||||
throw se;
|
||||
} catch (Exception e) {
|
||||
log.error(ResultCode.CART_ERROR.message(), e);
|
||||
throw new ServiceException(ResultCode.CART_ERROR);
|
||||
@ -161,7 +161,7 @@ public class CartController {
|
||||
return ResultUtil.data(this.cartService.getCheckedTradeDTO(CartTypeEnum.valueOf(way)));
|
||||
} catch (ServiceException se) {
|
||||
log.error(se.getMsg(), se);
|
||||
return ResultUtil.error(se.getResultCode().code(), se.getResultCode().message());
|
||||
throw se;
|
||||
} catch (Exception e) {
|
||||
log.error(ResultCode.CART_ERROR.message(), e);
|
||||
throw new ServiceException(ResultCode.CART_ERROR);
|
||||
@ -205,7 +205,7 @@ public class CartController {
|
||||
return ResultUtil.success();
|
||||
} catch (ServiceException se) {
|
||||
log.error(se.getMsg(), se);
|
||||
return ResultUtil.error(se.getResultCode().code(), se.getResultCode().message());
|
||||
throw se;
|
||||
} catch (Exception e) {
|
||||
log.error(ResultCode.CART_ERROR.message(), e);
|
||||
throw new ServiceException(ResultCode.CART_ERROR);
|
||||
@ -243,7 +243,7 @@ public class CartController {
|
||||
return ResultUtil.data(this.cartService.createTrade(tradeParams));
|
||||
} catch (ServiceException se) {
|
||||
log.info(se.getMsg(), se);
|
||||
return ResultUtil.error(se.getResultCode().code(), se.getResultCode().message());
|
||||
throw se;
|
||||
} catch (Exception e) {
|
||||
log.error(ResultCode.ORDER_ERROR.message(), e);
|
||||
throw new ServiceException(ResultCode.ORDER_ERROR);
|
||||
|
@ -44,10 +44,21 @@ public class GlobalControllerExceptionHandler {
|
||||
|
||||
//如果是自定义异常,则获取异常,返回自定义错误消息
|
||||
if (e instanceof ServiceException) {
|
||||
ResultCode resultCode = ((ServiceException) e).getResultCode();
|
||||
ServiceException serviceException = ((ServiceException) e);
|
||||
ResultCode resultCode = serviceException.getResultCode();
|
||||
|
||||
Integer code = null;
|
||||
String message = null;
|
||||
|
||||
if (resultCode != null) {
|
||||
return ResultUtil.error(resultCode.code(), resultCode.message());
|
||||
code = resultCode.code();
|
||||
message = resultCode.message();
|
||||
}
|
||||
//如果有扩展消息,则输出异常中,跟随补充异常
|
||||
if (!serviceException.getMsg().equals(ServiceException.DEFAULT_MESSAGE)) {
|
||||
message += ":" + serviceException.getMsg();
|
||||
}
|
||||
return ResultUtil.error(code, message);
|
||||
}
|
||||
|
||||
//默认错误消息
|
||||
|
@ -4,13 +4,19 @@ import cn.lili.common.enums.ResultCode;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 全局业务异常类
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
@Data
|
||||
public class ServiceException extends RuntimeException {
|
||||
|
||||
private String msg;
|
||||
public static String DEFAULT_MESSAGE = "网络错误,请稍后重试!";
|
||||
|
||||
//异常消息
|
||||
private String msg = DEFAULT_MESSAGE;
|
||||
|
||||
//错误码
|
||||
private ResultCode resultCode;
|
||||
|
||||
public ServiceException(String msg) {
|
||||
@ -19,8 +25,7 @@ public class ServiceException extends RuntimeException {
|
||||
}
|
||||
|
||||
public ServiceException() {
|
||||
super("网络错误,请稍后重试!");
|
||||
this.msg = "网络错误,请稍后重试!";
|
||||
super();
|
||||
}
|
||||
|
||||
public ServiceException(ResultCode resultCode) {
|
||||
|
@ -1,42 +0,0 @@
|
||||
package cn.lili.modules.goods.entity.dos;
|
||||
|
||||
import cn.lili.base.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 规格值
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-02-18 15:18:56
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "li_spec_values")
|
||||
@TableName("li_spec_values")
|
||||
@ApiModel(value = "规格值")
|
||||
public class SpecValues extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 规格项id
|
||||
*/
|
||||
@TableField(value = "spec_id")
|
||||
@ApiModelProperty(value = "规格项id")
|
||||
private String specId;
|
||||
|
||||
/**
|
||||
* 规格值名字
|
||||
*/
|
||||
@TableField(value = "spec_value")
|
||||
@ApiModelProperty(value = "规格值名字")
|
||||
private String specValue;
|
||||
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
package cn.lili.modules.goods.entity.dos;
|
||||
|
||||
import cn.lili.base.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
@ -34,9 +36,19 @@ public class Specification extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 所属卖家 0属于平台
|
||||
* <p>
|
||||
* 店铺自定义规格暂时废弃 2021-06-23 后续推出新配置方式
|
||||
*/
|
||||
@ApiModelProperty(hidden = true)
|
||||
private String storeId;
|
||||
|
||||
/**
|
||||
* 规格值名字
|
||||
*/
|
||||
@TableField(value = "spec_value")
|
||||
@Column(columnDefinition = "TEXT")
|
||||
@ApiModelProperty(value = "规格值名字, 《,》分割")
|
||||
private String specValue;
|
||||
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package cn.lili.modules.goods.entity.dto;
|
||||
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 规格搜索参数
|
||||
*
|
||||
* @author paulG
|
||||
* @date 2020/12/19
|
||||
**/
|
||||
@Data
|
||||
public class SpecificationSearchParams {
|
||||
|
||||
|
||||
@ApiModelProperty(value = "规格id")
|
||||
private String specId;
|
||||
|
||||
@ApiModelProperty(value = "绑定分类")
|
||||
private String categoryPath;
|
||||
|
||||
@ApiModelProperty(value = "未删除 ")
|
||||
private Boolean deleteFlag;
|
||||
|
||||
public <T> QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(StringUtils.isNotEmpty(specId), "spec_id", specId);
|
||||
queryWrapper.eq(deleteFlag != null, "delete_flag", deleteFlag);
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package cn.lili.modules.goods.entity.vos;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 分类规格VO
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-02-26 23:24:13
|
||||
*/
|
||||
@Data
|
||||
public class CategorySpecificationVO {
|
||||
/**
|
||||
* 规格id
|
||||
*/
|
||||
@ApiModelProperty(value = "规格id", required = true)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 规格名称
|
||||
*/
|
||||
@ApiModelProperty(value = "规格名称", required = true)
|
||||
private String name;
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package cn.lili.modules.goods.entity.vos;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格值VO
|
||||
*
|
||||
* @author paulG
|
||||
* @date 2020-02-26 23:24:13
|
||||
*/
|
||||
@Data
|
||||
public class GoodsSpecValueVO {
|
||||
|
||||
/**
|
||||
* 规格值名字
|
||||
*/
|
||||
@TableField(value = "name")
|
||||
@ApiModelProperty(value = "规格值名字")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 规格值名字
|
||||
*/
|
||||
@TableField(value = "value")
|
||||
@ApiModelProperty(value = "规格值")
|
||||
private List<String> value;
|
||||
|
||||
}
|
@ -18,18 +18,10 @@ public class SpecValueVO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4433579132929428572L;
|
||||
|
||||
@TableField(value = "spec_name_id")
|
||||
@ApiModelProperty(value = "规格项ID")
|
||||
private String specNameId;
|
||||
|
||||
@TableField(value = "spec_name")
|
||||
@ApiModelProperty(value = "规格项名字")
|
||||
private String specName;
|
||||
|
||||
@TableField(value = "spec_value_id")
|
||||
@ApiModelProperty(value = "规格值")
|
||||
private String specValueId;
|
||||
|
||||
@TableField(value = "spec_value")
|
||||
@ApiModelProperty(value = "规格值")
|
||||
private String specValue;
|
||||
@ -43,18 +35,5 @@ public class SpecValueVO implements Serializable {
|
||||
* 规格图片
|
||||
*/
|
||||
@ApiModelProperty(value = "规格的图片")
|
||||
private List<SpecImages> specImage;
|
||||
|
||||
@Data
|
||||
public static class SpecImages implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1816357809660916086L;
|
||||
|
||||
private String url;
|
||||
|
||||
private String name;
|
||||
|
||||
private String status;
|
||||
|
||||
}
|
||||
private List<String> specImage;
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
package cn.lili.modules.goods.entity.vos;
|
||||
|
||||
import cn.lili.modules.goods.entity.dos.Specification;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 规格VO
|
||||
*
|
||||
* @author Chopper
|
||||
* @date 2020-02-26 23:24:13
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class SpecificationVO extends Specification {
|
||||
|
||||
private static final long serialVersionUID = 5504602856844228350L;
|
||||
|
||||
@ApiModelProperty(value = "规格项名称")
|
||||
private String specValue;
|
||||
|
||||
@ApiModelProperty(value = "分类path")
|
||||
private String categoryPath;
|
||||
|
||||
public SpecificationVO(String specName, String storeId, String categoryPath) {
|
||||
|
||||
this.setSpecName(specName);
|
||||
this.setStoreId(storeId);
|
||||
this.categoryPath = categoryPath;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package cn.lili.modules.goods.mapper;
|
||||
|
||||
import cn.lili.modules.goods.entity.dos.CategorySpecification;
|
||||
import cn.lili.modules.goods.entity.vos.CategorySpecificationVO;
|
||||
import cn.lili.modules.goods.entity.dos.Specification;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@ -20,8 +20,8 @@ public interface CategorySpecificationMapper extends BaseMapper<CategorySpecific
|
||||
* @param categoryId 分类id
|
||||
* @return 分类绑定规格列表
|
||||
*/
|
||||
@Select("select s.id, s.spec_name as `name` from " +
|
||||
@Select("select s.* from " +
|
||||
"li_specification s INNER join li_category_specification cs on s.id = cs.specification_id and cs.category_id = #{categoryId} " +
|
||||
"where s.delete_flag = 0")
|
||||
List<CategorySpecificationVO> getCategorySpecList(String categoryId);
|
||||
List<Specification> getCategorySpecList(String categoryId);
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package cn.lili.modules.goods.mapper;
|
||||
|
||||
import cn.lili.modules.goods.entity.dos.SpecValues;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 规格项数据处理层
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-02-18 15:18:56
|
||||
*/
|
||||
public interface SpecValuesMapper extends BaseMapper<SpecValues> {
|
||||
|
||||
|
||||
}
|
@ -2,14 +2,7 @@ package cn.lili.modules.goods.mapper;
|
||||
|
||||
|
||||
import cn.lili.modules.goods.entity.dos.Specification;
|
||||
import cn.lili.modules.goods.entity.vos.SpecificationVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格数据处理层
|
||||
@ -19,11 +12,4 @@ import java.util.List;
|
||||
*/
|
||||
public interface SpecificationMapper extends BaseMapper<Specification> {
|
||||
|
||||
/**
|
||||
* 查询规格信息列表
|
||||
* @return
|
||||
*/
|
||||
@Select("SELECT s.id, s.spec_name,s.create_time ,GROUP_CONCAT(sv.spec_value SEPARATOR ',') AS spec_value" +
|
||||
" FROM li_specification s LEFT JOIN li_spec_values sv ON s.id = sv.spec_id ${ew.customSqlSegment} ")
|
||||
List<SpecificationVO> findSpecList(@Param(Constants.WRAPPER) Wrapper queryWrapper);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package cn.lili.modules.goods.service;
|
||||
|
||||
import cn.lili.modules.goods.entity.dos.CategorySpecification;
|
||||
import cn.lili.modules.goods.entity.vos.CategorySpecificationVO;
|
||||
import cn.lili.modules.goods.entity.dos.Specification;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
@ -19,15 +19,8 @@ public interface CategorySpecificationService extends IService<CategorySpecifica
|
||||
* @param categoryId 分类id
|
||||
* @return 分类规格关联信息
|
||||
*/
|
||||
List<CategorySpecificationVO> getCategorySpecList(String categoryId);
|
||||
List<Specification> getCategorySpecList(String categoryId);
|
||||
|
||||
/***
|
||||
* 根据分类id查询规格信息
|
||||
*
|
||||
* @param categoryId 分类id
|
||||
* @return 分类规格关联信息
|
||||
*/
|
||||
List<CategorySpecification> getCategorySpecList(String[] categoryId);
|
||||
|
||||
/**
|
||||
* 通过分类ID删除关联规格
|
||||
|
@ -1,63 +0,0 @@
|
||||
package cn.lili.modules.goods.service;
|
||||
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.goods.entity.dos.SpecValues;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 规格项接口
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-02-18 15:18:56
|
||||
*/
|
||||
public interface SpecValuesService extends IService<SpecValues> {
|
||||
|
||||
/**
|
||||
* 保存规格值
|
||||
*
|
||||
* @param specId 规格Id
|
||||
* @param valueList 规格值集合
|
||||
*/
|
||||
List<SpecValues> saveSpecValue(String specId, String[] valueList);
|
||||
|
||||
/**
|
||||
* 保存规格值
|
||||
*
|
||||
* @param specId 规格Id
|
||||
* @param valueList 规格值集合
|
||||
*/
|
||||
List<SpecValues> addSpecValue(String specId, String[] valueList);
|
||||
|
||||
/**
|
||||
* 根据规格id查询规格值信息
|
||||
*
|
||||
* @param specIds 规格值ids
|
||||
* @return
|
||||
*/
|
||||
List<SpecValues> getSpecValues(List<String> specIds);
|
||||
|
||||
/**
|
||||
* 根据值获取规格值信息
|
||||
* 如果不存在则自动创建
|
||||
*
|
||||
* @param specValue 规格值
|
||||
* @param specId 规格ID
|
||||
* @return 规格值信息
|
||||
*/
|
||||
SpecValues getSpecValues(String specValue, String specId);
|
||||
|
||||
/**
|
||||
* 分页获取规格值
|
||||
*
|
||||
* @param specId 规格项ID
|
||||
* @param specVal 规格值
|
||||
* @param pageVo 分页参数
|
||||
* @return 规格值列表
|
||||
*/
|
||||
IPage<SpecValues> queryByParams(String specId, String specVal, PageVO pageVo);
|
||||
|
||||
}
|
@ -1,12 +1,7 @@
|
||||
package cn.lili.modules.goods.service;
|
||||
|
||||
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.goods.entity.dos.Specification;
|
||||
import cn.lili.modules.goods.entity.dto.SpecificationSearchParams;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsSpecValueVO;
|
||||
import cn.lili.modules.goods.entity.vos.SpecificationVO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
@ -19,64 +14,6 @@ import java.util.List;
|
||||
*/
|
||||
public interface SpecificationService extends IService<Specification> {
|
||||
|
||||
/**
|
||||
* 查询规格信息列表
|
||||
*
|
||||
* @param specName 规格名
|
||||
* @return 规格列表
|
||||
*/
|
||||
List<SpecificationVO> getSpecList(String specName);
|
||||
|
||||
/**
|
||||
* 根据分类id获取规格信息
|
||||
*
|
||||
* @param categoryId 分类id
|
||||
* @return 商品规格值列表
|
||||
*/
|
||||
List<GoodsSpecValueVO> getGoodsSpecValue(String categoryId);
|
||||
|
||||
/**
|
||||
* 获取规格详情
|
||||
*
|
||||
* @param id 规格ID
|
||||
* @return 规格详情
|
||||
*/
|
||||
Specification getSpecification(String id);
|
||||
|
||||
/**
|
||||
* 获取规格分页
|
||||
*
|
||||
* @param searchParams 搜索参数
|
||||
* @param pageVo 分页参数
|
||||
* @return 规格分页
|
||||
*/
|
||||
IPage<SpecificationVO> getSpecificationPage(SpecificationSearchParams searchParams, PageVO pageVo);
|
||||
|
||||
/**
|
||||
* 获取规格分页
|
||||
*
|
||||
* @param searchParams 搜索参数
|
||||
* @param pageVo 分页参数
|
||||
* @return 规格分页
|
||||
*/
|
||||
IPage<Specification> getSpecificationByPage(SpecificationSearchParams searchParams, PageVO pageVo);
|
||||
|
||||
/**
|
||||
* 添加规格
|
||||
*
|
||||
* @param specificationVO 规格信息
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
Specification addSpecification(SpecificationVO specificationVO);
|
||||
|
||||
/**
|
||||
* 修改规格
|
||||
*
|
||||
* @param specificationVO 规格信息
|
||||
* @return 是否修改成功
|
||||
*/
|
||||
boolean updateSpecification(SpecificationVO specificationVO);
|
||||
|
||||
/**
|
||||
* 删除规格
|
||||
*
|
||||
|
@ -1,17 +1,14 @@
|
||||
package cn.lili.modules.goods.serviceimpl;
|
||||
|
||||
import cn.lili.modules.goods.entity.dos.CategorySpecification;
|
||||
import cn.lili.modules.goods.entity.vos.CategorySpecificationVO;
|
||||
import cn.lili.modules.goods.entity.dos.Specification;
|
||||
import cn.lili.modules.goods.mapper.CategorySpecificationMapper;
|
||||
import cn.lili.modules.goods.service.CategorySpecificationService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -25,17 +22,12 @@ import java.util.List;
|
||||
public class CategorySpecificationServiceImpl extends ServiceImpl<CategorySpecificationMapper, CategorySpecification> implements CategorySpecificationService {
|
||||
|
||||
@Override
|
||||
public List<CategorySpecificationVO> getCategorySpecList(String categoryId) {
|
||||
public List<Specification> getCategorySpecList(String categoryId) {
|
||||
return this.baseMapper.getCategorySpecList(categoryId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CategorySpecification> getCategorySpecList(String[] categoryId) {
|
||||
return this.list(new LambdaQueryWrapper<CategorySpecification>().in(CategorySpecification::getCategoryId, Arrays.asList(categoryId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByCategoryId(String categoryId) {
|
||||
this.baseMapper.delete(new LambdaQueryWrapper<CategorySpecification>().eq(CategorySpecification::getCategoryId,categoryId));
|
||||
this.baseMapper.delete(new LambdaQueryWrapper<CategorySpecification>().eq(CategorySpecification::getCategoryId, categoryId));
|
||||
}
|
||||
}
|
@ -12,12 +12,17 @@ import cn.lili.common.rocketmq.tags.GoodsTagsEnum;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.utils.PageUtil;
|
||||
import cn.lili.config.rocketmq.RocketmqCustomProperties;
|
||||
import cn.lili.modules.goods.entity.dos.*;
|
||||
import cn.lili.modules.goods.entity.dos.Goods;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsParams;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsSkuStockDTO;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
||||
import cn.lili.modules.goods.entity.vos.*;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsSkuSpecVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsVO;
|
||||
import cn.lili.modules.goods.entity.vos.SpecValueVO;
|
||||
import cn.lili.modules.goods.mapper.GoodsSkuMapper;
|
||||
import cn.lili.modules.goods.service.*;
|
||||
import cn.lili.modules.member.entity.dos.FootPrint;
|
||||
@ -39,7 +44,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 商品sku业务层实现
|
||||
@ -63,9 +67,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
//规格
|
||||
@Autowired
|
||||
private SpecificationService specificationService;
|
||||
//规格项
|
||||
@Autowired
|
||||
private SpecValuesService specValuesService;
|
||||
//缓存
|
||||
@Autowired
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
@ -320,29 +321,29 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
JSONObject jsonObject = JSONUtil.parseObj(goodsSku.getSpecs());
|
||||
List<SpecValueVO> specValueVOS = new ArrayList<>();
|
||||
List<String> goodsGalleryList = new ArrayList<>();
|
||||
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
|
||||
SpecValueVO s = new SpecValueVO();
|
||||
if (entry.getKey().equals("images")) {
|
||||
s.setSpecName(entry.getKey());
|
||||
if (entry.getValue().toString().contains("url")) {
|
||||
List<SpecValueVO.SpecImages> specImages = JSONUtil.toList(JSONUtil.parseArray(entry.getValue()), SpecValueVO.SpecImages.class);
|
||||
s.setSpecImage(specImages);
|
||||
goodsGalleryList = specImages.stream().map(SpecValueVO.SpecImages::getUrl).collect(Collectors.toList());
|
||||
}
|
||||
} else {
|
||||
SpecificationVO specificationVO = new SpecificationVO();
|
||||
specificationVO.setSpecName(entry.getKey());
|
||||
specificationVO.setStoreId(goodsSku.getStoreId());
|
||||
specificationVO.setCategoryPath(goodsSku.getCategoryPath());
|
||||
Specification specification = specificationService.addSpecification(specificationVO);
|
||||
s.setSpecNameId(specification.getId());
|
||||
SpecValues specValues = specValuesService.getSpecValues(entry.getValue().toString(), specification.getId());
|
||||
s.setSpecValueId(specValues.getId());
|
||||
s.setSpecName(entry.getKey());
|
||||
s.setSpecValue(entry.getValue().toString());
|
||||
}
|
||||
specValueVOS.add(s);
|
||||
}
|
||||
// for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
|
||||
// SpecValueVO s = new SpecValueVO();
|
||||
// if (entry.getKey().equals("images")) {
|
||||
// s.setSpecName(entry.getKey());
|
||||
// if (entry.getValue().toString().contains("url")) {
|
||||
// List<SpecValueVO.SpecImages> specImages = JSONUtil.toList(JSONUtil.parseArray(entry.getValue()), SpecValueVO.SpecImages.class);
|
||||
// s.setSpecImage(specImages);
|
||||
// goodsGalleryList = specImages.stream().map(SpecValueVO.SpecImages::getUrl).collect(Collectors.toList());
|
||||
// }
|
||||
// } else {
|
||||
// SpecificationVO specificationVO = new SpecificationVO();
|
||||
// specificationVO.setSpecName(entry.getKey());
|
||||
// specificationVO.setStoreId(goodsSku.getStoreId());
|
||||
// specificationVO.setCategoryPath(goodsSku.getCategoryPath());
|
||||
// Specification specification = specificationService.addSpecification(specificationVO);
|
||||
// s.setSpecNameId(specification.getId());
|
||||
// SpecValues specValues = specValuesService.getSpecValues(entry.getValue().toString(), specification.getId());
|
||||
// s.setSpecValueId(specValues.getId());
|
||||
// s.setSpecName(entry.getKey());
|
||||
// s.setSpecValue(entry.getValue().toString());
|
||||
// }
|
||||
// specValueVOS.add(s);
|
||||
// }
|
||||
goodsSkuVO.setGoodsGalleryList(goodsGalleryList);
|
||||
goodsSkuVO.setSpecList(specValueVOS);
|
||||
return goodsSkuVO;
|
||||
@ -619,20 +620,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
} else {
|
||||
//设置商品名称
|
||||
goodsName.append(" ").append(m.getValue());
|
||||
|
||||
//规格简短信息
|
||||
simpleSpecs.append(" ").append(m.getValue());
|
||||
|
||||
//保存规格项
|
||||
SpecificationVO specificationVO = new SpecificationVO(m.getKey(), goods.getStoreId(), goods.getCategoryPath());
|
||||
Specification specification = specificationService.addSpecification(specificationVO);
|
||||
|
||||
//保存规格值
|
||||
SpecValues specValues = specValuesService.getSpecValues(m.getValue().toString(), specification.getId());
|
||||
|
||||
//添加属性索引
|
||||
EsGoodsAttribute attribute = new EsGoodsAttribute(0, specification.getId(), m.getKey(), specValues.getId(), m.getValue().toString());
|
||||
attributes.add(attribute);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,113 +0,0 @@
|
||||
package cn.lili.modules.goods.serviceimpl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.lili.common.utils.PageUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.goods.entity.dos.SpecValues;
|
||||
import cn.lili.modules.goods.entity.dos.Specification;
|
||||
import cn.lili.modules.goods.mapper.SpecValuesMapper;
|
||||
import cn.lili.modules.goods.service.SpecValuesService;
|
||||
import cn.lili.modules.goods.service.SpecificationService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 规格项接口实现
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-02-18 16:18:56
|
||||
*/
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class SpecValuesServiceImpl extends ServiceImpl<SpecValuesMapper, SpecValues> implements SpecValuesService {
|
||||
|
||||
//规格
|
||||
@Autowired
|
||||
private SpecificationService specificationService;
|
||||
|
||||
@Override
|
||||
public List<SpecValues> saveSpecValue(String specId, String[] valueList) {
|
||||
//校验是否存在
|
||||
Specification specification = specificationService.getById(specId);
|
||||
List<SpecValues> res = new ArrayList<>();
|
||||
if (specification != null) {
|
||||
//先删除原有规格值
|
||||
QueryWrapper<SpecValues> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("spec_id", specId);
|
||||
this.remove(queryWrapper);
|
||||
//添加新的规格值
|
||||
for (String value : valueList) {
|
||||
SpecValues specValues = new SpecValues();
|
||||
specValues.setSpecValue(value);
|
||||
specValues.setSpecId(specification.getId());
|
||||
this.save(specValues);
|
||||
res.add(specValues);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpecValues> addSpecValue(String specId, String[] valueList) {
|
||||
List<SpecValues> specValuesList = new ArrayList<>();
|
||||
for (String value : valueList) {
|
||||
QueryWrapper<SpecValues> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("spec_id", specId);
|
||||
queryWrapper.eq("spec_value", value);
|
||||
if (this.getOne(queryWrapper) == null) {
|
||||
SpecValues specValues = new SpecValues();
|
||||
specValues.setSpecValue(value);
|
||||
specValues.setSpecId(specId);
|
||||
this.save(specValues);
|
||||
specValuesList.add(specValues);
|
||||
}
|
||||
}
|
||||
return specValuesList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SpecValues> getSpecValues(List<String> specIds) {
|
||||
LambdaQueryWrapper<SpecValues> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SpecValues::getSpecValue, specIds);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpecValues getSpecValues(String specValue, String specId) {
|
||||
LambdaQueryWrapper<SpecValues> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SpecValues::getSpecValue, specValue);
|
||||
queryWrapper.eq(SpecValues::getSpecId, specId);
|
||||
|
||||
SpecValues specValues = this.getOne(queryWrapper);
|
||||
if (specValues == null) {
|
||||
specValues = new SpecValues();
|
||||
specValues.setSpecValue(specValue);
|
||||
specValues.setSpecId(specId);
|
||||
this.save(specValues);
|
||||
}
|
||||
return specValues;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SpecValues> queryByParams(String specId, String specVal, PageVO pageVo) {
|
||||
LambdaQueryWrapper<SpecValues> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (StrUtil.isNotEmpty(specId)) {
|
||||
queryWrapper.eq(SpecValues::getSpecId, specId);
|
||||
}
|
||||
if (StrUtil.isNotEmpty(specVal)) {
|
||||
queryWrapper.like(SpecValues::getSpecValue, specVal);
|
||||
}
|
||||
return this.page(PageUtil.initPage(pageVo), queryWrapper);
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +1,22 @@
|
||||
package cn.lili.modules.goods.serviceimpl;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.utils.PageUtil;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.goods.entity.dos.Category;
|
||||
import cn.lili.modules.goods.entity.dos.CategorySpecification;
|
||||
import cn.lili.modules.goods.entity.dos.SpecValues;
|
||||
import cn.lili.modules.goods.entity.dos.Specification;
|
||||
import cn.lili.modules.goods.entity.dto.SpecificationSearchParams;
|
||||
import cn.lili.modules.goods.entity.vos.CategorySpecificationVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsSpecValueVO;
|
||||
import cn.lili.modules.goods.entity.vos.SpecificationVO;
|
||||
import cn.lili.modules.goods.mapper.SpecificationMapper;
|
||||
import cn.lili.modules.goods.service.CategorySpecificationService;
|
||||
import cn.lili.modules.goods.service.SpecValuesService;
|
||||
import cn.lili.modules.goods.service.SpecificationService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品规格业务层实现
|
||||
@ -45,111 +31,11 @@ public class SpecificationServiceImpl extends ServiceImpl<SpecificationMapper, S
|
||||
//分类-规格绑定
|
||||
@Autowired
|
||||
private CategorySpecificationService categorySpecificationService;
|
||||
//规格值
|
||||
|
||||
@Autowired
|
||||
private SpecValuesService specValuesService;
|
||||
private CategoryServiceImpl categoryService;
|
||||
|
||||
@Override
|
||||
public List<SpecificationVO> getSpecList(String specId) {
|
||||
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq(StringUtils.isNotEmpty(specId), "s.spec_id", specId);
|
||||
queryWrapper.orderByDesc("s.create_time");
|
||||
return this.baseMapper.findSpecList(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GoodsSpecValueVO> getGoodsSpecValue(String categoryId) {
|
||||
List<CategorySpecificationVO> categorySpecificationVOS = categorySpecificationService.getCategorySpecList(categoryId);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (!categorySpecificationVOS.isEmpty()) {
|
||||
//循环组织查询规格值数据
|
||||
List<String> valueId = new ArrayList<>();
|
||||
for (CategorySpecificationVO categorySpecification : categorySpecificationVOS) {
|
||||
map.put(categorySpecification.getId(), categorySpecification.getName());
|
||||
valueId.add(categorySpecification.getId());
|
||||
}
|
||||
//使用valueId去查询规格值
|
||||
List<SpecValues> specValues = specValuesService.getSpecValues(valueId);
|
||||
//循环组织数据
|
||||
List<GoodsSpecValueVO> goodsSpecValueVOS = new ArrayList<>();
|
||||
for (Map.Entry<String, Object> m : map.entrySet()) {
|
||||
GoodsSpecValueVO goodsSpecValueVO = new GoodsSpecValueVO();
|
||||
goodsSpecValueVO.setName(m.getValue().toString());
|
||||
List<String> list = new ArrayList<>();
|
||||
for (SpecValues spec : specValues) {
|
||||
if (spec.getSpecId().equals(m.getKey())) {
|
||||
list.add(spec.getSpecValue());
|
||||
}
|
||||
}
|
||||
goodsSpecValueVO.setValue(list);
|
||||
goodsSpecValueVOS.add(goodsSpecValueVO);
|
||||
}
|
||||
return goodsSpecValueVOS;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification getSpecification(String id) {
|
||||
Specification specification = this.getById(id);
|
||||
if (specification == null) {
|
||||
throw new ServiceException("当前商品已下架");
|
||||
}
|
||||
return specification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SpecificationVO> getSpecificationPage(SpecificationSearchParams searchParams, PageVO pageVo) {
|
||||
|
||||
List<SpecificationVO> specList = this.getSpecList(searchParams.getSpecId());
|
||||
IPage<SpecificationVO> page = new Page<>(pageVo.getPageNumber(), pageVo.getPageSize(), specList.size());
|
||||
page.setRecords(PageUtil.listToPage(pageVo, specList));
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<Specification> getSpecificationByPage(SpecificationSearchParams searchParams, PageVO pageVo) {
|
||||
List<String> specIds = new ArrayList<>();
|
||||
if (StrUtil.isNotEmpty(searchParams.getCategoryPath())) {
|
||||
String categoryPath = searchParams.getCategoryPath();
|
||||
List<CategorySpecification> categorySpecList = categorySpecificationService.getCategorySpecList(categoryPath.split(","));
|
||||
categorySpecList.forEach(i -> specIds.add(i.getSpecificationId()));
|
||||
}
|
||||
QueryWrapper<Specification> queryWrapper = searchParams.queryWrapper();
|
||||
queryWrapper.in("id", specIds);
|
||||
return this.page(PageUtil.initPage(pageVo), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification addSpecification(SpecificationVO specificationVO) {
|
||||
Specification specification = this.getOne(new LambdaQueryWrapper<Specification>().eq(Specification::getSpecName, specificationVO.getSpecName()));
|
||||
if (specification == null) {
|
||||
this.save(specificationVO);
|
||||
specification = specificationVO;
|
||||
}
|
||||
|
||||
CategorySpecification categorySpecification = categorySpecificationService.getOne(new LambdaQueryWrapper<CategorySpecification>().eq(CategorySpecification::getSpecificationId, specification.getId()));
|
||||
if (categorySpecification == null) {
|
||||
categorySpecification = new CategorySpecification();
|
||||
categorySpecification.setSpecificationId(specification.getId());
|
||||
String categoryPath = specificationVO.getCategoryPath();
|
||||
if (CharSequenceUtil.isNotEmpty(categoryPath)) {
|
||||
categorySpecification.setCategoryId(categoryPath.substring(categoryPath.lastIndexOf(",") + 1));
|
||||
categorySpecificationService.save(categorySpecification);
|
||||
}
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(specificationVO.getSpecValue())) {
|
||||
specValuesService.saveSpecValue(specificationVO.getId(), new String[]{specificationVO.getSpecValue()});
|
||||
}
|
||||
return specification;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateSpecification(SpecificationVO specificationVO) {
|
||||
this.getSpecification(specificationVO.getId());
|
||||
return this.updateById(specificationVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteSpecification(List<String> ids) {
|
||||
@ -157,12 +43,23 @@ public class SpecificationServiceImpl extends ServiceImpl<SpecificationMapper, S
|
||||
//如果此规格绑定分类则不允许删除
|
||||
List<CategorySpecification> list = categorySpecificationService.list(new QueryWrapper<CategorySpecification>().eq("specification_id", id));
|
||||
if (!list.isEmpty()) {
|
||||
throw new ServiceException(ResultCode.SPEC_DELETE_ERROR);
|
||||
List<String> categoryIds = new ArrayList<>();
|
||||
list.forEach(item -> {
|
||||
categoryIds.add(item.getCategoryId());
|
||||
});
|
||||
//返回包含分类的信息
|
||||
LambdaQueryWrapper<Category> queryWrapper = new LambdaQueryWrapper();
|
||||
queryWrapper.in(Category::getId, categoryIds);
|
||||
List<Category> categories = categoryService.list(queryWrapper);
|
||||
StringBuffer stringBuffer = new StringBuffer("包含的分类有-");
|
||||
categories.stream().forEach(item -> {
|
||||
stringBuffer.append(item.getName());
|
||||
stringBuffer.append(",");
|
||||
});
|
||||
throw new ServiceException(ResultCode.SPEC_DELETE_ERROR, stringBuffer.toString());
|
||||
}
|
||||
//删除规格
|
||||
this.removeById(id);
|
||||
//删除规格值
|
||||
specValuesService.remove(new QueryWrapper<SpecValues>().eq("spec_id", id));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -3,8 +3,7 @@ package cn.lili.controller.goods;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.goods.entity.dos.CategorySpecification;
|
||||
import cn.lili.modules.goods.entity.vos.CategorySpecificationVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsSpecValueVO;
|
||||
import cn.lili.modules.goods.entity.dos.Specification;
|
||||
import cn.lili.modules.goods.service.CategorySpecificationService;
|
||||
import cn.lili.modules.goods.service.SpecificationService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@ -45,15 +44,15 @@ public class CategorySpecificationManagerController {
|
||||
@ApiOperation(value = "查询某分类下绑定的规格信息")
|
||||
@GetMapping(value = "/{categoryId}")
|
||||
@ApiImplicitParam(name = "categoryId", value = "分类id", required = true, dataType = "String", paramType = "path")
|
||||
public List<CategorySpecificationVO> getCategorySpec(@PathVariable String categoryId) {
|
||||
public List<Specification> getCategorySpec(@PathVariable String categoryId) {
|
||||
return categorySpecificationService.getCategorySpecList(categoryId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询某分类下绑定的规格信息,商品操作使用")
|
||||
@GetMapping(value = "/goods/{categoryId}")
|
||||
@ApiImplicitParam(name = "categoryId", value = "分类id", required = true, dataType = "String", paramType = "path")
|
||||
public List<GoodsSpecValueVO> getSpec(@PathVariable String categoryId) {
|
||||
return specificationService.getGoodsSpecValue(categoryId);
|
||||
public List<Specification> getSpec(@PathVariable String categoryId) {
|
||||
return specificationService.list();
|
||||
}
|
||||
|
||||
|
||||
@ -71,7 +70,7 @@ public class CategorySpecificationManagerController {
|
||||
if (categorySpecs != null && categorySpecs.length > 0) {
|
||||
List<CategorySpecification> categorySpecifications = new ArrayList<>();
|
||||
for (String categorySpec : categorySpecs) {
|
||||
categorySpecifications.add( new CategorySpecification(categoryId, categorySpec));
|
||||
categorySpecifications.add(new CategorySpecification(categoryId, categorySpec));
|
||||
}
|
||||
categorySpecificationService.saveBatch(categorySpecifications);
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
package cn.lili.controller.goods;
|
||||
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.goods.entity.dos.SpecValues;
|
||||
import cn.lili.modules.goods.service.SpecValuesService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 管理端,规格项管理接口
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-02-18 15:18:56
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "管理端,规格项管理接口")
|
||||
@RequestMapping("/manager/goods/specValues")
|
||||
public class SpecValuesManagerController {
|
||||
|
||||
@Autowired
|
||||
private SpecValuesService specValuesService;
|
||||
|
||||
@GetMapping(value = "/values/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "规格项ID", required = true, dataType = "String", paramType = "path")
|
||||
@ApiOperation(value = "查询规格值列表")
|
||||
public ResultMessage<List<SpecValues>> list(@PathVariable("id") String id) {
|
||||
return ResultUtil.data(specValuesService.query().eq("spec_id", id).list());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "保存规格值")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "specId", value = "商品规格ID", required = true, paramType = "path"),
|
||||
@ApiImplicitParam(name = "specValue", value = "商品项", required = true, allowMultiple = true, paramType = "query")
|
||||
})
|
||||
@PostMapping(value = "/save/{specId}")
|
||||
public ResultMessage<List<SpecValues>> saveSpecValue(@PathVariable String specId,
|
||||
@NotNull(message = "至少添加一个规格值") @RequestParam String[] specValue) {
|
||||
//重新添加
|
||||
List<SpecValues> list = specValuesService.saveSpecValue(specId, specValue);
|
||||
return ResultUtil.data(list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,24 +1,21 @@
|
||||
package cn.lili.controller.goods;
|
||||
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.utils.PageUtil;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.goods.entity.dos.Specification;
|
||||
import cn.lili.modules.goods.entity.dto.SpecificationSearchParams;
|
||||
import cn.lili.modules.goods.entity.vos.SpecificationVO;
|
||||
import cn.lili.modules.goods.service.SpecificationService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -36,54 +33,39 @@ public class SpecificationManagerController {
|
||||
@Autowired
|
||||
private SpecificationService specificationService;
|
||||
|
||||
@GetMapping(value = "/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "商品规格ID", required = true, dataType = "String", paramType = "path")
|
||||
@ApiOperation(value = "通过id获取商品规格")
|
||||
public ResultMessage<Specification> get(@PathVariable String id) {
|
||||
return ResultUtil.data(specificationService.getSpecification(id));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/all", method = RequestMethod.GET)
|
||||
@GetMapping("/all")
|
||||
@ApiOperation(value = "获取所有可用规格")
|
||||
public List<Specification> getAll() {
|
||||
List<Specification> list = specificationService.list(new QueryWrapper<Specification>().eq("delete_flag", 0));
|
||||
List<Specification> list = specificationService.list();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping(value = "/page")
|
||||
@ApiOperation(value = "分页获取")
|
||||
public ResultMessage<IPage<SpecificationVO>> getByPage(String specId, PageVO pageVo) {
|
||||
SpecificationSearchParams searchParams = new SpecificationSearchParams();
|
||||
searchParams.setSpecId(specId);
|
||||
return ResultUtil.data(specificationService.getSpecificationPage(searchParams, pageVo));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@ApiOperation(value = "编辑规格")
|
||||
public ResultMessage<Specification> update(@Valid SpecificationVO parameters) {
|
||||
if (parameters.getStoreId() == null) {
|
||||
parameters.setStoreId("0");
|
||||
}
|
||||
if (specificationService.updateSpecification(parameters)) {
|
||||
return ResultUtil.data(parameters);
|
||||
}
|
||||
throw new ServiceException(ResultCode.SPEC_UPDATE_ERROR);
|
||||
@GetMapping
|
||||
@ApiOperation(value = "搜索规格")
|
||||
public Page<Specification> page(String specName, PageVO page) {
|
||||
LambdaQueryWrapper<Specification> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.like(StringUtils.isNotEmpty(specName), Specification::getSpecName, specName);
|
||||
lambdaQueryWrapper.orderByDesc(Specification::getCreateTime);
|
||||
return specificationService.page(PageUtil.initPage(page), lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "添加规格")
|
||||
public ResultMessage<Specification> save(@Valid SpecificationVO parameters) {
|
||||
if (parameters.getStoreId() == null) {
|
||||
parameters.setStoreId("0");
|
||||
}
|
||||
if (specificationService.addSpecification(parameters) != null) {
|
||||
return ResultUtil.data(parameters);
|
||||
}
|
||||
throw new ServiceException(ResultCode.SPEC_SAVE_ERROR);
|
||||
@ApiOperation(value = "保存规格")
|
||||
public ResultMessage<Object> save(Specification specification) {
|
||||
specificationService.save(specification);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/{ids}")
|
||||
@PutMapping("/{id}")
|
||||
@ApiOperation(value = "更改规格")
|
||||
public ResultMessage<Object> update(Specification specification, @PathVariable String id) {
|
||||
specification.setId(id);
|
||||
specificationService.saveOrUpdate(specification);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
@DeleteMapping("/{ids}")
|
||||
@ApiImplicitParam(name = "ids", value = "规格ID", required = true, dataType = "String", allowMultiple = true, paramType = "path")
|
||||
@ApiOperation(value = "批量删除")
|
||||
public ResultMessage<Object> delAllByIds(@PathVariable List<String> ids) {
|
||||
|
@ -8,6 +8,8 @@ import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.token.Token;
|
||||
import cn.lili.common.utils.PageUtil;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.verification.enums.VerificationEnums;
|
||||
import cn.lili.common.verification.service.VerificationService;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.common.vo.SearchVO;
|
||||
@ -49,11 +51,19 @@ public class AdminUserManagerController {
|
||||
@Autowired
|
||||
private DepartmentService departmentService;
|
||||
|
||||
@Autowired
|
||||
private VerificationService verificationService;
|
||||
|
||||
@GetMapping(value = "/login")
|
||||
@ApiOperation(value = "登录管理员")
|
||||
public ResultMessage<Token> login(String username, String password) {
|
||||
public ResultMessage<Token> login(@NotNull(message = "用户名不能为空") @RequestParam String username,
|
||||
@NotNull(message = "密码不能为空") @RequestParam String password,
|
||||
@RequestHeader String uuid) {
|
||||
if (verificationService.check(uuid, VerificationEnums.LOGIN)) {
|
||||
return ResultUtil.data(adminUserService.login(username, password));
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.VERIFICATION_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -152,7 +162,7 @@ public class AdminUserManagerController {
|
||||
}
|
||||
adminUserService.saveAdminUser(adminUser, roles);
|
||||
} catch (Exception e) {
|
||||
log.error("添加用户错误",e);
|
||||
log.error("添加用户错误", e);
|
||||
}
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
@ -1,21 +1,16 @@
|
||||
package cn.lili.controller.goods;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.goods.entity.dos.CategorySpecification;
|
||||
import cn.lili.modules.goods.entity.vos.CategorySpecificationVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsSpecValueVO;
|
||||
import cn.lili.modules.goods.entity.dos.Specification;
|
||||
import cn.lili.modules.goods.service.CategorySpecificationService;
|
||||
import cn.lili.modules.goods.service.SpecificationService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -32,40 +27,14 @@ import java.util.List;
|
||||
public class CategorySpecificationStoreController {
|
||||
@Autowired
|
||||
private CategorySpecificationService categorySpecificationService;
|
||||
@Autowired
|
||||
private SpecificationService specificationService;
|
||||
|
||||
|
||||
@ApiOperation(value = "查询某分类下绑定的规格信息")
|
||||
@GetMapping(value = "/{category_id}")
|
||||
@ApiImplicitParam(name = "category_id", value = "分类id", required = true, dataType = "String", paramType = "path")
|
||||
public List<CategorySpecificationVO> getCategorySpec(@PathVariable("category_id") String categoryId) {
|
||||
public List<Specification> getCategorySpec(@PathVariable("category_id") String categoryId) {
|
||||
return categorySpecificationService.getCategorySpecList(categoryId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询某分类下绑定的规格信息,商品操作使用")
|
||||
@GetMapping(value = "/goods/{category_id}")
|
||||
@ApiImplicitParam(name = "category_id", value = "分类id", required = true, dataType = "String", paramType = "path")
|
||||
public List<GoodsSpecValueVO> getSpec(@PathVariable("category_id") String categoryId) {
|
||||
return specificationService.getGoodsSpecValue(categoryId);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "保存某分类下绑定的规格信息")
|
||||
@PostMapping(value = "/{category_id}")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "category_id", value = "分类id", required = true, paramType = "path", dataType = "String"),
|
||||
@ApiImplicitParam(name = "category_specs", value = "规格id数组", required = true, paramType = "query", dataType = "String[]")
|
||||
})
|
||||
public ResultMessage<Object> saveCategoryBrand(@PathVariable("category_id") String categoryId, @RequestParam("category_specs") String[] categorySpecs) {
|
||||
//删除分类规格绑定信息
|
||||
this.categorySpecificationService.remove(new QueryWrapper<CategorySpecification>().eq("category_id", categoryId));
|
||||
//绑定规格信息
|
||||
for (String specId : categorySpecs) {
|
||||
CategorySpecification categoryBrand = new CategorySpecification(categoryId, specId);
|
||||
categorySpecificationService.save(categoryBrand);
|
||||
}
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
package cn.lili.controller.goods;
|
||||
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.goods.entity.dos.SpecValues;
|
||||
import cn.lili.modules.goods.service.SpecValuesService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店铺端,规格项管理接口
|
||||
*
|
||||
* @author pikachu
|
||||
* @date 2020-02-18 15:18:56
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "店铺端,规格项管理接口")
|
||||
@RequestMapping("/store/goods/spec-values")
|
||||
public class SpecValuesStoreController {
|
||||
@Autowired
|
||||
private SpecValuesService specValuesService;
|
||||
|
||||
@GetMapping(value = "/values/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "规格项ID", required = true, dataType = "String", paramType = "path")
|
||||
@ApiOperation(value = "查询规格值列表")
|
||||
public ResultMessage<IPage<SpecValues>> list(@PathVariable("id") String id, String specVal, PageVO pageVo) {
|
||||
return ResultUtil.data(specValuesService.queryByParams(id, specVal, pageVo));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "保存规格值")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "商品规格ID", required = true, paramType = "path"),
|
||||
@ApiImplicitParam(name = "specValue", value = "商品项", required = true, allowMultiple = true, paramType = "query")
|
||||
})
|
||||
@PostMapping(value = "/save/{id}")
|
||||
public ResultMessage<List<SpecValues>> saveSpecValue(@PathVariable("id") String specId,
|
||||
@NotNull(message = "至少添加一个规格值") @RequestParam(value = "spec_value") String[] specValue) {
|
||||
//重新添加
|
||||
List<SpecValues> list = specValuesService.addSpecValue(specId, specValue);
|
||||
return ResultUtil.data(list);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,22 +1,15 @@
|
||||
package cn.lili.controller.goods;
|
||||
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.goods.entity.dos.Specification;
|
||||
import cn.lili.modules.goods.entity.dto.SpecificationSearchParams;
|
||||
import cn.lili.modules.goods.entity.vos.SpecificationVO;
|
||||
import cn.lili.modules.goods.service.SpecificationService;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import cn.lili.modules.goods.service.CategorySpecificationService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@ -27,35 +20,17 @@ import java.util.List;
|
||||
* @date 2020-02-18 15:18:56
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "店铺端,规格管理接口")
|
||||
@Api(tags = "店铺端,规格接口")
|
||||
@RequestMapping("/store/goods/spec")
|
||||
public class SpecificationStoreController {
|
||||
|
||||
@Autowired
|
||||
private SpecificationService specificationService;
|
||||
private CategorySpecificationService categorySpecificationService;
|
||||
|
||||
|
||||
@GetMapping(value = "/page")
|
||||
@ApiOperation(value = "分页获取")
|
||||
public ResultMessage<IPage<Specification>> getByPage(SpecificationSearchParams searchParams, PageVO pageVo) {
|
||||
searchParams.setDeleteFlag(false);
|
||||
return ResultUtil.data(specificationService.getSpecificationByPage(searchParams, pageVo));
|
||||
@GetMapping(value = "/{categoryId}")
|
||||
@ApiOperation(value = "获取分类规格")
|
||||
public List<Specification> getSpecifications(String categoryId) {
|
||||
return categorySpecificationService.getCategorySpecList(categoryId);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "添加规格")
|
||||
public ResultMessage<Specification> save(@Valid SpecificationVO parameters) {
|
||||
if (parameters.getStoreId() == null) {
|
||||
parameters.setStoreId(UserContext.getCurrentUser().getId());
|
||||
}
|
||||
specificationService.addSpecification(parameters);
|
||||
return ResultUtil.data(parameters);
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/{ids}")
|
||||
@ApiImplicitParam(name = "ids", value = "规格ID", required = true, dataType = "String", allowMultiple = true, paramType = "path")
|
||||
@ApiOperation(value = "批量删除")
|
||||
public ResultMessage<Object> delAllByIds(@PathVariable List<String> ids) {
|
||||
specificationService.deleteSpecification(ids);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,11 @@
|
||||
package cn.lili.controller.passport;
|
||||
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.verification.enums.VerificationEnums;
|
||||
import cn.lili.common.verification.service.VerificationService;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
@ -32,6 +36,8 @@ public class StorePassportController {
|
||||
@Autowired
|
||||
private MemberService memberService;
|
||||
|
||||
@Autowired
|
||||
private VerificationService verificationService;
|
||||
|
||||
@ApiOperation(value = "登录接口")
|
||||
@ApiImplicitParams({
|
||||
@ -40,8 +46,12 @@ public class StorePassportController {
|
||||
})
|
||||
@PostMapping("/userLogin")
|
||||
public ResultMessage<Object> userLogin(@NotNull(message = "用户名不能为空") @RequestParam String username,
|
||||
@NotNull(message = "密码不能为空") @RequestParam String password) {
|
||||
@NotNull(message = "密码不能为空") @RequestParam String password, @RequestHeader String uuid) {
|
||||
if (verificationService.check(uuid, VerificationEnums.LOGIN)) {
|
||||
return ResultUtil.data(this.memberService.usernameStoreLogin(username, password));
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.VERIFICATION_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改密码")
|
||||
|
Loading…
x
Reference in New Issue
Block a user