| | |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.other.api.domain.RedPackegeSet; |
| | | import com.ruoyi.other.dto.RedPackegeSetDto; |
| | | import com.ruoyi.other.service.RedPackegeSetService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | */ |
| | | @ApiOperation(value = "获取红包配置", tags = {"管理后台-活动管理-签到红包"}) |
| | | @GetMapping("/getRedPackegeSet") |
| | | public R<RedPackegeSet> getRedPackegeSet(){ |
| | | return R.ok(redPackegeSetService.getOne(null)); |
| | | public R<RedPackegeSetDto> getRedPackegeSet(){ |
| | | List<RedPackegeSet> redPackegeSetList = redPackegeSetService.list(); |
| | | RedPackegeSetDto redPackegeSetDto = new RedPackegeSetDto(); |
| | | redPackegeSetDto.setRedPackegeSets(redPackegeSetList); |
| | | return R.ok(redPackegeSetDto); |
| | | } |
| | | |
| | | |
| | |
| | | @ApiOperation(value = "添加红包配置", tags = {"管理后台-活动管理-签到红包"}) |
| | | @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); |
| | | } |
| | | } |
| | | public R<Void> addRedPackegeSet(@RequestBody RedPackegeSetDto redPackegeSets){ |
| | | redPackegeSetService.remove(null); |
| | | List<RedPackegeSet> redPackegeSetList = redPackegeSets.getRedPackegeSets(); |
| | | redPackegeSetService.saveBatch(redPackegeSetList); |
| | | return R.ok(); |
| | | } |
| | | |