package com.tievd.jyz.controller; 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.tievd.cube.commons.annotations.AutoLog; import com.tievd.cube.commons.annotations.DictApi; import com.tievd.cube.commons.base.CubeController; import com.tievd.cube.commons.base.Result; import com.tievd.cube.commons.utils.SystemContextUtil; import com.tievd.cube.modules.system.model.LoginUser; import com.tievd.jyz.entity.SpotcheckEvent; import com.tievd.jyz.entity.vo.EventReqVo; import com.tievd.jyz.service.ISpotcheckEventService; import com.tievd.jyz.util.BusinessUtil; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.sql.Timestamp; import java.util.Arrays; /** * SpotcheckEvent * * @author cube * @since 2023-08-15 * @version V2.0.0 */ @Slf4j @DictApi @RestController @RequestMapping("/jyz/spotcheckEvent") @Tag(name = "抽查记录接口") public class SpotcheckEventController extends CubeController { @Autowired private ISpotcheckEventService spotcheckEventService; /** * 分页列表查询 */ @GetMapping("/list") @Operation(summary = "抽查记录列表") public Result> queryPageList(EventReqVo eventReqVo, @RequestParam(defaultValue="1") Integer pageNo, @RequestParam(defaultValue="10") Integer pageSize, HttpServletRequest req) { QueryWrapper queryWrapper = BusinessUtil.getEventQueryWrapper(eventReqVo, new SpotcheckEvent()); Page page = new Page<>(pageNo, pageSize); IPage pageList = spotcheckEventService.page(page, queryWrapper); return Result.ok(pageList); } @AutoLog("OilEvent-事件审核") @PostMapping("/audit") @Operation(summary = "抽查事件审核") public Result audit(@RequestBody SpotcheckEvent event) { LoginUser sysUser = SystemContextUtil.currentLoginUser(); event.setAuditUser(sysUser.getUsername()); event.setAuditTime(new Timestamp(System.currentTimeMillis())); spotcheckEventService.updateById(event); return Result.ok(); } /** * 添加 */ @AutoLog("SpotcheckEvent-添加") @PostMapping("/add") public Result add(@RequestBody SpotcheckEvent spotcheckEvent) { spotcheckEventService.save(spotcheckEvent); return Result.ok(); } /** * 编辑 */ @AutoLog("SpotcheckEvent-编辑") @PutMapping("/edit") public Result edit(@RequestBody SpotcheckEvent spotcheckEvent) { spotcheckEventService.updateById(spotcheckEvent); return Result.ok(); } /** * 通过id删除 */ @AutoLog("SpotcheckEvent-通过id删除") @DeleteMapping("/delete") public Result delete(@RequestParam String id) { spotcheckEventService.removeById(id); return Result.ok(); } /** * 批量删除 */ @AutoLog("SpotcheckEvent-批量删除") @DeleteMapping("/deleteBatch") public Result deleteBatch(@RequestParam String ids) { this.spotcheckEventService.removeByIds(Arrays.asList(ids.split(","))); return Result.ok(); } /** * 通过id查询 */ @GetMapping("/queryById") public Result queryById(@RequestParam String id) { SpotcheckEvent spotcheckEvent = spotcheckEventService.getById(id); return Result.ok(spotcheckEvent); } /** * 导出excel */ @RequestMapping("/exportXls") public void exportXls(HttpServletRequest request, HttpServletResponse response, SpotcheckEvent spotcheckEvent) throws IOException { super.exportXls(request, response, spotcheckEvent, "SpotcheckEvent"); } /** * 通过excel导入数据 */ @PostMapping("/importExcel") public Result importExcel(HttpServletRequest request) throws Exception { return super.importExcel(request, SpotcheckEvent.class); } }