| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.model.TBigGiftPackage; |
| | | import com.ruoyi.system.query.BigGiftPackageQuery; |
| | | import com.ruoyi.system.service.TBigGiftPackageService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Objects; |
| | | |
| | |
| | | public class TBigGiftPackageController { |
| | | |
| | | private final TBigGiftPackageService tBigGiftPackageService; |
| | | private final TokenService tokenService; |
| | | |
| | | public TBigGiftPackageController(TBigGiftPackageService tBigGiftPackageService) { |
| | | public TBigGiftPackageController(TBigGiftPackageService tBigGiftPackageService, TokenService tokenService) { |
| | | this.tBigGiftPackageService = tBigGiftPackageService; |
| | | this.tokenService = tokenService; |
| | | } |
| | | |
| | | @ApiOperation(value = "大礼包分页列表") |
| | |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @ApiOperation(value = "大礼包详情") |
| | | @GetMapping(value = "/detail/{id}") |
| | | public R<TBigGiftPackage> detail(@PathVariable Integer id ) { |
| | | TBigGiftPackage tBigGiftPackage = tBigGiftPackageService.getById(id); |
| | | return R.ok(tBigGiftPackage); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "大礼包添加") |
| | | @PostMapping(value = "/add") |
| | | @Log(title = "大礼包-添加", businessType = BusinessType.INSERT) |
| | | public R<String> add(@RequestBody TBigGiftPackage tBigGiftPackage) { |
| | | |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | tBigGiftPackage.setCreateUserId(loginUser.getUserId()); |
| | | boolean save = tBigGiftPackageService.save(tBigGiftPackage); |
| | | if (save) { |
| | | return R.ok("添加成功"); |
| | | } |
| | | return R.fail("添加失败"); |
| | | } |
| | | |
| | | @ApiOperation(value = "大礼包修改") |
| | | @PostMapping(value = "/update") |
| | | @Log(title = "大礼包-修改", businessType = BusinessType.UPDATE) |
| | | public R<String> update(@RequestBody TBigGiftPackage tBigGiftPackage) { |
| | | |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | tBigGiftPackage.setUpdateUserId(loginUser.getUserId()); |
| | | boolean update = tBigGiftPackageService.updateById(tBigGiftPackage); |
| | | if (update) { |
| | | return R.ok("修改成功"); |
| | | } |
| | | return R.fail("修改失败"); |
| | | } |
| | | |
| | | @ApiOperation(value = "大礼包删除") |
| | | @DeleteMapping(value = "/delete/{id}") |
| | | @Log(title = "大礼包-删除", businessType = BusinessType.DELETE) |
| | | public R<String> delete(@PathVariable Integer id ) { |
| | | TBigGiftPackage bigGiftPackage = tBigGiftPackageService.getById(id); |
| | | bigGiftPackage.setStatus(0); |
| | | bigGiftPackage.setUpdateUserId(tokenService.getLoginUser().getUserId()); |
| | | boolean remove = tBigGiftPackageService.updateById(bigGiftPackage); |
| | | if (remove) { |
| | | return R.ok("删除成功"); |
| | | } |
| | | return R.fail("删除失败"); |
| | | } |
| | | } |
| | | |