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.FinanceCouponUserRecord; import com.gear.finance.service.IFinanceCouponUserRecordService; import com.gear.common.utils.poi.ExcelUtil; /** * 券领取记录Controller * * @author czx * @date 2023-11-16 */ @RestController @RequestMapping("/finance/couponRecord") public class FinanceCouponUserRecordController extends BaseController { @Autowired private IFinanceCouponUserRecordService financeCouponUserRecordService; /** * 查询券领取记录列表 */ @PreAuthorize("@ss.hasPermi('finance:couponRecord:list')") @GetMapping("/list") public Result> list(FinanceCouponUserRecord financeCouponUserRecord, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize){ QueryWrapper queryWrapper = WhereBuilder.build(financeCouponUserRecord); Page page = new Page(pageNo, pageSize); IPage pageList = financeCouponUserRecordService.page(page, queryWrapper); return Result.OK(pageList); } /** * 导出券领取记录列表 */ @PreAuthorize("@ss.hasPermi('finance:couponRecord:export')") @Log(title = "券领取记录", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, FinanceCouponUserRecord financeCouponUserRecord){ QueryWrapper queryWrapper = WhereBuilder.build(financeCouponUserRecord); List list = financeCouponUserRecordService.list(queryWrapper); ExcelUtil util = new ExcelUtil(FinanceCouponUserRecord.class); util.exportExcel(response, list, "券领取记录数据"); } /** * 获取券领取记录详细信息 */ @PreAuthorize("@ss.hasPermi('finance:couponRecord:query')") @GetMapping(value = "/{id}") public Result getInfo(@PathVariable("id") String id){ FinanceCouponUserRecord financeCouponUserRecord = financeCouponUserRecordService.getById(id); if(financeCouponUserRecord==null) { return Result.error("未找到对应数据"); } return Result.OK(financeCouponUserRecord); } /** * 新增券领取记录 */ @PreAuthorize("@ss.hasPermi('finance:couponRecord:add')") @Log(title = "券领取记录", businessType = BusinessType.INSERT) @PostMapping public Result add(@RequestBody FinanceCouponUserRecord financeCouponUserRecord){ financeCouponUserRecordService.save(financeCouponUserRecord); return Result.ok("添加成功!"); } /** * 修改券领取记录 */ @PreAuthorize("@ss.hasPermi('finance:couponRecord:edit')") @Log(title = "券领取记录", businessType = BusinessType.UPDATE) @PutMapping public Result edit(@RequestBody FinanceCouponUserRecord financeCouponUserRecord){ financeCouponUserRecordService.updateById(financeCouponUserRecord); return Result.ok("编辑成功!"); } /** * 删除券领取记录 */ @PreAuthorize("@ss.hasPermi('finance:couponRecord:remove')") @Log(title = "券领取记录", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public Result remove(@PathVariable List ids){ financeCouponUserRecordService.removeBatchByIds(ids); return Result.ok("删除成功!"); } }