霸王餐接口
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.FreeDineConfig;
|
||||
|
||||
/**
|
||||
* 霸王餐配置信息表 映射层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-21
|
||||
*/
|
||||
public interface FreeDineConfigMapper extends BaseMapper<FreeDineConfig> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.dto.freeding.FreeDineConfigEditDTO;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.FreeDineConfig;
|
||||
import com.czg.account.service.FreeDineConfigService;
|
||||
import com.czg.service.account.mapper.FreeDineConfigMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 霸王餐配置信息表 服务层实现。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-21
|
||||
*/
|
||||
@Service
|
||||
public class FreeDineConfigServiceImpl extends ServiceImpl<FreeDineConfigMapper, FreeDineConfig> implements FreeDineConfigService{
|
||||
@Override
|
||||
public FreeDineConfig getConfig(long shopId) {
|
||||
FreeDineConfig freeDineConfig = getOne(new QueryWrapper().eq(FreeDineConfig::getShopId, shopId));
|
||||
if (freeDineConfig == null) {
|
||||
freeDineConfig = new FreeDineConfig();
|
||||
freeDineConfig.setShopId(shopId);
|
||||
save(freeDineConfig);
|
||||
}
|
||||
|
||||
return freeDineConfig;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean edit(long shopId, FreeDineConfigEditDTO freeDineConfigEditDTO) {
|
||||
FreeDineConfig config = getConfig(shopId);
|
||||
if (config == null) {
|
||||
throw new ApiNotPrintException("霸王餐信息未配置");
|
||||
}
|
||||
BeanUtil.copyProperties(freeDineConfigEditDTO, config);
|
||||
if (freeDineConfigEditDTO.getUseType() != null && !freeDineConfigEditDTO.getUseType().isEmpty()) {
|
||||
config.setUseType(JSONObject.toJSONString(freeDineConfigEditDTO.getUseType()));
|
||||
}
|
||||
return updateById(config);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.account.mapper.FreeDineConfigMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user