MaterialBatchController.java 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package com.bosshand.virgo.api.controller;
  2. import java.util.HashMap;
  3. import java.util.List;
  4. import java.util.Map;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.web.bind.annotation.PathVariable;
  7. import org.springframework.web.bind.annotation.RequestBody;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RequestMethod;
  10. import org.springframework.web.bind.annotation.RestController;
  11. import com.bosshand.virgo.api.model.MaterialBatch;
  12. import com.bosshand.virgo.api.service.MaterialBatchService;
  13. import com.bosshand.virgo.core.model.MgrUser;
  14. import com.bosshand.virgo.core.response.Response;
  15. import com.bosshand.virgo.core.utils.ContextUtils;
  16. import io.swagger.annotations.ApiOperation;
  17. @RestController
  18. public class MaterialBatchController {
  19. @Autowired
  20. private MaterialBatchService materialBatchService;
  21. @ApiOperation(value = "新增", notes = "新增")
  22. @RequestMapping(value = "materialbatch", method = RequestMethod.POST)
  23. public Response addMaterialBatch(@RequestBody MaterialBatch materialBatch) {
  24. MgrUser user = ContextUtils.getCurrentUser();
  25. materialBatch.setCreateBy(user.getName());
  26. materialBatch.setCreateByUserId(user.getId());
  27. return Response.ok(materialBatchService.save(materialBatch));
  28. }
  29. @ApiOperation(value = "编辑", notes = "编辑")
  30. @RequestMapping(value = "materialbatch", method = RequestMethod.PUT)
  31. public Response editMaterialBatch(@RequestBody MaterialBatch materialBatch) {
  32. MgrUser user = ContextUtils.getCurrentUser();
  33. materialBatch.setCreateBy(user.getName());
  34. materialBatch.setCreateByUserId(user.getId());
  35. return Response.ok(materialBatchService.update(materialBatch));
  36. }
  37. @ApiOperation(value = "删除", notes = "删除")
  38. @RequestMapping(value = "materialbatch/{id}", method = RequestMethod.DELETE)
  39. public Response delMaterialBatch(@PathVariable long id) {
  40. materialBatchService.delete(id);
  41. return Response.ok();
  42. }
  43. @ApiOperation(value = "查询列表", notes = "查询列表")
  44. @RequestMapping(value = "materialbatch/queryList", method = RequestMethod.POST)
  45. public Response getMaterialBatchByList(@RequestBody MaterialBatch materialBatch) {
  46. return Response.ok(materialBatchService.queryByList(materialBatch));
  47. }
  48. @ApiOperation(value = "查询", notes = "查询")
  49. @RequestMapping(value = "materialbatch/query", method = RequestMethod.POST)
  50. public Response getMaterialBatchByProjectId(@RequestBody MaterialBatch materialBatch) {
  51. return Response.ok(materialBatchService.query(materialBatch));
  52. }
  53. @ApiOperation(value = "分页查询", notes = "分页查询")
  54. @RequestMapping(value = "materialbatch/query/{currPage}/{pageSize}", method = RequestMethod.POST)
  55. public Response getMaterialBatchByProjectId(@RequestBody MaterialBatch materialBatch, @PathVariable int currPage, @PathVariable int pageSize) {
  56. List<MaterialBatch> list = materialBatchService.query(materialBatch, currPage, pageSize);
  57. List<MaterialBatch> totalCount = materialBatchService.query(materialBatch);
  58. Map<String, Object> result = new HashMap<String, Object>();
  59. result.put("dataList", list);
  60. result.put("totalCount", totalCount.size());
  61. return Response.ok(result);
  62. }
  63. }