package com.ruoyi.web.controller.api; 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.*; import java.util.Objects; /** *

* 大礼包 前端控制器 *

* * @author xiaochen * @since 2025-12-08 */ @RestController @RequestMapping("/t-big-gift-package") @Api(tags = "(嘉视达)大礼包") public class TBigGiftPackageController { private final TBigGiftPackageService tBigGiftPackageService; private final TokenService tokenService; public TBigGiftPackageController(TBigGiftPackageService tBigGiftPackageService, TokenService tokenService) { this.tBigGiftPackageService = tBigGiftPackageService; this.tokenService = tokenService; } @ApiOperation(value = "大礼包分页列表") @PostMapping(value = "/pageList") public R> pageList(@RequestBody BigGiftPackageQuery query) { Page tBigGiftPackagePage = new Page<>(query.getPageNum(), query.getPageSize()); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(TBigGiftPackage::getStatus,1); wrapper.like(Objects.nonNull(query.getName()), TBigGiftPackage::getName, query.getName()); wrapper.orderByDesc(TBigGiftPackage::getCreateTime); Page pageInfo = tBigGiftPackageService.page(tBigGiftPackagePage, wrapper); return R.ok(pageInfo); } @ApiOperation(value = "大礼包详情") @GetMapping(value = "/detail/{id}") public R 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 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 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 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("删除失败"); } }