更新到jwt

This commit is contained in:
Xiong Neng 2018-09-09 21:45:05 +08:00
parent df914631a5
commit 9e9cd02507
26 changed files with 93 additions and 2444 deletions

View File

@ -10,9 +10,9 @@ spring:
profiles: profiles:
active: dev active: dev
datasource: datasource:
url: jdbc:mysql://123.207.66.156:3306/test?useSSL=false&autoReconnect=true&tinyInt1isBit=false&useUnicode=true&characterEncoding=utf8 url: jdbc:mysql://127.0.0.1:3306/test?useSSL=false&autoReconnect=true&tinyInt1isBit=false&useUnicode=true&characterEncoding=utf8
username: root username: root
password: _EnZhi123 password: 123456
################### mybatis-plus配置 ################### ################### mybatis-plus配置 ###################
mybatis-plus: mybatis-plus:

View File

@ -15,7 +15,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version> <version>2.0.4.RELEASE</version>
<relativePath/> <relativePath/>
</parent> </parent>

View File

@ -15,7 +15,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version> <version>2.0.4.RELEASE</version>
<relativePath/> <relativePath/>
</parent> </parent>

View File

@ -9,7 +9,81 @@
## 测试 ## 测试
启动应用后,先访问登录接口,使用参数用户名=admin/密码=12345678拿到token后再访问其他接口。 启动应用后
1. 先访问登录接口/login
*URL*
```
POST http://localhost:9095/login
```
*Header参数*
```
Content-Type: application/json
```
*Body参数*
``` json
{
"username": "admin",
"password": "12345678",
"appid": "111",
"imei": "imei"
}
```
返回值:
``` json
{
"success": true,
"msg": "Login success",
"data": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcHBpZCI6IjExMSIsImltZWkiOiJpbWVpIiwiZXhwIjoxNTM2NDg3NTM1LCJ1c2VybmFtZSI6ImFkbWluIn0.uat7rvVLwC7bcM-jRs329RWdHIFC6P-YN7YdJrdRUHE"
}
```
2. 使用token再去访问接口
上面的"data"对应的一长串字符串就是返回的token值
*URL*
```
GET http://localhost:9095/api/v1/join?imei=imei
```
*Header参数*
```
Content-Type: application/json
Authorization: 'Bearer ' + token
```
*Body参数*
``` json
{
"username": "admin",
"password": "12345678",
"appid": "111",
"imei": "imei"
}
```
返回值:
``` json
{
"success": true,
"msg": "Login success",
"data": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcHBpZCI6IjExMSIsImltZWkiOiJpbWVpIiwiZXhwIjoxNTM2NDg3NTM1LCJ1c2VybmFtZSI6ImFkbWluIn0.uat7rvVLwC7bcM-jRs329RWdHIFC6P-YN7YdJrdRUHE"
}
```
## 许可证 ## 许可证

View File

@ -15,7 +15,7 @@
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version> <version>2.0.4.RELEASE</version>
<relativePath/> <relativePath/>
</parent> </parent>

View File

@ -20,21 +20,21 @@ public class ExceptionController {
@ResponseStatus(HttpStatus.UNAUTHORIZED) @ResponseStatus(HttpStatus.UNAUTHORIZED)
@ExceptionHandler(ShiroException.class) @ExceptionHandler(ShiroException.class)
public BaseResponse handle401(ShiroException e) { public BaseResponse handle401(ShiroException e) {
return new BaseResponse(false, "shiro的异常", null); return new BaseResponse<>(false, "shiro的异常", null);
} }
// 捕捉UnauthorizedException // 捕捉UnauthorizedException
@ResponseStatus(HttpStatus.UNAUTHORIZED) @ResponseStatus(HttpStatus.UNAUTHORIZED)
@ExceptionHandler(UnauthorizedException.class) @ExceptionHandler(UnauthorizedException.class)
public BaseResponse handle401() { public BaseResponse handle401() {
return new BaseResponse(false, "UnauthorizedException", null); return new BaseResponse<>(false, "UnauthorizedException", null);
} }
// 捕捉其他所有异常 // 捕捉其他所有异常
@ExceptionHandler(Exception.class) @ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseStatus(HttpStatus.BAD_REQUEST)
public BaseResponse globalException(HttpServletRequest request, Throwable ex) { public BaseResponse globalException(HttpServletRequest request, Throwable ex) {
return new BaseResponse(false, "其他异常", null); return new BaseResponse<>(false, "其他异常", null);
} }
private HttpStatus getStatus(HttpServletRequest request) { private HttpStatus getStatus(HttpServletRequest request) {

View File

@ -1,28 +0,0 @@
package com.xncoding.jwt.api;
import com.xncoding.jwt.api.model.BaseResponse;
import com.xncoding.jwt.api.model.UnbindParam;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
/**
* 通知接口类
*/
@RestController
@RequestMapping(value = "/notify")
public class NotifyController {
private static final Logger _logger = LoggerFactory.getLogger(NotifyController.class);
@PostMapping("/unbind")
@RequiresUser
public BaseResponse unbind(@RequestHeader(name="Content-Type", defaultValue = "application/json") String contentType,
@RequestHeader(name="Authorization", defaultValue="token") String token,
@RequestBody UnbindParam unbindParam) {
_logger.info("解绑通知接口start");
return new BaseResponse<>(true, "解绑通知发送成功", null);
}
}

View File

@ -1,22 +1,11 @@
package com.xncoding.jwt.api; package com.xncoding.jwt.api;
import com.xncoding.jwt.api.model.*; import com.xncoding.jwt.api.model.BaseResponse;
import com.xncoding.jwt.common.dao.entity.Pos; import org.apache.shiro.authz.annotation.RequiresAuthentication;
import com.xncoding.jwt.common.dao.entity.Project;
import com.xncoding.jwt.service.ApiService;
import com.xncoding.jwt.service.ManagerInfoService;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
/** /**
* 机具管理API接口类 * 机具管理API接口类
*/ */
@ -24,12 +13,6 @@ import java.util.Date;
@RequestMapping(value = "/api/v1") @RequestMapping(value = "/api/v1")
public class PublicController { public class PublicController {
@Resource
private ApiService apiService;
@Resource
private ManagerInfoService managerInfoService;
private static final Logger _logger = LoggerFactory.getLogger(PublicController.class); private static final Logger _logger = LoggerFactory.getLogger(PublicController.class);
/** /**
@ -38,230 +21,13 @@ public class PublicController {
* @return 是否入网 * @return 是否入网
*/ */
@RequestMapping(value = "/join", method = RequestMethod.GET) @RequestMapping(value = "/join", method = RequestMethod.GET)
@RequiresUser @RequiresAuthentication
public JoinBindResponse join(@RequestHeader(name="Accept", defaultValue = "application/json", required = false) String accept, public BaseResponse join(@RequestHeader("Authorization") String token,
@RequestHeader(name="Authorization", defaultValue="token") String token,
@RequestParam("imei") String imei) { @RequestParam("imei") String imei) {
_logger.info("入网查询接口 start...."); _logger.info("入网查询接口 start... imei=" + imei);
JoinBindResponse result = new JoinBindResponse(); BaseResponse result = new BaseResponse();
int posCount = apiService.selectCount(imei);
if (posCount > 0) {
// 如果入网了再去查询是否绑定了网点
int bindCount = apiService.selectBindCount(imei);
Pos pos = apiService.selectByImei(imei);
result.setPosState(pos.getPosState());
if (bindCount == 0) {
result.setSuccess(false);
result.setCode(2);
result.setMsg("已入网但尚未绑定网点");
} else {
result.setSuccess(true); result.setSuccess(true);
result.setCode(1);
result.setMsg("已入网并绑定了网点"); result.setMsg("已入网并绑定了网点");
}
} else {
result.setSuccess(false);
result.setCode(3);
result.setMsg("未入网");
}
return result; return result;
} }
/**
* 请求入网接口
*
* @return 处理结果
*/
@RequestMapping(value = "/join", method = RequestMethod.POST)
@RequiresUser
public ResponseEntity<BaseResponse> doJoin(@RequestHeader(name="Content-Type", defaultValue = "application/json") String contentType,
@RequestHeader(name="Authorization", defaultValue="token") String token,
@RequestBody PosParam posParam) {
_logger.info("请求入网接口 start....");
BaseResponse result = new BaseResponse();
// imei码约束检查
if (StringUtils.isEmpty(posParam.getImei()) || posParam.getImei().length() > 32) {
result.setSuccess(false);
result.setMsg("IMEI码长度不是1-32位入网失败。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
// 序列号SN约束检查
if (StringUtils.isEmpty(posParam.getSn()) || posParam.getSn().length() > 64) {
result.setSuccess(false);
result.setMsg("序列号长度不是1-64位入网失败。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
// 机具型号约束检查
if (StringUtils.isEmpty(posParam.getSeries()) || posParam.getSeries().length() > 32) {
result.setSuccess(false);
result.setMsg("机具型号不是1-32位入网失败。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
// Android版本约束检查
if (StringUtils.isEmpty(posParam.getAndroidVersion()) || posParam.getAndroidVersion().length() > 32) {
result.setSuccess(false);
result.setMsg("Android版本号不是1-32位入网失败。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
// 版本号约束检查
if (StringUtils.isEmpty(posParam.getVersion()) || posParam.getVersion().length() > 32) {
result.setSuccess(false);
result.setMsg("版本号不是1-32位入网失败。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
// 归属网点约束检查
if (StringUtils.isEmpty(posParam.getLocation()) || posParam.getLocation().length() > 64) {
result.setSuccess(false);
result.setMsg("归属网点不是1-64位入网失败。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
// 产权方约束检查
if (StringUtils.isEmpty(posParam.getOwner()) || posParam.getOwner().length() > 64) {
result.setSuccess(false);
result.setMsg("产权方不是1-64位入网失败。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
// 应用ID约束检查
if (StringUtils.isEmpty(posParam.getApplicationId()) || posParam.getApplicationId().length() > 64) {
result.setSuccess(false);
result.setMsg("应用ID不是1-64位入网失败。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
// 备注约束检查
if (StringUtils.isNotEmpty(posParam.getTips()) && posParam.getTips().length() > 255) {
result.setSuccess(false);
result.setMsg("备注超过255个字符入网失败。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
Pos pos = new Pos();
Date now = new Date();
pos.setJointime(now);
pos.setBindtime(now);
BeanUtils.copyProperties(posParam, pos);
// 根据applicationId设置归属项目ID
Project project = apiService.selectProjectByApplicationId(posParam.getApplicationId());
if (project == null) {
result.setSuccess(false);
result.setMsg("Application Id不正确入网失败。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
// 重复检查
int posCount = apiService.selectCount(posParam.getImei());
if (posCount > 0) {
result.setSuccess(false);
result.setMsg("入网失败,该机具之前已经入网了。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
// 插入一条新纪录
pos.setProjectId(project.getId());
int insert = apiService.insertPos(pos);
if (insert > 0) {
result.setSuccess(true);
result.setMsg("入网成功");
return new ResponseEntity<>(result, HttpStatus.CREATED);
} else {
result.setSuccess(false);
result.setMsg("入网失败,请联系管理员。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
}
/**
* 请求绑定网点接口
*
* @return 处理结果
*/
@RequestMapping(value = "/bind", method = RequestMethod.POST)
@RequiresUser
public ResponseEntity<BaseResponse> doBind(@RequestHeader(name="Content-Type", defaultValue = "application/json") String contentType,
@RequestHeader(name="Authorization", defaultValue="token") String token,
@RequestBody BindParam bindParam) {
_logger.info("请求绑定网点接口 start....");
BaseResponse result = new BaseResponse();
// imei码约束检查
if (StringUtils.isEmpty(bindParam.getImei()) || bindParam.getImei().length() > 32) {
result.setSuccess(false);
result.setMsg("IMEI码长度不是1-32位绑定网点失败。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
// 归属网点约束检查
if (StringUtils.isEmpty(bindParam.getLocation()) || bindParam.getLocation().length() > 64) {
result.setSuccess(false);
result.setMsg("归属网点不是1-64位绑定网点失败。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
Pos pos = apiService.selectByImei(bindParam.getImei());
if (pos == null) {
result.setSuccess(false);
result.setMsg("该POS机尚未入网。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
Pos pos2 = apiService.selectBindByImei(bindParam.getImei());
if (pos2 != null) {
result.setSuccess(false);
result.setMsg("该POS机已经绑定了网点请先解绑。");
return new ResponseEntity<>(result, HttpStatus.OK);
}
pos.setLocation(bindParam.getLocation());
pos.setUpdatedTime(new Date());
apiService.bindLocation(pos);
result.setSuccess(true);
result.setMsg("绑定网点成功");
return new ResponseEntity<>(result, HttpStatus.OK);
}
/**
* 报告位置接口
*
* @return 报告结果
*/
@RequestMapping(value = "/report", method = RequestMethod.POST)
@RequiresUser
public BaseResponse report(@RequestHeader(name="Content-Type", defaultValue = "application/json") String contentType,
@RequestHeader(name="Authorization", defaultValue="token") String token,
@RequestBody ReportParam param) {
_logger.info("定时报告接口 start....");
BaseResponse result = new BaseResponse();
// IMEI码约束检查
if (StringUtils.isEmpty(param.getImei()) || param.getImei().length() > 32) {
result.setSuccess(false);
result.setMsg("IMEI码不是1-32位心跳报告失败。");
return result;
}
// 地址约束检查
if (StringUtils.isEmpty(param.getLocation()) || param.getLocation().length() > 255) {
result.setSuccess(false);
result.setMsg("地址不是1-255位心跳报告失败。");
return result;
}
int r = apiService.report(param);
if (r > 0) {
result.setSuccess(true);
result.setMsg("心跳报告成功");
} else {
result.setSuccess(false);
result.setMsg("该POS机还没有入网心跳报告失败。");
}
return result;
}
/**
* 版本检查接口
*
* @return 版本检查结果
*/
@RequestMapping(value = "/version", method = RequestMethod.POST)
@RequiresUser
public VersionResult version(@RequestHeader(name="Content-Type", defaultValue = "application/json") String contentType,
@RequestHeader(name="Authorization", defaultValue="token") String token,
@RequestBody VersionParam param) {
_logger.info("版本检查接口 start....");
return apiService.selectPublishCount(param);
}
} }

View File

@ -1,35 +0,0 @@
package com.xncoding.jwt.api.model;
/**
* POS绑定网点参数
*
* @author XiongNeng
* @version 1.0
* @since 2018/1/7
*/
public class BindParam {
/**
* 机具IMEI码
*/
private String imei;
/**
* 归属网点
*/
private String location;
public String getImei() {
return imei;
}
public void setImei(String imei) {
this.imei = imei;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
}

View File

@ -1,36 +0,0 @@
package com.xncoding.jwt.api.model;
/**
* 入网绑定返回
*
* @author XiongNeng
* @version 1.0
* @since 2018/1/16
*/
public class JoinBindResponse<T> extends BaseResponse<T> {
/**
* 返回码 1:已入网并绑定了网点 2:已入网但尚未绑定网点 3:未入网
*/
private int code;
/**
* 机具状态: 1:正常 2:故障 3:维修中(返厂) 4:已禁用(丢失) 5:已停用(回收)
*/
private Integer posState;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public Integer getPosState() {
return posState;
}
public void setPosState(Integer posState) {
this.posState = posState;
}
}

View File

@ -1,119 +0,0 @@
package com.xncoding.jwt.api.model;
/**
* POS入网参数
*
* @author XiongNeng
* @version 1.0
* @since 2018/1/7
*/
public class PosParam {
/**
* 机具IMEI码
*/
private String imei;
/**
* 序列号(SN)
*/
private String sn;
/**
* 机具型号
*/
private String series;
/**
* Android版本
*/
private String androidVersion;
/**
* 版本号
*/
private String version;
/**
* 归属网点
*/
private String location;
/**
* 产权方
*/
private String owner;
/**
* 备注
*/
private String tips;
/**
* 应用ID
*/
private String applicationId;
public String getImei() {
return imei;
}
public void setImei(String imei) {
this.imei = imei;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public String getSeries() {
return series;
}
public void setSeries(String series) {
this.series = series;
}
public String getAndroidVersion() {
return androidVersion;
}
public void setAndroidVersion(String androidVersion) {
this.androidVersion = androidVersion;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getTips() {
return tips;
}
public void setTips(String tips) {
this.tips = tips;
}
public String getApplicationId() {
return applicationId;
}
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
}

View File

@ -1,35 +0,0 @@
package com.xncoding.jwt.api.model;
/**
* 报告参数
*
* @author XiongNeng
* @version 1.0
* @since 2018/1/7
*/
public class ReportParam {
/**
* IMEI码
*/
private String imei;
/**
* 位置
*/
private String location;
public String getImei() {
return imei;
}
public void setImei(String imei) {
this.imei = imei;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
}

View File

@ -1,35 +0,0 @@
package com.xncoding.jwt.api.model;
/**
* 解绑通知参数
*
* @author XiongNeng
* @version 1.0
* @since 2018/1/9
*/
public class UnbindParam {
/**
* IMEI码
*/
private String imei;
/**
* 网点
*/
private String location;
public String getImei() {
return imei;
}
public void setImei(String imei) {
this.imei = imei;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
}

View File

@ -1,47 +0,0 @@
package com.xncoding.jwt.api.model;
/**
* APP版本检查接口参数
*
* @author XiongNeng
* @version 1.0
* @since 2018/1/9
*/
public class VersionParam {
/**
* 机具IMEI码
*/
private String imei;
/**
* 应用ID
*/
private String applicationId;
/**
* 当前版本号
*/
private String version;
public String getApplicationId() {
return applicationId;
}
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getImei() {
return imei;
}
public void setImei(String imei) {
this.imei = imei;
}
}

View File

@ -1,85 +0,0 @@
package com.xncoding.jwt.api.model;
import java.util.Date;
/**
* 版本检查结果
*
* @author XiongNeng
* @version 1.0
* @since 2018/1/9
*/
public class VersionResult {
/**
* 是否发现新版本
*/
private boolean findNew;
/**
* APP名称
*/
private String appName;
/**
* 新版本号
*/
private String version;
/**
* 新版本说明
*/
private String tips;
/**
* 新版本发布时间
*/
private Date publishtime;
/**
* 新版本下载地址
*/
private String downloadUrl;
public boolean isFindNew() {
return findNew;
}
public void setFindNew(boolean findNew) {
this.findNew = findNew;
}
public String getDownloadUrl() {
return downloadUrl;
}
public void setDownloadUrl(String downloadUrl) {
this.downloadUrl = downloadUrl;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getTips() {
return tips;
}
public void setTips(String tips) {
this.tips = tips;
}
public Date getPublishtime() {
return publishtime;
}
public void setPublishtime(Date publishtime) {
this.publishtime = publishtime;
}
}

View File

@ -1,264 +0,0 @@
package com.xncoding.jwt.common.dao.entity;
import java.io.Serializable;
import java.util.Date;
/**
* APP表
*
* @author 熊能
* @version 1.0
* @since 2018/01/02
*/
public class App {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private Integer id;
/**
* 应用编号
*/
private String applicationId;
/**
* 应用名称
*/
private String name;
/**
* 版本号
*/
private String version;
/**
* 版本说明
*/
private String tips;
/**
* 归属项目ID
*/
private Integer projectId;
/**
* 发布时间
*/
private Date publishtime;
/**
* 发布范围 1:全网发布 2:灰度发布
*/
private Integer publishRange;
/**
* 操作者ID
*/
private Integer operatorId;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 获取 主键ID.
*
* @return 主键ID.
*/
public Integer getId() {
return id;
}
/**
* 设置 主键ID.
*
* @param id 主键ID.
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取 应用编号.
*
* @return 应用编号.
*/
public String getApplicationId() {
return applicationId;
}
/**
* 设置 应用编号.
*
* @param applicationId 应用编号.
*/
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
/**
* 获取 应用名称.
*
* @return 应用名称.
*/
public String getName() {
return name;
}
/**
* 设置 应用名称.
*
* @param name 应用名称.
*/
public void setName(String name) {
this.name = name;
}
/**
* 获取 版本号.
*
* @return 版本号.
*/
public String getVersion() {
return version;
}
/**
* 设置 版本号.
*
* @param version 版本号.
*/
public void setVersion(String version) {
this.version = version;
}
/**
* 获取 版本说明.
*
* @return 版本说明.
*/
public String getTips() {
return tips;
}
/**
* 设置 版本说明.
*
* @param tips 版本说明.
*/
public void setTips(String tips) {
this.tips = tips;
}
/**
* 获取 归属项目ID.
*
* @return 归属项目ID.
*/
public Integer getProjectId() {
return projectId;
}
/**
* 设置 归属项目ID.
*
* @param projectId 归属项目ID.
*/
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
/**
* 获取 发布时间.
*
* @return 发布时间.
*/
public Date getPublishtime() {
return publishtime;
}
/**
* 设置 发布时间.
*
* @param publishtime 发布时间.
*/
public void setPublishtime(Date publishtime) {
this.publishtime = publishtime;
}
/**
* 获取 发布范围 1:全网发布 2:灰度发布.
*
* @return 发布范围 1:全网发布 2:灰度发布.
*/
public Integer getPublishRange() {
return publishRange;
}
/**
* 设置 发布范围 1:全网发布 2:灰度发布.
*
* @param publishRange 发布范围 1:全网发布 2:灰度发布.
*/
public void setPublishRange(Integer publishRange) {
this.publishRange = publishRange;
}
/**
* 获取 操作者ID.
*
* @return 操作者ID.
*/
public Integer getOperatorId() {
return operatorId;
}
/**
* 设置 操作者ID.
*
* @param operatorId 操作者ID.
*/
public void setOperatorId(Integer operatorId) {
this.operatorId = operatorId;
}
/**
* 获取 创建时间.
*
* @return 创建时间.
*/
public Date getCreatedTime() {
return createdTime;
}
/**
* 设置 创建时间.
*
* @param createdTime 创建时间.
*/
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
/**
* 获取 更新时间.
*
* @return 更新时间.
*/
public Date getUpdatedTime() {
return updatedTime;
}
/**
* 设置 更新时间.
*
* @param updatedTime 更新时间.
*/
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -1,132 +0,0 @@
package com.xncoding.jwt.common.dao.entity;
import java.io.Serializable;
import java.util.Date;
/**
* APP发布表
*
* @author 熊能
* @version 1.0
* @since 2018/01/02
*/
public class AppPublish {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private Integer id;
/**
* APP主键
*/
private Integer appId;
/**
* POS主键
*/
private Integer posId;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 获取 主键ID.
*
* @return 主键ID.
*/
public Integer getId() {
return id;
}
/**
* 设置 主键ID.
*
* @param id 主键ID.
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取 APP主键.
*
* @return APP主键.
*/
public Integer getAppId() {
return appId;
}
/**
* 设置 APP主键.
*
* @param appId APP主键.
*/
public void setAppId(Integer appId) {
this.appId = appId;
}
/**
* 获取 POS主键.
*
* @return POS主键.
*/
public Integer getPosId() {
return posId;
}
/**
* 设置 POS主键.
*
* @param posId POS主键.
*/
public void setPosId(Integer posId) {
this.posId = posId;
}
/**
* 获取 创建时间.
*
* @return 创建时间.
*/
public Date getCreatedTime() {
return createdTime;
}
/**
* 设置 创建时间.
*
* @param createdTime 创建时间.
*/
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
/**
* 获取 更新时间.
*
* @return 更新时间.
*/
public Date getUpdatedTime() {
return updatedTime;
}
/**
* 设置 更新时间.
*
* @param updatedTime 更新时间.
*/
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -1,198 +0,0 @@
package com.xncoding.jwt.common.dao.entity;
import java.io.Serializable;
import java.util.Date;
/**
* 操作日志表
*
* @author 熊能
* @version 1.0
* @since 2018/01/02
*/
public class OperationLog {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private Integer id;
/**
* 操作者ID
*/
private Integer operatorId;
/**
* 操作对象ID
*/
private Integer targetId;
/**
* 操作对象名称
*/
private String targetName;
/**
* 操作类型
*/
private String operateType;
/**
* 备注
*/
private String tips;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 获取 主键ID.
*
* @return 主键ID.
*/
public Integer getId() {
return id;
}
/**
* 设置 主键ID.
*
* @param id 主键ID.
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取 操作者ID.
*
* @return 操作者ID.
*/
public Integer getOperatorId() {
return operatorId;
}
/**
* 设置 操作者ID.
*
* @param operatorId 操作者ID.
*/
public void setOperatorId(Integer operatorId) {
this.operatorId = operatorId;
}
/**
* 获取 操作对象ID.
*
* @return 操作对象ID.
*/
public Integer getTargetId() {
return targetId;
}
/**
* 设置 操作对象ID.
*
* @param targetId 操作对象ID.
*/
public void setTargetId(Integer targetId) {
this.targetId = targetId;
}
/**
* 获取 操作对象名称.
*
* @return 操作对象名称.
*/
public String getTargetName() {
return targetName;
}
/**
* 设置 操作对象名称.
*
* @param targetName 操作对象名称.
*/
public void setTargetName(String targetName) {
this.targetName = targetName;
}
/**
* 获取 操作类型.
*
* @return 操作类型.
*/
public String getOperateType() {
return operateType;
}
/**
* 设置 操作类型.
*
* @param operateType 操作类型.
*/
public void setOperateType(String operateType) {
this.operateType = operateType;
}
/**
* 获取 备注.
*
* @return 备注.
*/
public String getTips() {
return tips;
}
/**
* 设置 备注.
*
* @param tips 备注.
*/
public void setTips(String tips) {
this.tips = tips;
}
/**
* 获取 创建时间.
*
* @return 创建时间.
*/
public Date getCreatedTime() {
return createdTime;
}
/**
* 设置 创建时间.
*
* @param createdTime 创建时间.
*/
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
/**
* 获取 更新时间.
*
* @return 更新时间.
*/
public Date getUpdatedTime() {
return updatedTime;
}
/**
* 设置 更新时间.
*
* @param updatedTime 更新时间.
*/
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -1,352 +0,0 @@
package com.xncoding.jwt.common.dao.entity;
import java.io.Serializable;
import java.util.Date;
/**
* POS机表
*
* @author 熊能
* @version 1.0
* @since 2018/01/02
*/
public class Pos {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private Integer id;
/**
* 机具IMEI码
*/
private String imei;
/**
* 序列号(SN)
*/
private String sn;
/**
* 机具型号
*/
private String series;
/**
* Android版本
*/
private String androidVersion;
/**
* 版本号
*/
private String version;
/**
* 归属网点
*/
private String location;
/**
* 归属项目ID
*/
private Integer projectId;
/**
* 入网时间
*/
private Date jointime;
/**
* 绑定时间
*/
private Date bindtime;
/**
* 产权方
*/
private String owner;
/**
* 备注
*/
private String tips;
/**
* 机具状态: 1:正常 2:故障 3:维修中(返厂) 4:已禁用(丢失) 5:已停用(回收)
*/
private Integer posState;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 获取 主键ID.
*
* @return 主键ID.
*/
public Integer getId() {
return id;
}
/**
* 设置 主键ID.
*
* @param id 主键ID.
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取 机具IMEI码.
*
* @return 机具IMEI码.
*/
public String getImei() {
return imei;
}
/**
* 设置 机具IMEI码.
*
* @param imei 机具IMEI码.
*/
public void setImei(String imei) {
this.imei = imei;
}
/**
* 获取 序列号(SN).
*
* @return 序列号(SN).
*/
public String getSn() {
return sn;
}
/**
* 设置 序列号(SN).
*
* @param sn 序列号(SN).
*/
public void setSn(String sn) {
this.sn = sn;
}
/**
* 获取 机具型号.
*
* @return 机具型号.
*/
public String getSeries() {
return series;
}
/**
* 设置 机具型号.
*
* @param series 机具型号.
*/
public void setSeries(String series) {
this.series = series;
}
/**
* 获取 Android版本.
*
* @return Android版本.
*/
public String getAndroidVersion() {
return androidVersion;
}
/**
* 设置 Android版本.
*
* @param androidVersion Android版本.
*/
public void setAndroidVersion(String androidVersion) {
this.androidVersion = androidVersion;
}
/**
* 获取 版本号.
*
* @return 版本号.
*/
public String getVersion() {
return version;
}
/**
* 设置 版本号.
*
* @param version 版本号.
*/
public void setVersion(String version) {
this.version = version;
}
/**
* 获取 归属网点.
*
* @return 归属网点.
*/
public String getLocation() {
return location;
}
/**
* 设置 归属网点.
*
* @param location 归属网点.
*/
public void setLocation(String location) {
this.location = location;
}
/**
* 获取 归属项目ID.
*
* @return 归属项目ID.
*/
public Integer getProjectId() {
return projectId;
}
/**
* 设置 归属项目ID.
*
* @param projectId 归属项目ID.
*/
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
/**
* 获取 入网时间.
*
* @return 入网时间.
*/
public Date getJointime() {
return jointime;
}
/**
* 设置 入网时间.
*
* @param jointime 入网时间.
*/
public void setJointime(Date jointime) {
this.jointime = jointime;
}
/**
* 获取 绑定时间.
*
* @return 绑定时间.
*/
public Date getBindtime() {
return bindtime;
}
/**
* 设置 绑定时间.
*
* @param bindtime 绑定时间.
*/
public void setBindtime(Date bindtime) {
this.bindtime = bindtime;
}
/**
* 获取 产权方.
*
* @return 产权方.
*/
public String getOwner() {
return owner;
}
/**
* 设置 产权方.
*
* @param owner 产权方.
*/
public void setOwner(String owner) {
this.owner = owner;
}
/**
* 获取 备注.
*
* @return 备注.
*/
public String getTips() {
return tips;
}
/**
* 设置 备注.
*
* @param tips 备注.
*/
public void setTips(String tips) {
this.tips = tips;
}
/**
* 获取 机具状态: 1:正常 2:故障 3:维修中(返厂) 4:已禁用(丢失) 5:已停用(回收).
*
* @return 机具状态: 1:正常 2:故障 3:维修中(返厂) 4:已禁用(丢失) 5:已停用(回收).
*/
public Integer getPosState() {
return posState;
}
/**
* 设置 机具状态: 1:正常 2:故障 3:维修中(返厂) 4:已禁用(丢失) 5:已停用(回收).
*
* @param posState 机具状态: 1:正常 2:故障 3:维修中(返厂) 4:已禁用(丢失) 5:已停用(回收).
*/
public void setPosState(Integer posState) {
this.posState = posState;
}
/**
* 获取 创建时间.
*
* @return 创建时间.
*/
public Date getCreatedTime() {
return createdTime;
}
/**
* 设置 创建时间.
*
* @param createdTime 创建时间.
*/
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
/**
* 获取 更新时间.
*
* @return 更新时间.
*/
public Date getUpdatedTime() {
return updatedTime;
}
/**
* 设置 更新时间.
*
* @param updatedTime 更新时间.
*/
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -1,176 +0,0 @@
package com.xncoding.jwt.common.dao.entity;
import java.io.Serializable;
import java.util.Date;
/**
* POS机历史归属表
*
* @author 熊能
* @version 1.0
* @since 2018/01/02
*/
public class PosHistory {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private Integer id;
/**
* POS机ID
*/
private Integer posId;
/**
* 归属网点
*/
private String location;
/**
* 绑定时间
*/
private Date bindtime;
/**
* 解绑时间
*/
private Date unbindtime;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 获取 主键ID.
*
* @return 主键ID.
*/
public Integer getId() {
return id;
}
/**
* 设置 主键ID.
*
* @param id 主键ID.
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取 POS机ID.
*
* @return POS机ID.
*/
public Integer getPosId() {
return posId;
}
/**
* 设置 POS机ID.
*
* @param posId POS机ID.
*/
public void setPosId(Integer posId) {
this.posId = posId;
}
/**
* 获取 归属网点.
*
* @return 归属网点.
*/
public String getLocation() {
return location;
}
/**
* 设置 归属网点.
*
* @param location 归属网点.
*/
public void setLocation(String location) {
this.location = location;
}
/**
* 获取 绑定时间.
*
* @return 绑定时间.
*/
public Date getBindtime() {
return bindtime;
}
/**
* 设置 绑定时间.
*
* @param bindtime 绑定时间.
*/
public void setBindtime(Date bindtime) {
this.bindtime = bindtime;
}
/**
* 获取 解绑时间.
*
* @return 解绑时间.
*/
public Date getUnbindtime() {
return unbindtime;
}
/**
* 设置 解绑时间.
*
* @param unbindtime 解绑时间.
*/
public void setUnbindtime(Date unbindtime) {
this.unbindtime = unbindtime;
}
/**
* 获取 创建时间.
*
* @return 创建时间.
*/
public Date getCreatedTime() {
return createdTime;
}
/**
* 设置 创建时间.
*
* @param createdTime 创建时间.
*/
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
/**
* 获取 更新时间.
*
* @return 更新时间.
*/
public Date getUpdatedTime() {
return updatedTime;
}
/**
* 设置 更新时间.
*
* @param updatedTime 更新时间.
*/
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -1,198 +0,0 @@
package com.xncoding.jwt.common.dao.entity;
import java.io.Serializable;
import java.util.Date;
/**
* POS机监控表
*
* @author 熊能
* @version 1.0
* @since 2018/01/02
*/
public class PosMonitor {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private Integer id;
/**
* POS机ID
*/
private Integer posId;
/**
* Socket会话ID
*/
private String sessionId;
/**
* 最近一次报告时间
*/
private Date reportTime;
/**
* 最近一次报告地址
*/
private String reportLocation;
/**
* 在线状态: 1:在线 2:离线
*/
private Integer onlineState;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 获取 主键ID.
*
* @return 主键ID.
*/
public Integer getId() {
return id;
}
/**
* 设置 主键ID.
*
* @param id 主键ID.
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取 POS机ID.
*
* @return POS机ID.
*/
public Integer getPosId() {
return posId;
}
/**
* 设置 POS机ID.
*
* @param posId POS机ID.
*/
public void setPosId(Integer posId) {
this.posId = posId;
}
/**
* 获取 Socket会话ID.
*
* @return Socket会话ID.
*/
public String getSessionId() {
return sessionId;
}
/**
* 设置 Socket会话ID.
*
* @param sessionId Socket会话ID.
*/
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
/**
* 获取 最近一次报告时间.
*
* @return 最近一次报告时间.
*/
public Date getReportTime() {
return reportTime;
}
/**
* 设置 最近一次报告时间.
*
* @param reportTime 最近一次报告时间.
*/
public void setReportTime(Date reportTime) {
this.reportTime = reportTime;
}
/**
* 获取 最近一次报告地址.
*
* @return 最近一次报告地址.
*/
public String getReportLocation() {
return reportLocation;
}
/**
* 设置 最近一次报告地址.
*
* @param reportLocation 最近一次报告地址.
*/
public void setReportLocation(String reportLocation) {
this.reportLocation = reportLocation;
}
/**
* 获取 在线状态: 1:在线 2:离线.
*
* @return 在线状态: 1:在线 2:离线.
*/
public Integer getOnlineState() {
return onlineState;
}
/**
* 设置 在线状态: 1:在线 2:离线.
*
* @param onlineState 在线状态: 1:在线 2:离线.
*/
public void setOnlineState(Integer onlineState) {
this.onlineState = onlineState;
}
/**
* 获取 创建时间.
*
* @return 创建时间.
*/
public Date getCreatedTime() {
return createdTime;
}
/**
* 设置 创建时间.
*
* @param createdTime 创建时间.
*/
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
/**
* 获取 更新时间.
*
* @return 更新时间.
*/
public Date getUpdatedTime() {
return updatedTime;
}
/**
* 设置 更新时间.
*
* @param updatedTime 更新时间.
*/
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -1,154 +0,0 @@
package com.xncoding.jwt.common.dao.entity;
import java.io.Serializable;
import java.util.Date;
/**
* 项目表
*
* @author 熊能
* @version 1.0
* @since 2018/01/02
*/
public class Project {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private Integer id;
/**
* 项目名称
*/
private String name;
/**
* 应用编号
*/
private String applicationId;
/**
* 项目图片
*/
private String icon;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 获取 主键ID.
*
* @return 主键ID.
*/
public Integer getId() {
return id;
}
/**
* 设置 主键ID.
*
* @param id 主键ID.
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取 项目名称.
*
* @return 项目名称.
*/
public String getName() {
return name;
}
/**
* 设置 项目名称.
*
* @param name 项目名称.
*/
public void setName(String name) {
this.name = name;
}
/**
* 获取 应用编号.
*
* @return 应用编号.
*/
public String getApplicationId() {
return applicationId;
}
/**
* 设置 应用编号.
*
* @param applicationId 应用编号.
*/
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
/**
* 获取 项目图片.
*
* @return 项目图片.
*/
public String getIcon() {
return icon;
}
/**
* 设置 项目图片.
*
* @param icon 项目图片.
*/
public void setIcon(String icon) {
this.icon = icon;
}
/**
* 获取 创建时间.
*
* @return 创建时间.
*/
public Date getCreatedTime() {
return createdTime;
}
/**
* 设置 创建时间.
*
* @param createdTime 创建时间.
*/
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
/**
* 获取 更新时间.
*
* @return 更新时间.
*/
public Date getUpdatedTime() {
return updatedTime;
}
/**
* 设置 更新时间.
*
* @param updatedTime 更新时间.
*/
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -1,132 +0,0 @@
package com.xncoding.jwt.common.dao.entity;
import java.io.Serializable;
import java.util.Date;
/**
* 项目用户关联表
*
* @author 熊能
* @version 1.0
* @since 2018/01/02
*/
public class ProjectUser {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private Integer id;
/**
* 用户ID
*/
private Integer userId;
/**
* 项目ID
*/
private Integer projectId;
/**
* 创建时间
*/
private Date createdTime;
/**
* 更新时间
*/
private Date updatedTime;
/**
* 获取 主键ID.
*
* @return 主键ID.
*/
public Integer getId() {
return id;
}
/**
* 设置 主键ID.
*
* @param id 主键ID.
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取 用户ID.
*
* @return 用户ID.
*/
public Integer getUserId() {
return userId;
}
/**
* 设置 用户ID.
*
* @param userId 用户ID.
*/
public void setUserId(Integer userId) {
this.userId = userId;
}
/**
* 获取 项目ID.
*
* @return 项目ID.
*/
public Integer getProjectId() {
return projectId;
}
/**
* 设置 项目ID.
*
* @param projectId 项目ID.
*/
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
/**
* 获取 创建时间.
*
* @return 创建时间.
*/
public Date getCreatedTime() {
return createdTime;
}
/**
* 设置 创建时间.
*
* @param createdTime 创建时间.
*/
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
/**
* 获取 更新时间.
*
* @return 更新时间.
*/
public Date getUpdatedTime() {
return updatedTime;
}
/**
* 设置 更新时间.
*
* @param updatedTime 更新时间.
*/
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
protected Serializable pkVal() {
return this.id;
}
}

View File

@ -1,146 +0,0 @@
package com.xncoding.jwt.service;
import com.xncoding.jwt.api.model.ReportParam;
import com.xncoding.jwt.api.model.VersionParam;
import com.xncoding.jwt.api.model.VersionResult;
import com.xncoding.jwt.common.dao.entity.Pos;
import com.xncoding.jwt.common.dao.entity.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
/**
* 专门用来服务对外接口用Service
*/
@Service
public class ApiService {
private static final Logger logger = LoggerFactory.getLogger(ApiService.class);
/**
* 根据IMEI码查询POS机是否已经入网
*
* @param imei IMEI码
* @return 数量
*/
public int selectCount(String imei) {
return 1;
}
/**
* 根据IMEI码查找POS
*
* @param imei
* @return
*/
public Pos selectByImei(String imei) {
Pos p = new Pos();
p.setImei(imei);
return p;
}
/**
* 根据IMEI码查找绑定网点的POS
*
* @param imei
* @return
*/
public Pos selectBindByImei(String imei) {
return null;
}
/**
* 根据IMEI码查询POS机是否绑定了网点
*
* @param imei IMEI码
* @return 绑定数量
*/
public int selectBindCount(String imei) {
return 1;
}
/**
* 更新机具信息
*
* @param pos
* @return
*/
public int bindLocation(Pos pos) {
return 1;
}
/**
* 执行POS机入网
*
* @param param 参数
* @return 结果
*/
public int insertPos(Pos param) {
return 1;
}
/**
* 根据Application Id查询项目
*
* @param applicationId Application Id
* @return 项目
*/
public Project selectProjectByApplicationId(String applicationId) {
Project p = new Project();
return p;
}
/**
* 更新报告
*
* @param param 报告参数
* @return 结果
*/
public int report(ReportParam param) {
return 1;
}
/**
* Just Update monitor state
*
* @param param report param
* @param sessionId session id.
* @param state 1:在线 2:离线.
* @return result
*/
public int updateJustState(ReportParam param, String sessionId, Integer state) {
return 1;
}
/**
* 根据imei码获取session id
*
* @param imei imei码
* @return sessionId
*/
public String selectSessionId(String imei) {
return "11";
}
/**
* 查询版本发布
* @param param 查询版本参数
* @return 结果
*/
public VersionResult selectPublishCount(VersionParam param) {
return new VersionResult();
}
/**
* 给某个POS机推送网点解除绑定消息
* @param imei imei码
* @param location 解除的网点
* @return error msg
*/
public String sendUnbind(String imei, String location) {
logger.info("开始给POS机推送解绑消息");
return null;
}
}

View File

@ -27,11 +27,8 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
return authorization != null; return authorization != null;
} }
/**
*
*/
@Override @Override
protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception { protected boolean executeLogin(ServletRequest request, ServletResponse response) {
HttpServletRequest httpServletRequest = (HttpServletRequest) request; HttpServletRequest httpServletRequest = (HttpServletRequest) request;
String authorization = httpServletRequest.getHeader("Authorization"); String authorization = httpServletRequest.getHeader("Authorization");
JWTToken token = new JWTToken(authorization); JWTToken token = new JWTToken(authorization);
@ -53,11 +50,7 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
@Override @Override
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) { protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
if (isLoginAttempt(request, response)) { if (isLoginAttempt(request, response)) {
try { return executeLogin(request, response);
executeLogin(request, response);
} catch (Exception e) {
response401(request, response);
}
} }
return true; return true;
} }
@ -81,7 +74,7 @@ public class JWTFilter extends BasicHttpAuthenticationFilter {
} }
/** /**
* 将非法请求跳转到 /401 * 将非法请求 /401
*/ */
private void response401(ServletRequest req, ServletResponse resp) { private void response401(ServletRequest req, ServletResponse resp) {
try { try {

View File

@ -1,8 +1,5 @@
package com.xncoding.jwt; package com.xncoding.jwt;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xncoding.jwt.api.model.VersionParam;
import com.xncoding.jwt.shiro.ShiroKit; import com.xncoding.jwt.shiro.ShiroKit;
import org.junit.Test; import org.junit.Test;
@ -25,13 +22,4 @@ public class SimpleTest {
System.out.println("这个是保存进数据库的密码:" + encodedPassword); System.out.println("这个是保存进数据库的密码:" + encodedPassword);
System.out.println("这个是保存进数据库的盐:" + salt); System.out.println("这个是保存进数据库的盐:" + salt);
} }
@Test
public void testJackson() throws JsonProcessingException {
VersionParam req = new VersionParam();
String reqBody = new ObjectMapper().writeValueAsString(req);
System.out.println(reqBody);
}
} }