管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-10-11 9c5c93a36294b3f14536689d548928196c367de8
src/main/java/com/lf/server/controller/sys/LoginController.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.LoginEntity;
import com.lf.server.entity.sys.UserEntity;
import com.lf.server.service.sys.LoginService;
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.sql.Timestamp;
import java.util.List;
@@ -26,6 +29,9 @@
public class LoginController extends BaseController {
    @Autowired
    LoginService loginService;
    @Autowired
    TokenService tokenService;
    @SysLog()
    @ApiOperation(value = "查询记录数")
@@ -103,12 +109,17 @@
    @SysLog()
    @ApiOperation(value = "插入字典")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "loginEntity", value = "字典实体类", dataType = "com.lf.server.entity.sys.LoginEntity", paramType = "body", example = "")
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "com.lf.server.entity.sys.LoginEntity", paramType = "body", example = "")
    })
    @PostMapping(value = "/insertLogin", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> insertLogin(@RequestBody LoginEntity loginEntity) {
    public ResponseMsg<Integer> insertLogin(@RequestBody LoginEntity entity, HttpServletRequest req) {
        try {
            int count = loginService.insertLogin(loginEntity);
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                entity.setUserid(ue.getId());
            }
            int count = loginService.insertLogin(entity);
            return success(count);
        } catch (Exception ex) {
@@ -119,12 +130,19 @@
    @SysLog()
    @ApiOperation(value = "插入多条字典")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "loginEntity", value = "字典实体类集合", dataType = "List<LoginEntity>", paramType = "body", example = "")
            @ApiImplicitParam(name = "list", value = "实体类集合", dataType = "List<LoginEntity>", paramType = "body", example = "")
    })
    @PostMapping(value = "/insertLogins", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> insertLogins(@RequestBody List<LoginEntity> loginEntity) {
    public ResponseMsg<Integer> insertLogins(@RequestBody List<LoginEntity> list, HttpServletRequest req) {
        try {
            int count = loginService.insertLogins(loginEntity);
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                for (LoginEntity entity : list) {
                    entity.setUserid(ue.getId());
                }
            }
            int count = loginService.insertLogins(list);
            return success(count);
        } catch (Exception ex) {
@@ -169,13 +187,18 @@
    @SysLog()
    @ApiOperation(value = "更新一条字典")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "loginEntity", value = "字典ID集合", dataType = "LoginEntity", paramType = "body", example = "")
            @ApiImplicitParam(name = "entity", value = "实体类", dataType = "LoginEntity", paramType = "body", example = "")
    })
    @ResponseBody
    @PostMapping(value = "/updateLogin", produces = "application/json; charset=UTF-8")
    public ResponseMsg<Integer> updateLogin(@RequestBody LoginEntity loginEntity) {
    public ResponseMsg<Integer> updateLogin(@RequestBody LoginEntity entity, HttpServletRequest req) {
        try {
            int count = loginService.updateLogin(loginEntity);
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue != null) {
                entity.setUserid(ue.getId());
            }
            int count = loginService.updateLogin(entity);
            return success(count);
        } catch (Exception ex) {