...
|
...
|
@@ -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)
|
...
|
...
|
|