| | |
| | | package com.ycl.jxkg.controller.admin; |
| | | |
| | | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.base.BaseApiController; |
| | | import com.ycl.jxkg.base.Result; |
| | | import com.ycl.jxkg.domain.entity.Subject; |
| | | import com.ycl.jxkg.service.SubjectService; |
| | | import com.ycl.jxkg.utils.PageInfoHelper; |
| | | import com.ycl.jxkg.domain.vo.admin.education.SubjectEditRequestVO; |
| | | import com.ycl.jxkg.domain.vo.admin.education.SubjectPageRequestVO; |
| | | import com.ycl.jxkg.domain.vo.admin.education.SubjectResponseVO; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.ycl.jxkg.service.SubjectService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | |
| | | @RequestMapping(value = "/page", method = RequestMethod.POST) |
| | | public Result<PageInfo<SubjectResponseVO>> pageList(@RequestBody SubjectPageRequestVO model) { |
| | | PageInfo<Subject> pageInfo = subjectService.page(model); |
| | | PageInfo<SubjectResponseVO> page = PageInfoHelper.copyMap(pageInfo, e -> { |
| | | SubjectResponseVO vo = new SubjectResponseVO(); |
| | | BeanUtils.copyProperties(e, vo); |
| | | return vo; |
| | | }); |
| | | return Result.ok(page); |
| | | return Result.ok(subjectService.page(model)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/edit", method = RequestMethod.POST) |
| | | public Result edit(@RequestBody @Valid SubjectEditRequestVO model) { |
| | | public Result<String> edit(@RequestBody @Valid SubjectEditRequestVO model) { |
| | | Subject subject = new Subject(); |
| | | BeanUtils.copyProperties(model, subject); |
| | | if (model.getId() == null) { |
| | | subjectService.save(subject); |
| | | subjectService.save(subject.setCreateUser(getCurrentUser().getId())); |
| | | } else { |
| | | subjectService.updateById(subject); |
| | | } |
| | | return Result.ok(); |
| | | return Result.ok("操作成功"); |
| | | } |
| | | |
| | | @RequestMapping(value = "/select/{id}", method = RequestMethod.POST) |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) |
| | | public Result delete(@PathVariable Integer id) { |
| | | Subject subject = subjectService.getById(id); |
| | | subjectService.updateById(subject); |
| | | return Result.ok(); |
| | | public Result<Boolean> delete(@PathVariable Integer id) { |
| | | return Result.ok(subjectService.removeById(id)); |
| | | } |
| | | |
| | | @GetMapping(value = "/getItemOrder") |
| | | public Result<Integer> getItemOrder() { |
| | | return Result.ok(subjectService.getItemOrder()); |
| | | } |
| | | |
| | | @PostMapping(value = "/status") |
| | | public Result<String> status(@RequestBody Subject subject) { |
| | | subjectService.updateStatus(subject); |
| | | return Result.ok("操作成功"); |
| | | } |
| | | |
| | | } |