package com.ycl.jxkg.controller.admin; import com.ycl.jxkg.base.BaseApiController; import com.ycl.jxkg.base.Result; import com.ycl.jxkg.domain.entity.TaskExam; import com.ycl.jxkg.service.TaskExamService; import com.ycl.jxkg.utils.DateTimeUtil; import com.ycl.jxkg.utils.PageInfoHelper; import com.ycl.jxkg.domain.vo.admin.task.TaskPageRequestVO; import com.ycl.jxkg.domain.vo.admin.task.TaskPageResponseVO; import com.ycl.jxkg.domain.vo.admin.task.TaskRequestVO; import com.github.pagehelper.PageInfo; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; @RequiredArgsConstructor @RestController("AdminTaskController") @RequestMapping(value = "/api/admin/task") public class TaskController extends BaseApiController { private final TaskExamService taskExamService; @RequestMapping(value = "/page", method = RequestMethod.POST) public Result> pageList(@RequestBody TaskPageRequestVO model) { PageInfo pageInfo = taskExamService.page(model); PageInfo page = PageInfoHelper.copyMap(pageInfo, m -> { TaskPageResponseVO vo = new TaskPageResponseVO(); BeanUtils.copyProperties(m, vo); vo.setCreateTime(DateTimeUtil.dateFormat(m.getCreateTime())); return vo; }); return Result.ok(page); } @RequestMapping(value = "/edit", method = RequestMethod.POST) public Result edit(@RequestBody @Valid TaskRequestVO model) { taskExamService.edit(model, getCurrentUser()); TaskRequestVO vm = taskExamService.taskExamToVM(model.getId()); return Result.ok(vm); } @RequestMapping(value = "/select/{id}", method = RequestMethod.POST) public Result select(@PathVariable Integer id) { TaskRequestVO vm = taskExamService.taskExamToVM(id); return Result.ok(vm); } @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) public Result delete(@PathVariable Integer id) { TaskExam taskExam = taskExamService.getById(id); taskExamService.updateById(taskExam); return Result.ok(); } }