| | |
| | | package com.ycl.jxkg.controller.admin; |
| | | |
| | | import com.ycl.jxkg.base.SystemCode; |
| | | import com.ycl.jxkg.group.Update; |
| | | import com.ycl.jxkg.group.Add; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import lombok.RequiredArgsConstructor; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import com.ycl.jxkg.service.ExamTemplateService; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.form.ExamTemplateForm; |
| | | import com.ycl.jxkg.domain.query.ExamTemplateQuery; |
| | | import com.ycl.jxkg.group.Add; |
| | | import com.ycl.jxkg.group.Update; |
| | | import com.ycl.jxkg.service.ExamTemplateService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | 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.List; |
| | | import static com.ycl.jxkg.enums.DeductTypeEnum.EachCorrect; |
| | | import static com.ycl.jxkg.enums.DeductTypeEnum.PartCorrect; |
| | | |
| | | /** |
| | | * 随机试卷模板 前端控制器 |
| | | * |
| | | * @author 开发人员名字 |
| | | * @since 2024-06-03 |
| | | * @author flq |
| | | * @since 2024-06-05 |
| | | */ |
| | | @Validated |
| | | @RequiredArgsConstructor |
| | | @Api(value = "随机试卷模板", tags = "随机试卷模板管理") |
| | | @RestController |
| | | @RequestMapping("/exam-template") |
| | | @RequestMapping("/api/admin/exam-template") |
| | | public class ExamTemplateController { |
| | | |
| | | private final ExamTemplateService examTemplateService; |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "添加", notes = "添加") |
| | | @PreAuthorize("hasAuthority('examTemplate:add')") |
| | | public Result add(@RequestBody @Validated(Add.class) ExamTemplateForm form) { |
| | | //参数校验 |
| | | if(form.getDeductType()!=null && (form.getDeductType() ==PartCorrect.getCode() || form.getDeductType() == EachCorrect.getCode()) && (form.getDeductTypeScore() ==null || form.getDeductTypeScore().compareTo(BigDecimal.ZERO) <= 0)){ |
| | | return Result.fail(SystemCode.ParameterValidError.getCode(),"多选评分不能为0或空"); |
| | | } |
| | | return examTemplateService.add(form); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "修改", notes = "修改") |
| | | @PreAuthorize("hasAuthority('examTemplate:edit')") |
| | | public Result update(@RequestBody @Validated(Update.class) ExamTemplateForm form) { |
| | | //参数校验 |
| | | if(form.getDeductType()!=null && (form.getDeductType() ==PartCorrect.getCode() || form.getDeductType() == EachCorrect.getCode()) && (form.getDeductTypeScore() ==null || form.getDeductTypeScore().compareTo(BigDecimal.ZERO) <= 0)){ |
| | | return Result.fail(SystemCode.ParameterValidError.getCode(),"多选评分不能为0或空"); |
| | | } |
| | | return examTemplateService.update(form); |
| | | } |
| | | |
| | | @DeleteMapping("/{id}") |
| | | @ApiOperation(value = "ID删除", notes = "ID删除") |
| | | @PreAuthorize("hasAuthority('examTemplate:del')") |
| | | public Result removeById(@PathVariable("id") String id) { |
| | | return examTemplateService.removeById(id); |
| | | } |
| | | |
| | | @DeleteMapping("/batch") |
| | | @ApiOperation(value = "批量删除", notes = "批量删除") |
| | | @PreAuthorize("hasAuthority('examTemplate:del:batch')") |
| | | public Result remove(@RequestBody @NotEmpty(message = "请选择数据") List<String> ids) { |
| | | return examTemplateService.remove(ids); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | | @ApiOperation(value = "分页", notes = "分页") |
| | | @PreAuthorize("hasAuthority('examTemplate:page')") |
| | | public Result page(ExamTemplateQuery query) { |
| | | return examTemplateService.page(query); |
| | | } |
| | | |
| | | @GetMapping("/{id}") |
| | | @ApiOperation(value = "详情", notes = "详情") |
| | | @PreAuthorize("hasAuthority('examTemplate:detail')") |
| | | public Result detail(@PathVariable("id") Integer id) { |
| | | return examTemplateService.detail(id); |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | @PreAuthorize("hasAuthority('examTemplate:list')") |
| | | @ApiOperation(value = "列表", notes = "列表") |
| | | public Result list() { |
| | | return examTemplateService.all(); |