|
@@ -0,0 +1,84 @@
|
|
|
+package com.imed.costaccount.web;
|
|
|
+
|
|
|
+import com.imed.costaccount.common.util.PageUtils;
|
|
|
+import com.imed.costaccount.common.util.Result;
|
|
|
+import com.imed.costaccount.model.Product;
|
|
|
+import com.imed.costaccount.model.User;
|
|
|
+import com.imed.costaccount.service.ProductService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 成本管理表
|
|
|
+ *
|
|
|
+ * @author huangrui
|
|
|
+ * @date 2021-07-28 18:44:20
|
|
|
+ */
|
|
|
+@Api(tags = "收入及成本项目管理")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/costAccount/product")
|
|
|
+public class ProductController {
|
|
|
+
|
|
|
+ private final ProductService productService;
|
|
|
+
|
|
|
+ public ProductController(ProductService productService) {
|
|
|
+ this.productService = productService;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分页查询列表
|
|
|
+ */
|
|
|
+ @ApiOperation("成本项目列表")
|
|
|
+ @GetMapping("/list")
|
|
|
+ public Result list(@RequestParam(defaultValue = "1", value = "page") Integer page,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
+ @RequestParam(value = "name", required = false) String name){
|
|
|
+ User user = (User) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ PageUtils pageUtils = productService.selectList(page, pageSize,name, user);
|
|
|
+ return Result.ok(pageUtils);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 信息
|
|
|
+ */
|
|
|
+ @RequestMapping("/info/{id}")
|
|
|
+ public Result info(@PathVariable("id") Integer id){
|
|
|
+ Product product = productService.getById(id);
|
|
|
+ return Result.ok(product);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存
|
|
|
+ */
|
|
|
+ @RequestMapping("/save")
|
|
|
+ public Result save(@RequestBody Product product){
|
|
|
+ productService.save(product);
|
|
|
+ return Result.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改
|
|
|
+ */
|
|
|
+ @RequestMapping("/update")
|
|
|
+ public Result update(@RequestBody Product product){
|
|
|
+ productService.updateById(product);
|
|
|
+ return Result.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除
|
|
|
+ */
|
|
|
+ @RequestMapping("/delete")
|
|
|
+ public Result delete(@RequestBody Integer[] ids){
|
|
|
+ productService.removeByIds(Arrays.asList(ids));
|
|
|
+ return Result.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|