package com.ycl.jxkg.controller.admin; import com.ycl.jxkg.base.BaseApiController; import com.ycl.jxkg.base.Result; import com.ycl.jxkg.domain.form.ExamCheatForm; import com.ycl.jxkg.domain.query.ExamCheatQuery; import com.ycl.jxkg.group.Add; import com.ycl.jxkg.group.Update; import com.ycl.jxkg.service.ExamCheatService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.undertow.util.DateUtils; import lombok.RequiredArgsConstructor; import org.apache.poi.ss.usermodel.DateUtil; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.validation.constraints.NotEmpty; import java.util.Date; import java.util.List; /** * 考试作弊记录 前端控制器 * * @author gonghl * @since 2024-06-26 */ @Validated @RequiredArgsConstructor @Api(value = "考试作弊记录", tags = "考试作弊记录管理") @RestController @RequestMapping("/api/admin/cheat") public class ExamCheatController extends BaseApiController { private final ExamCheatService examCheatService; @PostMapping @ApiOperation(value = "添加", notes = "添加") @PreAuthorize("hasAuthority('examCheat:add')") public Result add(@RequestBody @Validated(Add.class) ExamCheatForm form) { form.setCreateUser(getCurrentUser().getId()); form.setCreateTime(new Date()); return examCheatService.add(form); } @PutMapping @ApiOperation(value = "修改", notes = "修改") @PreAuthorize("hasAuthority('examCheat:edit')") public Result update(@RequestBody @Validated(Update.class) ExamCheatForm form) { return examCheatService.update(form); } @DeleteMapping("/{id}") @ApiOperation(value = "ID删除", notes = "ID删除") @PreAuthorize("hasAuthority('examCheat:del')") public Result removeById(@PathVariable("id") String id) { return examCheatService.removeById(id); } @DeleteMapping("/batch") @ApiOperation(value = "批量删除", notes = "批量删除") @PreAuthorize("hasAuthority('examCheat:del:batch')") public Result remove(@RequestBody @NotEmpty(message = "请选择数据") List ids) { return examCheatService.remove(ids); } @GetMapping("/page") @ApiOperation(value = "分页", notes = "分页") @PreAuthorize("hasAuthority('examCheat:page')") public Result page(ExamCheatQuery query) { return examCheatService.page(query); } @GetMapping("/{id}") @ApiOperation(value = "详情", notes = "详情") @PreAuthorize("hasAuthority('examCheat:detail')") public Result detail(@PathVariable("id") Integer id) { return examCheatService.detail(id); } @GetMapping("/list") @PreAuthorize("hasAuthority('examCheat:list')") @ApiOperation(value = "列表", notes = "列表") public Result list() { return examCheatService.all(); } }