|
@@ -1,22 +1,28 @@
|
|
|
package com.chelvc.cloud.vehicle.server.service.impl;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.chelvc.cloud.vehicle.api.constant.CategoryType;
|
|
|
+import com.chelvc.cloud.vehicle.api.constant.MerchantStatus;
|
|
|
import com.chelvc.cloud.vehicle.api.dto.GoodsDTO;
|
|
|
import com.chelvc.cloud.vehicle.api.dto.MerchantDTO;
|
|
|
import com.chelvc.cloud.vehicle.api.dto.MerchantDetailDTO;
|
|
|
-import com.chelvc.cloud.vehicle.api.param.*;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.GoodsQueryParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.LocationQueryParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.MerchantModifyParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.MerchantPagingParam;
|
|
|
+import com.chelvc.cloud.vehicle.api.param.MerchantQueryParam;
|
|
|
import com.chelvc.cloud.vehicle.server.copier.MerchantCopier;
|
|
|
import com.chelvc.cloud.vehicle.server.dao.MerchantMapper;
|
|
|
import com.chelvc.cloud.vehicle.server.entity.Merchant;
|
|
|
import com.chelvc.cloud.vehicle.server.service.GoodsService;
|
|
|
import com.chelvc.cloud.vehicle.server.service.MerchantService;
|
|
|
-import com.chelvc.framework.base.model.Pagination;
|
|
|
-import com.chelvc.framework.base.util.StringUtils;
|
|
|
-import com.chelvc.framework.database.context.DatabaseContextHolder;
|
|
|
+import com.chelvc.framework.base.util.ResourceUtils;
|
|
|
+import com.chelvc.framework.common.model.Pagination;
|
|
|
+import com.chelvc.framework.common.util.StringUtils;
|
|
|
import com.chelvc.framework.database.util.PagingUtils;
|
|
|
import lombok.NonNull;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -54,7 +60,7 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
|
|
|
public MerchantDetailDTO getMerchantDetail(@NonNull Long id) {
|
|
|
// 获取商家信息
|
|
|
MerchantDTO merchant = MerchantCopier.INSTANCE.copying(
|
|
|
- DatabaseContextHolder.getRequireEntity(this, id, "商家不存在")
|
|
|
+ ResourceUtils.required(this.getById(id), "商家不存在")
|
|
|
);
|
|
|
|
|
|
// 获取商家全部商品列表
|
|
@@ -69,30 +75,30 @@ public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> i
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public Long addMerchant(MerchantModifyParam param){
|
|
|
+ public Long addMerchant(@NonNull MerchantModifyParam param) {
|
|
|
Merchant merchant = MerchantCopier.INSTANCE.copying(param);
|
|
|
+ merchant.setUserId(0L);
|
|
|
+ merchant.setScore(0D);
|
|
|
+ merchant.setSale(0);
|
|
|
+ merchant.setStatus(MerchantStatus.ONLINE);
|
|
|
this.save(merchant);
|
|
|
return merchant.getId();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void updateMerchant(@NonNull Long id, @NonNull MerchantModifyParam param) {
|
|
|
- Merchant merchant = DatabaseContextHolder.getRequireEntity(this, id, "商家不存在");
|
|
|
+ Merchant merchant = ResourceUtils.required(this.getById(id), "商家不存在");
|
|
|
MerchantCopier.INSTANCE.copying(param, merchant);
|
|
|
this.updateById(merchant);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void deleteMerchant(@NonNull Long id) {
|
|
|
- DatabaseContextHolder.getRequireEntity(this, id, "商家不存在");
|
|
|
- this.baseMapper.deleteById(id);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public Pagination<MerchantDTO> getMerchantPaging(@NonNull MerchantPagingParam param) {
|
|
|
Page<Merchant> page = this.lambdaQuery()
|
|
|
- .like(StringUtils.nonEmpty(param.getName()), Merchant::getName, param.getName())
|
|
|
- .orderByAsc(Merchant::getStatus).page(PagingUtils.convert(param.getPaging()));
|
|
|
+ .eq(StringUtils.nonEmpty(param.getName()), Merchant::getName, param.getName())
|
|
|
+ .eq(Objects.nonNull(param.getRecommend()), Merchant::getRecommend, param.getRecommend())
|
|
|
+ .eq(Objects.nonNull(param.getStatus()), Merchant::getStatus, param.getStatus())
|
|
|
+ .orderByDesc(Merchant::getCreateTime).page(PagingUtils.convert(param.getPaging()));
|
|
|
return PagingUtils.convert(page, MerchantCopier.INSTANCE::copying);
|
|
|
}
|
|
|
}
|