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
Email Patches
Plain Diff
Browse Files
Authored by
zhaoyue
8 years ago
Commit
7c806212bd8453e31b1ba45059279ba7746b6912
1 parent
11fdfac6
FIX some conflicts
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
16 deletions
pom.xml
src/main/java/com/xkl/config/SwaggerConfig.java
src/main/java/com/xkl/controller/uploadsoft/UpSoftAccountController.java
src/main/java/com/xkl/domain/Admin.java
pom.xml
View file @
7c80621
...
...
@@ -51,6 +51,16 @@
<artifactId>
swagger-springmvc
</artifactId>
<version>
1.0.0
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
<version>
2.4.0
</version>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
<version>
2.4.0
</version>
</dependency>
<dependency>
<groupId>
oro
</groupId>
...
...
src/main/java/com/xkl/config/SwaggerConfig.java
View file @
7c80621
package
com
.
xkl
.
config
;
package
com
.
xkl
;
import
com.mangofactory.swagger.configuration.SpringSwaggerConfig
;
import
com.mangofactory.swagger.models.dto.ApiInfo
;
...
...
@@ -7,7 +7,13 @@ import com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
//import springfox.documentation.service.ApiInfo;
import
java.sql.Timestamp
;
/**
...
...
@@ -16,6 +22,27 @@ import java.sql.Timestamp;
@Configuration
@EnableSwagger
public
class
SwaggerConfig
{
// @Bean
// public Docket createRestApi() {
// return new Docket(DocumentationType.SWAGGER_2)
// .apiInfo(apiInfo())
// .select()
// .apis(RequestHandlerSelectors.basePackage("com.xkl.controller"))
// .paths(PathSelectors.any())
// .build();
// }
//
// private ApiInfo apiInfo() {
// return new ApiInfoBuilder()
// .title("Spring Boot中使用Swagger2构建RESTful APIs")
// .description("更多Spring Boot相关文章请关注:http://blog.didispace.com/")
// .termsOfServiceUrl("http://blog.didispace.com/")
// .contact("程序猿DD").version("1.0")
// .build();
// }
//
//
//}
private
SpringSwaggerConfig
springSwaggerConfig
;
...
...
src/main/java/com/xkl/controller/uploadsoft/UpSoftAccountController.java
View file @
7c80621
...
...
@@ -13,6 +13,7 @@ import com.xkl.domain.Admin;
import
com.xkl.model.ResultModel
;
import
com.xkl.repository.AMPMachineRepository
;
import
com.xkl.repository.AdminRepository
;
import
com.xkl.security.SecurityTool
;
import
org.hibernate.validator.constraints.SafeHtml
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -39,29 +40,30 @@ public class UpSoftAccountController {
@Autowired
private
ITokenManager
tokenManager
;
private
static
final
String
UPSOFT_TOKEN_PREFIX
=
"UPSOFT
_
TOKEN"
;
private
static
final
String
UPSOFT_TOKEN_PREFIX
=
"UPSOFTTOKEN"
;
@RequestMapping
(
method
=
RequestMethod
.
POST
)
@ApiOperation
(
value
=
"报告上传软件登录"
,
notes
=
"login"
)
public
ResponseEntity
<
ResultModel
>
login
(
@RequestParam
String
account
,
@RequestParam
String
password
,
@RequestParam
String
ampserial
,
@RequestParam
String
ampkey
)
{
public
ResponseEntity
<
ResultModel
>
login
(
@RequestParam
String
account
,
@RequestParam
String
password
)
{
// , @RequestParam String ampserial, @RequestParam String ampkey
Assert
.
notNull
(
account
,
"account can not be empty"
);
Assert
.
notNull
(
password
,
"password can not be empty"
);
Assert
.
notNull
(
ampserial
,
"ampserial can not be empty"
);
Assert
.
notNull
(
ampkey
,
"ampkey can not be empty"
);
AMPMachine
ampMachine
=
ampMachineRepository
.
findBySecretKey
(
ampkey
.
trim
());
if
(
ampMachine
==
null
||
// 未找到密钥所对应的机器
!
ampMachine
.
getAMPSerial
().
equals
(
ampserial
)
||
//amp序号不符合
ampMachine
.
getStatus
()
!=
1
)
{
//用户无效
return
new
ResponseEntity
<>(
ResultModel
.
error
(
ResultStatus
.
AMP_KEY_ERROR
),
HttpStatus
.
NOT_FOUND
);
}
// Assert.notNull(ampserial, "ampserial can not be empty");
// Assert.notNull(ampkey, "ampkey can not be empty");
// AMPMachine ampMachine = ampMachineRepository.findBySecretKey(ampkey.trim());
// if (ampMachine == null ||// 未找到密钥所对应的机器
// !ampMachine.getAMPSerial().equals(ampserial) ||//amp序号不符合
// ampMachine.getStatus() != 1) {//用户无效
// return new ResponseEntity<>(ResultModel.error(ResultStatus.AMP_KEY_ERROR), HttpStatus.NOT_FOUND);
// }
Admin
admin
=
adminRepository
.
findByAccount
(
account
);
String
salt
=
admin
.
getSalt
();
String
pass_in_db
=
admin
.
getPwd
();
String
calcuPass
=
SecurityTool
.
getPassword
(
account
,
password
,
salt
);
if
(
admin
==
null
||
//未注册
!
admin
.
getPwd
().
equals
(
password
)
||
//密码错误
!
calcuPass
.
equals
(
pass_in_db
)
||
//密码错误
admin
.
getStatus
()
!=
1
)
{
//用户无效
//提示用户名或密码错误
return
new
ResponseEntity
<>(
ResultModel
.
error
(
ResultStatus
.
USERNAME_OR_PASSWORD_ERROR
),
HttpStatus
.
NOT_FOUND
);
...
...
src/main/java/com/xkl/domain/Admin.java
View file @
7c80621
...
...
@@ -33,6 +33,10 @@ public class Admin {
@Column
(
name
=
"coid"
)
private
int
coid
;
//salt
@Column
(
name
=
"salt"
)
private
String
salt
;
//备注
@Column
(
name
=
"note"
)
private
String
note
;
...
...
@@ -82,6 +86,14 @@ public class Admin {
this
.
coid
=
coid
;
}
public
String
getSalt
()
{
return
salt
;
}
public
void
setSalt
(
String
salt
)
{
this
.
salt
=
salt
;
}
public
String
getNote
()
{
return
note
;
}
...
...
Please
register
or
login
to post a comment