Authored by fangyeqing

Merge branch 'master' of gitlab.hanhezy.com:fyq/xkl-interface

git pull
git add --all src/*
git add push.sh
git add pom.xml
... ...
... ... @@ -15,4 +15,20 @@ public class TokenModel {
//随机生成的uuid
private String token;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
}
... ...
package com.xkl.controller.uploadsoft;
import com.wordnik.swagger.annotations.ApiImplicitParam;
import com.wordnik.swagger.annotations.ApiImplicitParams;
import com.wordnik.swagger.annotations.ApiOperation;
import com.xkl.authorization.annotation.*;
import com.xkl.authorization.manager.ITokenManager;
import com.xkl.config.Constants;
import com.xkl.config.ResultStatus;
import com.xkl.domain.User;
import com.xkl.domain.XklAdminEntity;
import com.xkl.domain.XklCompanyEntity;
import com.xkl.domain.XklMemberEntity;
import com.xkl.model.AdminInfoModel;
import com.xkl.model.ResultModel;
import com.xkl.repository.AdminRepository;
import com.xkl.repository.UserRepository;
import com.xkl.repository.XklCompanyRepository;
import com.xkl.repository.XklMemberRespository;
import com.xkl.security.AntiXSS;
import com.xkl.security.SecurityTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* 操作员信息查询接口
*/
@RestController
@RequestMapping("/adminInfo")
public class AdminInfoController {
@Autowired
private XklCompanyRepository xklCompanyRepository;
@RequestMapping(method = RequestMethod.GET)
@Authorization
@ApiOperation(value = "操作员信息查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "authorization", value = "请输入登录返回信息:userId_tokens", required = true, dataType = "string", paramType = "header"),
})
public ResponseEntity<ResultModel> getAdminInfo(@CurrentAdmin XklAdminEntity admin) {
XklCompanyEntity companyEntity = xklCompanyRepository.findById(admin.getCoid());
if(companyEntity==null){
return new ResponseEntity<>(ResultModel.error(ResultStatus.COMPANY_ERROR),HttpStatus.OK);
}
AdminInfoModel adminInfoModel = new AdminInfoModel(admin.getId(), admin.getAccount(), companyEntity.getId(), companyEntity.getName());
return new ResponseEntity<>(ResultModel.ok(adminInfoModel), HttpStatus.OK);
}
}
... ... @@ -11,9 +11,12 @@ import com.xkl.authorization.model.TokenModel;
import com.xkl.config.Constants;
import com.xkl.config.ResultStatus;
import com.xkl.domain.XklAdminEntity;
import com.xkl.domain.XklCompanyEntity;
import com.xkl.model.AdminLoginModel;
import com.xkl.model.ResultModel;
import com.xkl.repository.AMPMachineRepository;
import com.xkl.repository.AdminRepository;
import com.xkl.repository.XklCompanyRepository;
import com.xkl.security.SecurityTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
... ... @@ -39,7 +42,8 @@ public class UpSoftAccountController {
private AMPMachineRepository ampMachineRepository;
@Autowired
private ITokenManager tokenManager;
@Autowired
private XklCompanyRepository xklCompanyRepository;
public static final String UPSOFT_TOKEN_PREFIX = "UPSOFTTOKEN";
@RequestMapping(method = RequestMethod.POST)
... ... @@ -61,7 +65,7 @@ public class UpSoftAccountController {
//未注册
if (admin == null) {
//提示用户名或密码错误
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR),HttpStatus.OK);
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.OK);
}
String salt = admin.getSalt();
String pass_in_db = admin.getPwd();
... ... @@ -69,12 +73,19 @@ public class UpSoftAccountController {
if (!calcuPass.equals(pass_in_db) ||//密码错误
admin.getStatus() != 1) {//用户无效
//提示用户名或密码错误
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR),HttpStatus.OK);
return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.OK);
}
//生成一个token,保存用户登录状态
TokenModel model = tokenManager.createToken(UPSOFT_TOKEN_PREFIX + admin.getId());
return new ResponseEntity<>(ResultModel.ok(model), HttpStatus.OK);
XklCompanyEntity companyEntity = xklCompanyRepository.findById(admin.getCoid());
if (companyEntity == null) {
return new ResponseEntity<>(ResultModel.error(ResultStatus.COMPANY_ERROR), HttpStatus.OK);
}
AdminLoginModel adminLoginModel = new AdminLoginModel(admin.getId(), admin.getAccount(), companyEntity.getId(), companyEntity.getName(), model.getUserId(), model.getToken());
return new ResponseEntity<>(ResultModel.ok(adminLoginModel), HttpStatus.OK);
}
@RequestMapping(method = RequestMethod.DELETE)
... ...
... ... @@ -4,20 +4,26 @@ import lombok.AllArgsConstructor;
import lombok.Data;
/**
* 管理员信息
* 管理员登录后的返回信息
*/
@Data
public class AdminInfoModel {
public class AdminLoginModel {
public long adminId;
public String adminAccount;
public long comId;
public String comName;
//用户id
private String userId;
public String token;
public AdminInfoModel(long adminId, String adminAccount, long comId, String comName) {
public AdminLoginModel(long adminId, String adminAccount, long comId, String comName, String userId, String token) {
this.adminId = adminId;
this.adminAccount = adminAccount;
this.comId = comId;
this.comName = comName;
this.userId = userId;
this.token = token;
}
public long getAdminId() {
... ... @@ -51,4 +57,20 @@ public class AdminInfoModel {
public void setComName(String comName) {
this.comName = comName;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
}
... ...