Authored by zhaoyue

Merge branch 'zhaoyue-dev' into 'master'

Zhaoyue dev



See merge request !18
  1 +git pull
1 git add --all src/* 2 git add --all src/*
2 git add push.sh 3 git add push.sh
3 git add pom.xml 4 git add pom.xml
@@ -15,4 +15,20 @@ public class TokenModel { @@ -15,4 +15,20 @@ public class TokenModel {
15 15
16 //随机生成的uuid 16 //随机生成的uuid
17 private String token; 17 private String token;
  18 +
  19 + public String getUserId() {
  20 + return userId;
  21 + }
  22 +
  23 + public void setUserId(String userId) {
  24 + this.userId = userId;
  25 + }
  26 +
  27 + public String getToken() {
  28 + return token;
  29 + }
  30 +
  31 + public void setToken(String token) {
  32 + this.token = token;
  33 + }
18 } 34 }
1 -package com.xkl.controller.uploadsoft;  
2 -  
3 -import com.wordnik.swagger.annotations.ApiImplicitParam;  
4 -import com.wordnik.swagger.annotations.ApiImplicitParams;  
5 -import com.wordnik.swagger.annotations.ApiOperation;  
6 -import com.xkl.authorization.annotation.*;  
7 -import com.xkl.authorization.manager.ITokenManager;  
8 -import com.xkl.config.Constants;  
9 -import com.xkl.config.ResultStatus;  
10 -import com.xkl.domain.User;  
11 -import com.xkl.domain.XklAdminEntity;  
12 -import com.xkl.domain.XklCompanyEntity;  
13 -import com.xkl.domain.XklMemberEntity;  
14 -import com.xkl.model.AdminInfoModel;  
15 -import com.xkl.model.ResultModel;  
16 -import com.xkl.repository.AdminRepository;  
17 -import com.xkl.repository.UserRepository;  
18 -import com.xkl.repository.XklCompanyRepository;  
19 -import com.xkl.repository.XklMemberRespository;  
20 -import com.xkl.security.AntiXSS;  
21 -import com.xkl.security.SecurityTool;  
22 -import org.springframework.beans.factory.annotation.Autowired;  
23 -import org.springframework.http.HttpStatus;  
24 -import org.springframework.http.ResponseEntity;  
25 -import org.springframework.util.Assert;  
26 -import org.springframework.web.bind.annotation.RequestMapping;  
27 -import org.springframework.web.bind.annotation.RequestMethod;  
28 -import org.springframework.web.bind.annotation.RequestParam;  
29 -import org.springframework.web.bind.annotation.RestController;  
30 -  
31 -import javax.servlet.http.HttpServletRequest;  
32 -  
33 -/**  
34 - * 操作员信息查询接口  
35 - */  
36 -@RestController  
37 -@RequestMapping("/adminInfo")  
38 -public class AdminInfoController {  
39 - @Autowired  
40 - private XklCompanyRepository xklCompanyRepository;  
41 -  
42 - @RequestMapping(method = RequestMethod.GET)  
43 - @Authorization  
44 - @ApiOperation(value = "操作员信息查询接口")  
45 - @ApiImplicitParams({  
46 - @ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),  
47 - })  
48 - public ResponseEntity<ResultModel> getAdminInfo(@CurrentAdmin XklAdminEntity admin) {  
49 - XklCompanyEntity companyEntity = xklCompanyRepository.findById(admin.getCoid());  
50 - if(companyEntity==null){  
51 - return new ResponseEntity<>(ResultModel.error(ResultStatus.COMPANY_ERROR),HttpStatus.OK);  
52 - }  
53 - AdminInfoModel adminInfoModel = new AdminInfoModel(admin.getId(), admin.getAccount(), companyEntity.getId(), companyEntity.getName());  
54 - return new ResponseEntity<>(ResultModel.ok(adminInfoModel), HttpStatus.OK);  
55 - }  
56 -}  
@@ -11,9 +11,12 @@ import com.xkl.authorization.model.TokenModel; @@ -11,9 +11,12 @@ import com.xkl.authorization.model.TokenModel;
11 import com.xkl.config.Constants; 11 import com.xkl.config.Constants;
12 import com.xkl.config.ResultStatus; 12 import com.xkl.config.ResultStatus;
13 import com.xkl.domain.XklAdminEntity; 13 import com.xkl.domain.XklAdminEntity;
  14 +import com.xkl.domain.XklCompanyEntity;
  15 +import com.xkl.model.AdminLoginModel;
14 import com.xkl.model.ResultModel; 16 import com.xkl.model.ResultModel;
15 import com.xkl.repository.AMPMachineRepository; 17 import com.xkl.repository.AMPMachineRepository;
16 import com.xkl.repository.AdminRepository; 18 import com.xkl.repository.AdminRepository;
  19 +import com.xkl.repository.XklCompanyRepository;
17 import com.xkl.security.SecurityTool; 20 import com.xkl.security.SecurityTool;
18 import org.springframework.beans.factory.annotation.Autowired; 21 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.http.HttpStatus; 22 import org.springframework.http.HttpStatus;
@@ -39,7 +42,8 @@ public class UpSoftAccountController { @@ -39,7 +42,8 @@ public class UpSoftAccountController {
39 private AMPMachineRepository ampMachineRepository; 42 private AMPMachineRepository ampMachineRepository;
40 @Autowired 43 @Autowired
41 private ITokenManager tokenManager; 44 private ITokenManager tokenManager;
42 - 45 + @Autowired
  46 + private XklCompanyRepository xklCompanyRepository;
43 public static final String UPSOFT_TOKEN_PREFIX = "UPSOFTTOKEN"; 47 public static final String UPSOFT_TOKEN_PREFIX = "UPSOFTTOKEN";
44 48
45 @RequestMapping(method = RequestMethod.POST) 49 @RequestMapping(method = RequestMethod.POST)
@@ -61,7 +65,7 @@ public class UpSoftAccountController { @@ -61,7 +65,7 @@ public class UpSoftAccountController {
61 //未注册 65 //未注册
62 if (admin == null) { 66 if (admin == null) {
63 //提示用户名或密码错误 67 //提示用户名或密码错误
64 - return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR),HttpStatus.OK); 68 + return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.OK);
65 } 69 }
66 String salt = admin.getSalt(); 70 String salt = admin.getSalt();
67 String pass_in_db = admin.getPwd(); 71 String pass_in_db = admin.getPwd();
@@ -69,12 +73,19 @@ public class UpSoftAccountController { @@ -69,12 +73,19 @@ public class UpSoftAccountController {
69 if (!calcuPass.equals(pass_in_db) ||//密码错误 73 if (!calcuPass.equals(pass_in_db) ||//密码错误
70 admin.getStatus() != 1) {//用户无效 74 admin.getStatus() != 1) {//用户无效
71 //提示用户名或密码错误 75 //提示用户名或密码错误
72 - return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR),HttpStatus.OK); 76 + return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.OK);
73 } 77 }
74 78
75 //生成一个token,保存用户登录状态 79 //生成一个token,保存用户登录状态
76 TokenModel model = tokenManager.createToken(UPSOFT_TOKEN_PREFIX + admin.getId()); 80 TokenModel model = tokenManager.createToken(UPSOFT_TOKEN_PREFIX + admin.getId());
77 - return new ResponseEntity<>(ResultModel.ok(model), HttpStatus.OK); 81 +
  82 + XklCompanyEntity companyEntity = xklCompanyRepository.findById(admin.getCoid());
  83 + if (companyEntity == null) {
  84 + return new ResponseEntity<>(ResultModel.error(ResultStatus.COMPANY_ERROR), HttpStatus.OK);
  85 + }
  86 +
  87 + AdminLoginModel adminLoginModel = new AdminLoginModel(admin.getId(), admin.getAccount(), companyEntity.getId(), companyEntity.getName(), model.getUserId(), model.getToken());
  88 + return new ResponseEntity<>(ResultModel.ok(adminLoginModel), HttpStatus.OK);
78 } 89 }
79 90
80 @RequestMapping(method = RequestMethod.DELETE) 91 @RequestMapping(method = RequestMethod.DELETE)
@@ -4,20 +4,26 @@ import lombok.AllArgsConstructor; @@ -4,20 +4,26 @@ import lombok.AllArgsConstructor;
4 import lombok.Data; 4 import lombok.Data;
5 5
6 /** 6 /**
7 - * 管理员信息 7 + * 管理员登录后的返回信息
8 */ 8 */
9 @Data 9 @Data
10 -public class AdminInfoModel { 10 +public class AdminLoginModel {
  11 +
11 public long adminId; 12 public long adminId;
12 public String adminAccount; 13 public String adminAccount;
13 public long comId; 14 public long comId;
14 public String comName; 15 public String comName;
  16 + //用户id
  17 + private String userId;
  18 + public String token;
15 19
16 - public AdminInfoModel(long adminId, String adminAccount, long comId, String comName) { 20 + public AdminLoginModel(long adminId, String adminAccount, long comId, String comName, String userId, String token) {
17 this.adminId = adminId; 21 this.adminId = adminId;
18 this.adminAccount = adminAccount; 22 this.adminAccount = adminAccount;
19 this.comId = comId; 23 this.comId = comId;
20 this.comName = comName; 24 this.comName = comName;
  25 + this.userId = userId;
  26 + this.token = token;
21 } 27 }
22 28
23 public long getAdminId() { 29 public long getAdminId() {
@@ -51,4 +57,20 @@ public class AdminInfoModel { @@ -51,4 +57,20 @@ public class AdminInfoModel {
51 public void setComName(String comName) { 57 public void setComName(String comName) {
52 this.comName = comName; 58 this.comName = comName;
53 } 59 }
  60 +
  61 + public String getUserId() {
  62 + return userId;
  63 + }
  64 +
  65 + public void setUserId(String userId) {
  66 + this.userId = userId;
  67 + }
  68 +
  69 + public String getToken() {
  70 + return token;
  71 + }
  72 +
  73 + public void setToken(String token) {
  74 + this.token = token;
  75 + }
54 } 76 }