Authored by zhaoyue

FIX some conflicts

@@ -51,6 +51,16 @@ @@ -51,6 +51,16 @@
51 <artifactId>swagger-springmvc</artifactId> 51 <artifactId>swagger-springmvc</artifactId>
52 <version>1.0.0</version> 52 <version>1.0.0</version>
53 </dependency> 53 </dependency>
  54 + <dependency>
  55 + <groupId>io.springfox</groupId>
  56 + <artifactId>springfox-swagger2</artifactId>
  57 + <version>2.4.0</version>
  58 + </dependency>
  59 + <dependency>
  60 + <groupId>io.springfox</groupId>
  61 + <artifactId>springfox-swagger-ui</artifactId>
  62 + <version>2.4.0</version>
  63 + </dependency>
54 64
55 <dependency> 65 <dependency>
56 <groupId>oro</groupId> 66 <groupId>oro</groupId>
1 -package com.xkl.config; 1 +package com.xkl;
2 2
3 import com.mangofactory.swagger.configuration.SpringSwaggerConfig; 3 import com.mangofactory.swagger.configuration.SpringSwaggerConfig;
4 import com.mangofactory.swagger.models.dto.ApiInfo; 4 import com.mangofactory.swagger.models.dto.ApiInfo;
@@ -7,7 +7,13 @@ import com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin; @@ -7,7 +7,13 @@ import com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin;
7 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.beans.factory.annotation.Autowired;
8 import org.springframework.context.annotation.Bean; 8 import org.springframework.context.annotation.Bean;
9 import org.springframework.context.annotation.Configuration; 9 import org.springframework.context.annotation.Configuration;
10 - 10 +import springfox.documentation.builders.ApiInfoBuilder;
  11 +import springfox.documentation.builders.PathSelectors;
  12 +import springfox.documentation.builders.RequestHandlerSelectors;
  13 +import springfox.documentation.spi.DocumentationType;
  14 +import springfox.documentation.spring.web.plugins.Docket;
  15 +import springfox.documentation.swagger2.annotations.EnableSwagger2;
  16 +//import springfox.documentation.service.ApiInfo;
11 import java.sql.Timestamp; 17 import java.sql.Timestamp;
12 18
13 /** 19 /**
@@ -16,6 +22,27 @@ import java.sql.Timestamp; @@ -16,6 +22,27 @@ import java.sql.Timestamp;
16 @Configuration 22 @Configuration
17 @EnableSwagger 23 @EnableSwagger
18 public class SwaggerConfig { 24 public class SwaggerConfig {
  25 +// @Bean
  26 +// public Docket createRestApi() {
  27 +// return new Docket(DocumentationType.SWAGGER_2)
  28 +// .apiInfo(apiInfo())
  29 +// .select()
  30 +// .apis(RequestHandlerSelectors.basePackage("com.xkl.controller"))
  31 +// .paths(PathSelectors.any())
  32 +// .build();
  33 +// }
  34 +//
  35 +// private ApiInfo apiInfo() {
  36 +// return new ApiInfoBuilder()
  37 +// .title("Spring Boot中使用Swagger2构建RESTful APIs")
  38 +// .description("更多Spring Boot相关文章请关注:http://blog.didispace.com/")
  39 +// .termsOfServiceUrl("http://blog.didispace.com/")
  40 +// .contact("程序猿DD").version("1.0")
  41 +// .build();
  42 +// }
  43 +//
  44 +//
  45 +//}
19 46
20 private SpringSwaggerConfig springSwaggerConfig; 47 private SpringSwaggerConfig springSwaggerConfig;
21 48
@@ -13,6 +13,7 @@ import com.xkl.domain.Admin; @@ -13,6 +13,7 @@ import com.xkl.domain.Admin;
13 import com.xkl.model.ResultModel; 13 import com.xkl.model.ResultModel;
14 import com.xkl.repository.AMPMachineRepository; 14 import com.xkl.repository.AMPMachineRepository;
15 import com.xkl.repository.AdminRepository; 15 import com.xkl.repository.AdminRepository;
  16 +import com.xkl.security.SecurityTool;
16 import org.hibernate.validator.constraints.SafeHtml; 17 import org.hibernate.validator.constraints.SafeHtml;
17 import org.springframework.beans.factory.annotation.Autowired; 18 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.http.HttpStatus; 19 import org.springframework.http.HttpStatus;
@@ -39,29 +40,30 @@ public class UpSoftAccountController { @@ -39,29 +40,30 @@ public class UpSoftAccountController {
39 @Autowired 40 @Autowired
40 private ITokenManager tokenManager; 41 private ITokenManager tokenManager;
41 42
42 - private static final String UPSOFT_TOKEN_PREFIX = "UPSOFT_TOKEN"; 43 + private static final String UPSOFT_TOKEN_PREFIX = "UPSOFTTOKEN";
43 44
44 @RequestMapping(method = RequestMethod.POST) 45 @RequestMapping(method = RequestMethod.POST)
45 @ApiOperation(value = "报告上传软件登录", notes = "login") 46 @ApiOperation(value = "报告上传软件登录", notes = "login")
46 47
47 - public ResponseEntity<ResultModel> login(@RequestParam String account, @RequestParam String password  
48 - , @RequestParam String ampserial, @RequestParam String ampkey) { 48 + public ResponseEntity<ResultModel> login(@RequestParam String account, @RequestParam String password) {
  49 + // , @RequestParam String ampserial, @RequestParam String ampkey
49 Assert.notNull(account, "account can not be empty"); 50 Assert.notNull(account, "account can not be empty");
50 Assert.notNull(password, "password can not be empty"); 51 Assert.notNull(password, "password can not be empty");
51 - Assert.notNull(ampserial, "ampserial can not be empty");  
52 - Assert.notNull(ampkey, "ampkey can not be empty");  
53 -  
54 - AMPMachine ampMachine = ampMachineRepository.findBySecretKey(ampkey.trim());  
55 - if (ampMachine == null ||// 未找到密钥所对应的机器  
56 - !ampMachine.getAMPSerial().equals(ampserial) ||//amp序号不符合  
57 - ampMachine.getStatus() != 1) {//用户无效  
58 - return new ResponseEntity<>(ResultModel.error(ResultStatus.AMP_KEY_ERROR), HttpStatus.NOT_FOUND);  
59 -  
60 - } 52 +// Assert.notNull(ampserial, "ampserial can not be empty");
  53 +// Assert.notNull(ampkey, "ampkey can not be empty");
  54 +// AMPMachine ampMachine = ampMachineRepository.findBySecretKey(ampkey.trim());
  55 +// if (ampMachine == null ||// 未找到密钥所对应的机器
  56 +// !ampMachine.getAMPSerial().equals(ampserial) ||//amp序号不符合
  57 +// ampMachine.getStatus() != 1) {//用户无效
  58 +// return new ResponseEntity<>(ResultModel.error(ResultStatus.AMP_KEY_ERROR), HttpStatus.NOT_FOUND);
  59 +// }
61 60
62 Admin admin = adminRepository.findByAccount(account); 61 Admin admin = adminRepository.findByAccount(account);
  62 + String salt = admin.getSalt();
  63 + String pass_in_db = admin.getPwd();
  64 + String calcuPass = SecurityTool.getPassword(account, password, salt);
63 if (admin == null || //未注册 65 if (admin == null || //未注册
64 - !admin.getPwd().equals(password) ||//密码错误 66 + !calcuPass.equals(pass_in_db) ||//密码错误
65 admin.getStatus() != 1) {//用户无效 67 admin.getStatus() != 1) {//用户无效
66 //提示用户名或密码错误 68 //提示用户名或密码错误
67 return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.NOT_FOUND); 69 return new ResponseEntity<>(ResultModel.error(ResultStatus.USERNAME_OR_PASSWORD_ERROR), HttpStatus.NOT_FOUND);
@@ -33,6 +33,10 @@ public class Admin { @@ -33,6 +33,10 @@ public class Admin {
33 @Column(name = "coid") 33 @Column(name = "coid")
34 private int coid; 34 private int coid;
35 35
  36 + //salt
  37 + @Column(name = "salt")
  38 + private String salt;
  39 +
36 //备注 40 //备注
37 @Column(name = "note") 41 @Column(name = "note")
38 private String note; 42 private String note;
@@ -82,6 +86,14 @@ public class Admin { @@ -82,6 +86,14 @@ public class Admin {
82 this.coid = coid; 86 this.coid = coid;
83 } 87 }
84 88
  89 + public String getSalt() {
  90 + return salt;
  91 + }
  92 +
  93 + public void setSalt(String salt) {
  94 + this.salt = salt;
  95 + }
  96 +
85 public String getNote() { 97 public String getNote() {
86 return note; 98 return note;
87 } 99 }