Create model and service for GiftRules

pull/8040/head
Qiuyi LI 2024-09-04 17:08:31 +02:00
parent 8f4c39d178
commit 36c0df4e3d
5 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,15 @@
package org.jeecg.modules.business.entity;
import lombok.Data;
@Data
public class GiftRule {
private final String shopCode;
private final String sku;
private final String regex;
private final Boolean matchQuantity;
}

View File

@ -0,0 +1,19 @@
package org.jeecg.modules.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.business.entity.GiftRule;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @Description:
* @Author: jeecg-boot
* @Date: 2024-09-02
* @Version: V1.0
*/
@Repository
public interface GiftRulesMapper extends BaseMapper<GiftRule> {
List<GiftRule> findByShop(List<String> shopCodes);
}

View File

@ -0,0 +1,16 @@
<?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="org.jeecg.modules.business.mapper.GiftRulesMapper">
<select id="findByShop" resultType="org.jeecg.modules.business.entity.GiftRule">
SELECT s.erp_code AS shop_code,
sku.erp_code AS sku,
g.normal_sku_regex AS regex,
g.match_normal_sku_quantity AS match_quantity
FROM gift_rules g JOIN shop s ON g.shop_id = s.id
JOIN sku ON g.gift_sku_id = sku.id
WHERE s.erp_code IN
<foreach collection="shopCodes" separator="," open="(" close=")" item="shopCode">
#{shopCode}
</foreach>
</select>
</mapper>

View File

@ -0,0 +1,17 @@
package org.jeecg.modules.business.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.business.entity.GiftRule;
import java.util.List;
/**
* @Description:
* @Author: jeecg-boot
* @Date: 2024-09-02
* @Version: V1.0
*/
public interface IGiftRulesService extends IService<GiftRule> {
List<GiftRule> findGiftRulesByShopCode(List<String> shopCodes);
}

View File

@ -0,0 +1,34 @@
package org.jeecg.modules.business.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.business.entity.GiftRule;
import org.jeecg.modules.business.mapper.GiftRulesMapper;
import org.jeecg.modules.business.service.IGiftRulesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Description:
* @Author: jeecg-boot
* @Date: 2024-09-02
* @Version: V1.0
*/
@Service
@Slf4j
public class GiftRulesServiceImpl extends ServiceImpl<GiftRulesMapper, GiftRule> implements IGiftRulesService {
@Autowired
private GiftRulesMapper giftRulesMapper;
public GiftRulesServiceImpl(GiftRulesMapper giftRulesMapper) {
this.giftRulesMapper = giftRulesMapper;
}
@Override
public List<GiftRule> findGiftRulesByShopCode(List<String> shopCodes) {
return giftRulesMapper.findByShop(shopCodes);
}
}