Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fangyeqing
/
xkl-interface
·
Commits
Go to a project
GitLab
Go to dashboard
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
fangyeqing
8 years ago
Commit
8806a1eadc63b5f450eeb5320a8eb10f2cd4c09d
2 parents
7ddc0a29
6c05506b
Merge branch 'master' of gitlab.hanhezy.com:fyq/xkl-interface
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
63 deletions
push.sh
src/main/java/com/xkl/authorization/model/TokenModel.java
src/main/java/com/xkl/controller/uploadsoft/AdminInfoController.java
src/main/java/com/xkl/controller/uploadsoft/UpSoftAccountController.java
src/main/java/com/xkl/model/AdminInfoModel.java → src/main/java/com/xkl/model/AdminLoginModel.java
push.sh
View file @
8806a1e
git pull
git add --all src/
*
git add push.sh
git add pom.xml
...
...
src/main/java/com/xkl/authorization/model/TokenModel.java
View file @
8806a1e
...
...
@@ -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
;
}
}
...
...
src/main/java/com/xkl/controller/uploadsoft/AdminInfoController.java
deleted
100644 → 0
View file @
7ddc0a2
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
);
}
}
src/main/java/com/xkl/controller/uploadsoft/UpSoftAccountController.java
View file @
8806a1e
...
...
@@ -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
)
...
...
src/main/java/com/xkl/model/Admin
Info
Model.java → src/main/java/com/xkl/model/Admin
Login
Model.java
View file @
8806a1e
...
...
@@ -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
Admin
InfoModel
(
long
adminId
,
String
adminAccount
,
long
comId
,
String
comName
)
{
public
Admin
LoginModel
(
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
;
}
}
...
...
Please
register
or
login
to post a comment