管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-10-13 773643f7aaf8d7287aa320105492f0430a5c4698
src/main/java/com/lf/server/controller/sys/ArgsController.java
@@ -4,7 +4,9 @@
import com.lf.server.controller.all.BaseController;
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.entity.sys.ArgsEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.service.sys.ArgsService;
import com.lf.server.service.sys.TokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -12,6 +14,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
@@ -24,6 +27,9 @@
public class ArgsController extends BaseController {
    @Autowired
    ArgsService argsService;
    @Autowired
    TokenService tokenService;
    @SysLog()
    @ApiOperation(value = "查询记录数")
@@ -117,14 +123,19 @@
        }
    }
    @SysLog()
    @ApiOperation(value = "添加数据")
    /*@SysLog()
    @ApiOperation(value = "插入一条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "ArgsEntity", paramType = "body")
    })
    @PostMapping(value = "/insert", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> insert(@RequestBody ArgsEntity entity) {
    public ResponseMsg<Integer> insert(@RequestBody ArgsEntity entity, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                entity.setCreateUser(ue.getId());
            }
            int count = argsService.insert(entity);
            return success(count);
@@ -134,13 +145,20 @@
    }
    @SysLog()
    @ApiOperation(value = "批量添加")
    @ApiOperation(value = "插入多条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "ArgsEntity", paramType = "body")
    })
    @PostMapping(value = "/inserts", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> inserts(@RequestBody List<ArgsEntity> list) {
    public ResponseMsg<Integer> inserts(@RequestBody List<ArgsEntity> list, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                for (ArgsEntity entity : list) {
                    entity.setCreateUser(ue.getId());
                }
            }
            int count = argsService.inserts(list);
            return success(count);
@@ -150,7 +168,7 @@
    }
    @SysLog()
    @ApiOperation(value = "刪除数据")
    @ApiOperation(value = "删除一条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1")
    })
@@ -166,7 +184,7 @@
    }
    @SysLog()
    @ApiOperation(value = "批量删除")
    @ApiOperation(value = "删除多条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "ID数组", dataType = "Integer", paramType = "query", example = "1,2")
    })
@@ -183,17 +201,22 @@
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    }*/
    @SysLog()
    @ApiOperation(value = "修改数据")
    @ApiOperation(value = "更新一条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "ArgsEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/update", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> update(@RequestBody ArgsEntity entity) {
    public ResponseMsg<Integer> update(@RequestBody ArgsEntity entity, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                entity.setUpdateUser(ue.getId());
            }
            int count = argsService.update(entity);
            return success(count);
@@ -202,20 +225,27 @@
        }
    }
    @SysLog()
    @ApiOperation(value = "批量修改")
    /*@SysLog()
    @ApiOperation(value = "更新多条")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "ArgsEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/updates", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> updates(@RequestBody List<ArgsEntity> list) {
    public ResponseMsg<Integer> updates(@RequestBody List<ArgsEntity> list, HttpServletRequest req) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                for (ArgsEntity entity : list) {
                    entity.setUpdateUser(ue.getId());
                }
            }
            int count = argsService.updates(list);
            return success(count);
        } catch (Exception ex) {
            return fail(ex.getMessage(), -1);
        }
    }
    }*/
}