12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package com.bosshand.virgo.api.controller;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import com.bosshand.virgo.api.model.MaterialBatch;
- import com.bosshand.virgo.api.service.MaterialBatchService;
- import com.bosshand.virgo.core.model.MgrUser;
- import com.bosshand.virgo.core.response.Response;
- import com.bosshand.virgo.core.utils.ContextUtils;
- import io.swagger.annotations.ApiOperation;
- @RestController
- public class MaterialBatchController {
- @Autowired
- private MaterialBatchService materialBatchService;
- @ApiOperation(value = "新增", notes = "新增")
- @RequestMapping(value = "materialbatch", method = RequestMethod.POST)
- public Response addMaterialBatch(@RequestBody MaterialBatch materialBatch) {
- MgrUser user = ContextUtils.getCurrentUser();
- materialBatch.setCreateBy(user.getName());
- materialBatch.setCreateByUserId(user.getId());
- return Response.ok(materialBatchService.save(materialBatch));
- }
- @ApiOperation(value = "编辑", notes = "编辑")
- @RequestMapping(value = "materialbatch", method = RequestMethod.PUT)
- public Response editMaterialBatch(@RequestBody MaterialBatch materialBatch) {
- MgrUser user = ContextUtils.getCurrentUser();
- materialBatch.setCreateBy(user.getName());
- materialBatch.setCreateByUserId(user.getId());
- return Response.ok(materialBatchService.update(materialBatch));
- }
- @ApiOperation(value = "删除", notes = "删除")
- @RequestMapping(value = "materialbatch/{id}", method = RequestMethod.DELETE)
- public Response delMaterialBatch(@PathVariable long id) {
- materialBatchService.delete(id);
- return Response.ok();
- }
- @ApiOperation(value = "查询列表", notes = "查询列表")
- @RequestMapping(value = "materialbatch/queryList", method = RequestMethod.POST)
- public Response getMaterialBatchByList(@RequestBody MaterialBatch materialBatch) {
- return Response.ok(materialBatchService.queryByList(materialBatch));
- }
-
- @ApiOperation(value = "查询", notes = "查询")
- @RequestMapping(value = "materialbatch/query", method = RequestMethod.POST)
- public Response getMaterialBatchByProjectId(@RequestBody MaterialBatch materialBatch) {
- return Response.ok(materialBatchService.query(materialBatch));
- }
-
- @ApiOperation(value = "分页查询", notes = "分页查询")
- @RequestMapping(value = "materialbatch/query/{currPage}/{pageSize}", method = RequestMethod.POST)
- public Response getMaterialBatchByProjectId(@RequestBody MaterialBatch materialBatch, @PathVariable int currPage, @PathVariable int pageSize) {
- List<MaterialBatch> list = materialBatchService.query(materialBatch, currPage, pageSize);
- List<MaterialBatch> totalCount = materialBatchService.query(materialBatch);
- Map<String, Object> result = new HashMap<String, Object>();
- result.put("dataList", list);
- result.put("totalCount", totalCount.size());
- return Response.ok(result);
- }
- }
|