1
phpcjl
2024-12-16 754cb23d64173526b408510b308b5920fad9355c
1
1个文件已修改
31 ■■■■ 已修改文件
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RedPackegeSetController.java 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/RedPackegeSetController.java
@@ -6,15 +6,13 @@
import com.ruoyi.other.api.domain.RedPackegeSet;
import com.ruoyi.other.service.RedPackegeSetService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
/**
 * <p>
@@ -58,17 +56,20 @@
     * 添加红包配置
     */
    @ApiOperation(value = "添加红包配置", tags = {"管理后台-活动管理-签到红包"})
    @GetMapping("/addRedPackegeSet")
    public R<Void> addRedPackegeSet(RedPackegeSet redPackegeSet){
        RedPackegeSet one = redPackegeSetService.getOne(null);
        if (one==null){
            redPackegeSet.setId(1);
            redPackegeSetService.save(redPackegeSet);
        }else {
            if (one.getId()==null){
                return R.fail("参数错误");
    @PostMapping("/addRedPackegeSet")
    @Transactional(rollbackFor = Exception.class)
    public R<Void> addRedPackegeSet(@RequestBody List<RedPackegeSet> redPackegeSets){
        for (RedPackegeSet redPackegeSet : redPackegeSets) {
            RedPackegeSet one = redPackegeSetService.getOne(null);
            if (one==null){
                redPackegeSet.setId(1);
                redPackegeSetService.save(redPackegeSet);
            }else {
                if (one.getId()==null){
                    return R.fail("参数错误");
                }
                redPackegeSetService.updateById(redPackegeSet);
            }
            redPackegeSetService.updateById(redPackegeSet);
        }
        return R.ok();
    }