新增密码修改,添加resttemplate更新400状态处理
This commit is contained in:
parent
f001ab0828
commit
7d22720e36
@ -93,4 +93,14 @@ public interface IApiConsts {
|
||||
* 用户详情
|
||||
*/
|
||||
String GET_USER_DETAIL = "%s/resource/user/getuserdetail/%s";
|
||||
|
||||
/**
|
||||
* 密码状态
|
||||
*/
|
||||
String GET_PASSWORD_STATUS = "%s/resource/user/getpasswordstatus";
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
String UPDATE_USER_PASSWORD = "%s/resource/user/updateuserpassword";
|
||||
}
|
||||
|
@ -2,12 +2,16 @@ package com.cm.common.plugin.oauth.controller.apis.user;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cm.common.annotation.CheckRequestBodyAnnotation;
|
||||
import com.cm.common.base.AbstractController;
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import com.cm.common.exception.AccessTokenException;
|
||||
import com.cm.common.exception.ParamsException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.exception.UpdateException;
|
||||
import com.cm.common.plugin.oauth.service.user.IUserService;
|
||||
import com.cm.common.result.ErrorResult;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -140,4 +144,21 @@ public class UserController extends AbstractController {
|
||||
return userService.getUserDetail(params);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取密码状态", notes = "获取密码状态接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("getpasswordstatus")
|
||||
public JSONObject getPasswordStatus() {
|
||||
return userService.getPasswordStatus();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改密码", notes = "修改密码接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("updateuserpassword")
|
||||
@CheckRequestBodyAnnotation
|
||||
public SuccessResult updateUserPassword(@RequestBody Map<String, Object> params) throws ParamsException, SearchException, UpdateException {
|
||||
// params.put("oldPassword", appChangePasswordVO.getOldPassword());
|
||||
// params.put("newPassword", appChangePasswordVO.getNewPassword());
|
||||
return userService.updateUserPassword(params);
|
||||
}
|
||||
|
||||
}
|
@ -40,4 +40,11 @@ public class UserRouteController extends AbstractController {
|
||||
return mv;
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改密码页面", notes = "修改密码页面接口")
|
||||
@GetMapping("updatepassword")
|
||||
public ModelAndView updatePassword() {
|
||||
ModelAndView mv = new ModelAndView("user/update-password.html");
|
||||
return mv;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cm.common.exception.AccessTokenException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@ -127,5 +128,33 @@ public interface IUserService {
|
||||
*/
|
||||
JSONObject getUserDetail(Map<String, Object> params) throws AccessTokenException, SearchException;
|
||||
|
||||
/**
|
||||
* 角色用户列表
|
||||
*
|
||||
* @param accessToken
|
||||
* @param params
|
||||
* @return
|
||||
* @throws AccessTokenException
|
||||
* @throws SearchException
|
||||
*/
|
||||
JSONArray listRoleUsers(String accessToken, Map<String, Object> params) throws AccessTokenException, SearchException;
|
||||
|
||||
/**
|
||||
* 查询密码状态
|
||||
*
|
||||
* @return
|
||||
* @throws AccessTokenException
|
||||
* @throws SearchException
|
||||
*/
|
||||
JSONObject getPasswordStatus() throws AccessTokenException, SearchException;
|
||||
|
||||
/**
|
||||
* 更新用户密码
|
||||
*
|
||||
* @param params
|
||||
* @return
|
||||
* @throws AccessTokenException
|
||||
* @throws SearchException
|
||||
*/
|
||||
SuccessResult updateUserPassword(Map<String, Object> params) throws AccessTokenException, SearchException;
|
||||
}
|
||||
|
@ -9,10 +9,13 @@ import com.cm.common.exception.AccessTokenException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.plugin.IApiConsts;
|
||||
import com.cm.common.plugin.oauth.service.user.IUserService;
|
||||
import com.cm.common.plugin.oauth.token.ClientTokenManager;
|
||||
import com.cm.common.plugin.utils.RestTemplateUtil;
|
||||
import com.cm.common.result.SuccessResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -38,142 +41,100 @@ public class UserServiceImpl extends AbstractService implements IUserService {
|
||||
@Override
|
||||
public JSONArray listDepartmentUsers(Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
String result = restTemplateUtil.doPostForm(String.format(IApiConsts.LIST_DEPARTMENT_USER, apiPathProperties.getUserCenter(), params.get("departmentId").toString()), params);
|
||||
if (result == null) {
|
||||
throw new AccessTokenException("认证失败");
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
throw new SearchException("获取人员列表失败");
|
||||
}
|
||||
searchResourceResult(result, "获取人员列表失败");
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listRoleUsers(Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
String result = restTemplateUtil.doPostForm(String.format(IApiConsts.LIST_ROLE_USER, apiPathProperties.getUserCenter(), params.get("roleId").toString()), params);
|
||||
if (result == null) {
|
||||
throw new AccessTokenException("认证失败");
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
throw new SearchException("获取人员列表失败");
|
||||
}
|
||||
searchResourceResult(result, "获取人员列表失败");
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listGroupUsers(Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
String result = restTemplateUtil.doPostForm(String.format(IApiConsts.LIST_GROUP_USER, apiPathProperties.getUserCenter(), params.get("groupId").toString()), params);
|
||||
if (result == null) {
|
||||
throw new AccessTokenException("认证失败");
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
throw new SearchException("获取人员列表失败");
|
||||
}
|
||||
searchResourceResult(result, "获取人员列表失败");
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listPositionUsers(Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
String result = restTemplateUtil.doPostForm(String.format(IApiConsts.LIST_POSITION_USER, apiPathProperties.getUserCenter(), params.get("positionId").toString()), params);
|
||||
if (result == null) {
|
||||
throw new AccessTokenException("认证失败");
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
throw new SearchException("获取人员列表失败");
|
||||
}
|
||||
searchResourceResult(result, "获取人员列表失败");
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listUserByIds(Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
String result = restTemplateUtil.doPostForm(String.format(IApiConsts.LIST_USER_BY_ID, apiPathProperties.getUserCenter()), params);
|
||||
if (result == null) {
|
||||
throw new AccessTokenException("认证失败");
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
throw new SearchException("获取人员列表失败");
|
||||
}
|
||||
searchResourceResult(result, "获取人员列表失败");
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listAllUsers(Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
String result = restTemplateUtil.doPostForm(String.format(IApiConsts.LIST_ALL_USER, apiPathProperties.getUserCenter()), params);
|
||||
if (result == null) {
|
||||
throw new AccessTokenException("认证失败");
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
throw new SearchException("获取全部人员列表失败");
|
||||
}
|
||||
searchResourceResult(result, "获取全部人员列表失败");
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listUserDepartmentUser(Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
String result = restTemplateUtil.doPostForm(String.format(IApiConsts.LIST_USER_DEPARTMENT_USER, apiPathProperties.getUserCenter(), params.get("userId").toString()), params);
|
||||
if (result == null) {
|
||||
throw new AccessTokenException("认证失败");
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
throw new SearchException("获取人员列表失败");
|
||||
}
|
||||
searchResourceResult(result, "获取人员列表失败");
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listUserDepartmentUserByRole(Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
String result = restTemplateUtil.doPostForm(String.format(IApiConsts.LIST_USER_DEPARTMENT_USER_BY_ROLE, apiPathProperties.getUserCenter(), params.get("userId").toString(), params.get("roleId").toString()), params);
|
||||
if (result == null) {
|
||||
throw new AccessTokenException("认证失败");
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
throw new SearchException("获取人员列表失败");
|
||||
}
|
||||
searchResourceResult(result, "获取人员列表失败");
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listUserDepartmentUserByRole(String token, Map<String, Object> params) throws SearchException {
|
||||
String result = restTemplateUtil.doGetFormForApp(token, String.format(IApiConsts.APP_LIST_USER_DEPARTMENT_USER_BY_ROLE, apiPathProperties.getUserCenter(), params.get("userId").toString(), params.get("roleId").toString()), params);
|
||||
if (result == null || result.isEmpty()) {
|
||||
throw new SearchException("获取人员列表失败");
|
||||
}
|
||||
searchResourceResult(result, "获取人员列表失败");
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listUserDepartmentUserByPosition(Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
String result = restTemplateUtil.doPostForm(String.format(IApiConsts.LIST_USER_DEPARTMENT_USER_BY_POSITION, apiPathProperties.getUserCenter(), params.get("userId").toString(), params.get("positionId").toString()), params);
|
||||
if (result == null) {
|
||||
throw new AccessTokenException("认证失败");
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
throw new SearchException("获取人员列表失败");
|
||||
}
|
||||
searchResourceResult(result, "获取人员列表失败");
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getUserDetail(Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
String result = restTemplateUtil.doPostForm(String.format(IApiConsts.GET_USER_DETAIL, apiPathProperties.getUserCenter(), params.get("userId").toString()), params);
|
||||
if (result == null) {
|
||||
throw new AccessTokenException("认证失败");
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
throw new SearchException("获取人员列表失败");
|
||||
}
|
||||
searchResourceResult(result, "获取人员列表失败");
|
||||
return JSONObject.parseObject(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONArray listRoleUsers(String accessToken, Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
String result = oAuthRestTemplateComponent.doPostFormForOAuth2Client(accessToken, String.format(IApiConsts.LIST_ROLE_USER, apiPathProperties.getUserCenter(), params.get("roleId").toString()), params);
|
||||
if (result == null) {
|
||||
throw new AccessTokenException("认证失败");
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
throw new SearchException("获取人员列表失败");
|
||||
}
|
||||
searchResourceResult(result, "获取人员列表失败");
|
||||
return JSONArray.parseArray(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getPasswordStatus() throws AccessTokenException, SearchException {
|
||||
Map<String, Object> params = getHashMap(0);
|
||||
String result = restTemplateUtil.doGetForm(String.format(IApiConsts.GET_PASSWORD_STATUS, apiPathProperties.getUserCenter()), params);
|
||||
searchResourceResult(result, "获取密码状态失败");
|
||||
return JSONObject.parseObject(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResult updateUserPassword(Map<String, Object> params) throws AccessTokenException, SearchException {
|
||||
String result = restTemplateUtil.doPostForm(String.format(IApiConsts.UPDATE_USER_PASSWORD, apiPathProperties.getUserCenter()), params);
|
||||
updateResourceResult(result, "密码修改失败");
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,9 @@ import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestClientResponseException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.Map;
|
||||
@ -172,7 +175,10 @@ public class RestTemplateUtil {
|
||||
try {
|
||||
LOG.debug("Rest post:\nurl: {},\nparams: {},\nhttpHeaders: {},\nqueryParams: {}", url, params, httpHeaders, queryParams);
|
||||
return getResponse(restTemplate.postForEntity(url, httpEntity, String.class));
|
||||
} catch (Exception e) {
|
||||
} catch (HttpClientErrorException e) {
|
||||
if (e.getRawStatusCode() == HttpStatus.BAD_REQUEST.value()) {
|
||||
return e.getResponseBodyAsString();
|
||||
}
|
||||
LOG.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
@ -187,7 +193,10 @@ public class RestTemplateUtil {
|
||||
try {
|
||||
LOG.debug("Rest post for app:\ntoken: {},\nurl: {},\nparams: {}", token, url, params);
|
||||
return getResponse(restTemplate.postForEntity(url, httpEntity, String.class));
|
||||
} catch (Exception e) {
|
||||
} catch (HttpClientErrorException e) {
|
||||
if (e.getRawStatusCode() == HttpStatus.BAD_REQUEST.value()) {
|
||||
return e.getResponseBodyAsString();
|
||||
}
|
||||
LOG.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
@ -219,8 +228,8 @@ public class RestTemplateUtil {
|
||||
*/
|
||||
private String getResponse(ResponseEntity<String> responseEntity) {
|
||||
LOG.debug(">>>> 请求结果状态: {}, ", responseEntity.getStatusCodeValue());
|
||||
if (HttpStatus.OK.value() == responseEntity.getStatusCodeValue()) {
|
||||
String response = responseEntity.getBody();
|
||||
if (HttpStatus.OK.value() == responseEntity.getStatusCodeValue()) {
|
||||
LOG.debug(">>>> 返回结果: {}", response);
|
||||
return response;
|
||||
} else if (HttpStatus.UNAUTHORIZED.value() == responseEntity.getStatusCodeValue()) {
|
||||
|
@ -0,0 +1,104 @@
|
||||
<!doctype html>
|
||||
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<base th:href="${#httpServletRequest.getScheme() + '://' + #httpServletRequest.getServerName() + ':' + #request.getServerPort() + #request.getContextPath() + '/'} ">
|
||||
<meta charset="utf-8">
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein" style="padding: 0;overflow: hidden;">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body" style="padding: 15px;">
|
||||
<form class="layui-form layui-form-pane" lay-filter="dataForm">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">旧密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="password" name="oldPassword" lay-verify="required" placeholder="请输入旧密码" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">新密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="password" id="newPassword" name="newPassword" lay-verify="required" placeholder="请输入新密码" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">确认密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="password" name="confirmNewPassword" lay-verify="required|passwordSame" placeholder="请输入确认密码" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-layout-admin">
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-footer" style="left: 0;">
|
||||
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交编辑</button>
|
||||
<button type="button" class="layui-btn layui-btn-primary close">关闭窗口</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="assets/layuiadmin/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.config({
|
||||
base: 'assets/layuiadmin/' //静态资源所在路径
|
||||
}).extend({
|
||||
index: 'lib/index' //主入口模块
|
||||
}).use(['index', 'form'], function(){
|
||||
var $ = layui.$;
|
||||
var form = layui.form;
|
||||
|
||||
function closeBox() {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
|
||||
// 提交表单
|
||||
form.on('submit(submitForm)', function(formData) {
|
||||
top.dialog.confirm(top.dataMessage.commit, function(index) {
|
||||
top.dialog.close(index);
|
||||
var loadLayerIndex;
|
||||
top.restAjax.put(top.restAjax.path('api/user/updateuserpassword', []), formData.field, null, function(code, data) {
|
||||
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
|
||||
time: 0,
|
||||
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
||||
shade: 0.3,
|
||||
yes: function(index) {
|
||||
top.dialog.close(index);
|
||||
window.location.reload();
|
||||
},
|
||||
btn2: function() {
|
||||
closeBox();
|
||||
}
|
||||
});
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
});
|
||||
return false;
|
||||
});
|
||||
form.verify({
|
||||
passwordSame: function(value, item) {
|
||||
if($('#newPassword').val() != value) {
|
||||
return '确认密码不一致';
|
||||
}
|
||||
},
|
||||
});
|
||||
$('.close').on('click', function() {
|
||||
closeBox();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -204,7 +204,7 @@ public class ApiLogAspect {
|
||||
params.put("gmtCreate", currentTime);
|
||||
params.put("gmtModified", currentTime);
|
||||
params.put("creator", accessToken);
|
||||
params.put("creatorName", accessToken);
|
||||
params.put("creatorName", "client");
|
||||
systemLoggerService.saveSystemLogger(params);
|
||||
return result;
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
package com.cm.common.base;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cm.common.component.SecurityComponent;
|
||||
import com.cm.common.constants.ISystemConstant;
|
||||
import com.cm.common.exception.AccessTokenException;
|
||||
import com.cm.common.exception.SearchException;
|
||||
import com.cm.common.pojo.bos.UserInfoBO;
|
||||
import com.cm.common.pojo.dtos.ZTreeDTO;
|
||||
import com.cm.common.token.app.AppTokenManager;
|
||||
@ -178,4 +181,42 @@ public abstract class AbstractService {
|
||||
}
|
||||
return securityComponent.getCurrentUser().getBaseDepartmentIds();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询资源结果
|
||||
*
|
||||
* @param result 结果
|
||||
* @param errorMessage 异常提示
|
||||
* @throws AccessTokenException
|
||||
* @throws SearchException
|
||||
*/
|
||||
protected void searchResourceResult(String result, String errorMessage) throws AccessTokenException, SearchException {
|
||||
if (result == null) {
|
||||
throw new AccessTokenException("认证失败");
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
throw new SearchException(errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新结果
|
||||
*
|
||||
* @param result
|
||||
* @param errorMessage
|
||||
* @throws AccessTokenException
|
||||
* @throws SearchException
|
||||
*/
|
||||
protected void updateResourceResult(String result, String errorMessage) throws AccessTokenException, SearchException {
|
||||
if (result == null) {
|
||||
throw new AccessTokenException("认证失败");
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
throw new SearchException(errorMessage);
|
||||
}
|
||||
JSONObject resultObj = JSONObject.parseObject(result);
|
||||
if (resultObj.getString("msg") != null) {
|
||||
throw new SearchException(resultObj.getString("msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,9 +22,10 @@ public class LicenseTest {
|
||||
// 包头东河三务公开:00-16-3E-00-62-F6
|
||||
// 通用 00-16-3E-00-79-58
|
||||
// 乌海海勃湾区 50-AF-73-27-2E-B2
|
||||
// 东河新三务公开:00-16-3E-00-79-BC
|
||||
String mac = AddressUtil.getMacAddress();
|
||||
System.out.println(mac);
|
||||
String license = License.getLicense("2019-11-15", "60", "50-AF-73-27-2E-B2", "CMXX0471");
|
||||
String license = License.getLicense("2019-12-27", "10000", "00-16-3E-00-79-BC", "CMXX0471");
|
||||
System.out.println(license);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user