package com.gear.admin.controller.finance; import java.util.List; import javax.servlet.http.HttpServletResponse; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.gear.common.builder.WhereBuilder; import com.gear.common.vo.Result; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.gear.common.annotation.Log; import com.gear.common.core.controller.BaseController; import com.gear.common.enums.BusinessType; import com.gear.finance.domain.FinanceLotteryUserRecord; import com.gear.finance.service.IFinanceLotteryUserRecordService; import com.gear.common.utils.poi.ExcelUtil; /** * 抽奖记录Controller * * @author czx * @date 2023-11-16 */ @RestController @RequestMapping("/finance/lotteryRecord") public class FinanceLotteryUserRecordController extends BaseController { @Autowired private IFinanceLotteryUserRecordService financeLotteryUserRecordService; /** * 查询抽奖记录列表 */ @PreAuthorize("@ss.hasPermi('finance:lotteryRecord:list')") @GetMapping("/list") public Result> list(FinanceLotteryUserRecord financeLotteryUserRecord, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ QueryWrapper queryWrapper = WhereBuilder.build(financeLotteryUserRecord); Page page = new Page(pageNo, pageSize); IPage pageList = financeLotteryUserRecordService.page(page, queryWrapper); return Result.OK(pageList); } /** * 导出抽奖记录列表 */ @PreAuthorize("@ss.hasPermi('finance:lotteryRecord:export')") @Log(title = "抽奖记录", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, FinanceLotteryUserRecord financeLotteryUserRecord){ QueryWrapper queryWrapper = WhereBuilder.build(financeLotteryUserRecord); List list = financeLotteryUserRecordService.list(queryWrapper); ExcelUtil util = new ExcelUtil(FinanceLotteryUserRecord.class); util.exportExcel(response, list, "抽奖记录数据"); } /** * 获取抽奖记录详细信息 */ @PreAuthorize("@ss.hasPermi('finance:lotteryRecord:query')") @GetMapping(value = "/{id}") public Result getInfo(@PathVariable("id") String id){ FinanceLotteryUserRecord financeLotteryUserRecord = financeLotteryUserRecordService.getById(id); if(financeLotteryUserRecord==null) { return Result.error("未找到对应数据"); } return Result.OK(financeLotteryUserRecord); } /** * 新增抽奖记录 */ @PreAuthorize("@ss.hasPermi('finance:lotteryRecord:add')") @Log(title = "抽奖记录", businessType = BusinessType.INSERT) @PostMapping public Result add(@RequestBody FinanceLotteryUserRecord financeLotteryUserRecord){ financeLotteryUserRecordService.save(financeLotteryUserRecord); return Result.ok("添加成功!"); } /** * 修改抽奖记录 */ @PreAuthorize("@ss.hasPermi('finance:lotteryRecord:edit')") @Log(title = "抽奖记录", businessType = BusinessType.UPDATE) @PutMapping public Result edit(@RequestBody FinanceLotteryUserRecord financeLotteryUserRecord){ financeLotteryUserRecordService.updateById(financeLotteryUserRecord); return Result.ok("编辑成功!"); } /** * 删除抽奖记录 */ @PreAuthorize("@ss.hasPermi('finance:lotteryRecord:remove')") @Log(title = "抽奖记录", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public Result remove(@PathVariable List ids){ financeLotteryUserRecordService.removeBatchByIds(ids); return Result.ok("删除成功!"); } }