xiaoyong931011
2022-09-16 7f2d3e9bcb89311a5cbfaa617fde71ea412f9bc3
src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallGoodsService.java
@@ -12,6 +12,7 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -473,5 +474,55 @@
        return mallGoodsMapper.getAllGoodsTree();
    }
    @Override
    public FebsResponse goodsHot(Long id) {
        MallGoods mallGoods = mallGoodsMapper.selectById(id);
        if (ObjectUtil.isEmpty(mallGoods)) {
            return new FebsResponse().fail().message("商品不存在,请刷新当前页面");
        }
        mallGoods.setIsHot(MallGoods.ISHOT_STATE_YES);
        mallGoodsMapper.updateById(mallGoods);
        return new FebsResponse().success();
    }
    @Override
    public FebsResponse goodsNotHot(Long id) {
        MallGoods mallGoods = mallGoodsMapper.selectById(id);
        if (ObjectUtil.isEmpty(mallGoods)) {
            return new FebsResponse().fail().message("商品不存在,请刷新当前页面");
        }
        mallGoods.setIsHot(MallGoods.ISHOT_STATE_NO);
        mallGoodsMapper.updateById(mallGoods);
        return new FebsResponse().success();
    }
    @Override
    public IPage<AdminHomeDeliverySettingVo> getDeliveryHomeListInPage(AdminHomeDeliverySettingVo adminHomeDeliverySetting, QueryRequest request) {
        Page<DataDictionaryCustom> page = new Page<>(request.getPageNum(), request.getPageSize());
        IPage<DataDictionaryCustom> dataDictionaryCustomIPage = this.baseMapper.getDeliveryHomeListInPage(page, adminHomeDeliverySetting);
        List<DataDictionaryCustom> records = dataDictionaryCustomIPage.getRecords();
        List<AdminHomeDeliverySettingVo> adminHomeDeliverySettingVos = new ArrayList<>();
        if(CollUtil.isNotEmpty(records)){
            for(DataDictionaryCustom dataDictionaryCustom : records){
                AdminHomeDeliverySettingVo adminHomeDeliverySettingVo = JSONUtil.toBean(dataDictionaryCustom.getValue(), AdminHomeDeliverySettingVo.class);
                adminHomeDeliverySettingVo.setId(dataDictionaryCustom.getId());
                adminHomeDeliverySettingVos.add(adminHomeDeliverySettingVo);
            }
        }
        IPage<AdminHomeDeliverySettingVo> adminHomeDeliverySettingVoIPage = new Page<>();
        adminHomeDeliverySettingVoIPage.setRecords(adminHomeDeliverySettingVos);
        adminHomeDeliverySettingVoIPage.setTotal(dataDictionaryCustomIPage.getTotal());
        return adminHomeDeliverySettingVoIPage;
    }
    private final DataDictionaryCustomMapper dataDictionaryCustomMapper;
    @Override
    public FebsResponse deliveryHomeUpdate(AdminHomeDeliverySettingVo adminHomeDeliverySettingVo) {
        DataDictionaryCustom dataDictionaryCustom = dataDictionaryCustomMapper.selectById(adminHomeDeliverySettingVo.getId());
        adminHomeDeliverySettingVo.setId(null);
        dataDictionaryCustom.setValue(JSONUtil.toJsonStr(adminHomeDeliverySettingVo));
        dataDictionaryCustomMapper.updateById(dataDictionaryCustom);
        return new FebsResponse().success();
    }
}