|  |  |  | 
|---|
|  |  |  | import com.doumee.core.annotation.excel.ExcelExporter; | 
|---|
|  |  |  | import com.doumee.core.annotation.pr.PreventRepeat; | 
|---|
|  |  |  | import com.doumee.core.model.ApiResponse; | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.model.PageData; | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Problems; | 
|---|
|  |  |  | import com.doumee.service.business.ProblemsService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import org.apache.shiro.authz.annotation.RequiresPermissions; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author 江蹄蹄 | 
|---|
|  |  |  | * @date 2023/11/23 18:16 | 
|---|
|  |  |  | * @date 2023/11/30 15:33 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Api(tags = "试题信息表") | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("新建") | 
|---|
|  |  |  | @PostMapping("/create") | 
|---|
|  |  |  | @RequiresPermissions("business:problems:create") | 
|---|
|  |  |  | //@RequiresPermissions("business:problems:create") | 
|---|
|  |  |  | public ApiResponse create(@RequestBody Problems problems) { | 
|---|
|  |  |  | return ApiResponse.success(problemsService.create(problems)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID删除") | 
|---|
|  |  |  | @GetMapping("/delete/{id}") | 
|---|
|  |  |  | @RequiresPermissions("business:problems:delete") | 
|---|
|  |  |  | //@RequiresPermissions("business:problems:delete") | 
|---|
|  |  |  | public ApiResponse deleteById(@PathVariable Integer id) { | 
|---|
|  |  |  | problemsService.deleteById(id); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("批量删除") | 
|---|
|  |  |  | @GetMapping("/delete/batch") | 
|---|
|  |  |  | @RequiresPermissions("business:problems:delete") | 
|---|
|  |  |  | //@RequiresPermissions("business:problems:delete") | 
|---|
|  |  |  | public ApiResponse deleteByIdInBatch(@RequestParam String ids) { | 
|---|
|  |  |  | String [] idArray = ids.split(","); | 
|---|
|  |  |  | List<Integer> idList = new ArrayList<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID修改") | 
|---|
|  |  |  | @PostMapping("/updateById") | 
|---|
|  |  |  | @RequiresPermissions("business:problems:update") | 
|---|
|  |  |  | //@RequiresPermissions("business:problems:update") | 
|---|
|  |  |  | public ApiResponse updateById(@RequestBody Problems problems) { | 
|---|
|  |  |  | problemsService.updateById(problems); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("分页查询") | 
|---|
|  |  |  | @PostMapping("/page") | 
|---|
|  |  |  | @RequiresPermissions("business:problems:query") | 
|---|
|  |  |  | //@RequiresPermissions("business:problems:query") | 
|---|
|  |  |  | public ApiResponse<PageData<Problems>> findPage (@RequestBody PageWrap<Problems> pageWrap) { | 
|---|
|  |  |  | return ApiResponse.success(problemsService.findPage(pageWrap)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("导出Excel") | 
|---|
|  |  |  | @PostMapping("/exportExcel") | 
|---|
|  |  |  | @RequiresPermissions("business:problems:exportExcel") | 
|---|
|  |  |  | //@RequiresPermissions("business:problems:exportExcel") | 
|---|
|  |  |  | public void exportExcel (@RequestBody PageWrap<Problems> pageWrap, HttpServletResponse response) { | 
|---|
|  |  |  | ExcelExporter.build(Problems.class).export(problemsService.findPage(pageWrap).getRecords(), "试题信息表", response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID查询") | 
|---|
|  |  |  | @GetMapping("/{id}") | 
|---|
|  |  |  | @RequiresPermissions("business:problems:query") | 
|---|
|  |  |  | //@RequiresPermissions("business:problems:query") | 
|---|
|  |  |  | public ApiResponse findById(@PathVariable Integer id) { | 
|---|
|  |  |  | return ApiResponse.success(problemsService.findById(id)); | 
|---|
|  |  |  | } | 
|---|