霸王餐相关
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.czg.account.dto.freeding.FreeDineConfigEditDTO;
|
||||
import com.czg.account.entity.FreeDineConfig;
|
||||
import com.czg.account.service.FreeDineConfigService;
|
||||
import com.czg.account.vo.FreeDineConfigVO;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.service.account.mapper.FreeDineConfigMapper;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
@@ -19,7 +22,7 @@ import org.apache.dubbo.config.annotation.DubboService;
|
||||
@DubboService
|
||||
public class FreeDineConfigServiceImpl extends ServiceImpl<FreeDineConfigMapper, FreeDineConfig> implements FreeDineConfigService{
|
||||
@Override
|
||||
public FreeDineConfig getConfig(long shopId) {
|
||||
public FreeDineConfigVO getConfig(long shopId) {
|
||||
FreeDineConfig freeDineConfig = getOne(new QueryWrapper().eq(FreeDineConfig::getShopId, shopId));
|
||||
if (freeDineConfig == null) {
|
||||
freeDineConfig = new FreeDineConfig();
|
||||
@@ -27,17 +30,23 @@ public class FreeDineConfigServiceImpl extends ServiceImpl<FreeDineConfigMapper,
|
||||
save(freeDineConfig);
|
||||
freeDineConfig = getOne(new QueryWrapper().eq(FreeDineConfig::getShopId, shopId));
|
||||
}
|
||||
|
||||
return freeDineConfig;
|
||||
FreeDineConfigVO dto = BeanUtil.copyProperties(freeDineConfig, FreeDineConfigVO.class, "shopIdList");
|
||||
if (StrUtil.isNotBlank(freeDineConfig.getShopIdList())) {
|
||||
dto.setShopIdList(JSONArray.parseArray(freeDineConfig.getShopIdList()).toList(Long.class));
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean edit(long shopId, FreeDineConfigEditDTO freeDineConfigEditDTO) {
|
||||
FreeDineConfig config = getConfig(shopId);
|
||||
FreeDineConfig config = getOne(new QueryWrapper().eq(FreeDineConfig::getShopId, shopId));
|
||||
if (config == null) {
|
||||
throw new ApiNotPrintException("霸王餐信息未配置");
|
||||
}
|
||||
BeanUtil.copyProperties(freeDineConfigEditDTO, config);
|
||||
if ("part".equals(freeDineConfigEditDTO.getUseShopType()) && freeDineConfigEditDTO.getShopIdList() != null) {
|
||||
config.setShopIdList(JSONArray.toJSONString(freeDineConfigEditDTO.getShopIdList()));
|
||||
}
|
||||
// if (freeDineConfigEditDTO.getUseType() != null && !freeDineConfigEditDTO.getUseType().isEmpty()) {
|
||||
// config.setUseType(JSONObject.toJSONString(freeDineConfigEditDTO.getUseType()));
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user