调整代码结构

This commit is contained in:
wenc000 2020-03-09 00:04:40 +08:00
parent 008a14fbf1
commit 198a5cd978
13 changed files with 428 additions and 9 deletions

View File

@ -0,0 +1,109 @@
package com.cm.common.plugin.controller.wechat.datadictionary;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.exception.SearchException;
import com.cm.common.plugin.pojo.dtos.datadictionary.DataDictionaryDTO;
import com.cm.common.plugin.service.datadictionary.IDataDictionaryService;
import com.cm.common.pojo.ListPage;
import com.cm.common.pojo.dtos.ZTreeDTO;
import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResultList;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: DataDictionaryWechatController
* @Description: 微信数据字典
* @Author: WangGeng
* @Date: 2020/3/8 9:47 上午
* @Version: 1.0
**/
@Api(tags = ISystemConstant.API_TAGS_WECHAT_PREFIX + "字典管理接口")
@RestController
@RequestMapping(ISystemConstant.WECHAT_PREFIX + "/datadictionary")
public class DataDictionaryWechatController extends AbstractController {
@Autowired
private IDataDictionaryService dataDictionaryService;
@ApiOperation(value = "字典详情ID查询", notes = "字典详情ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "dictionaryId", value = "字典ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("getdictionarybyid/{dictionaryId}")
public DataDictionaryDTO getDictionaryById(@PathVariable("dictionaryId") String dictionaryId) {
return dataDictionaryService.getDictionaryById(dictionaryId);
}
@ApiOperation(value = "字典列表上级ID查询", notes = "字典列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "dictionaryParentId", value = "字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listdictionarybyparentid/{dictionaryParentId}")
public List<DataDictionaryDTO> listDictionaryByParentId(@PathVariable("dictionaryParentId") String dictionaryParentId) {
return dataDictionaryService.listDictionaryByParentId(dictionaryParentId);
}
@ApiOperation(value = "字典全部列表上级ID查询", notes = "字典全部列表上级ID查询接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "dictionaryParentId", value = "字典上级ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listdictionaryallbyparentid/{dictionaryParentId}")
public List<DataDictionaryDTO> listDictionary(@PathVariable("dictionaryParentId") String dictionaryParentId) throws SearchException {
return dataDictionaryService.listDictionaryAllByParentId(dictionaryParentId);
}
@ApiOperation(value = "分页字典列表", notes = "分页字典列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "parentId", value = "上级ID", paramType = "form", dataType = "String"),
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "form", dataType = "Integer", defaultValue = "1"),
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "form", dataType = "Integer", defaultValue = "20"),
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "form", dataType = "String"),
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "form", dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "form", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listpagedictionary")
public SuccessResultList<List<DataDictionaryDTO>> listPageDictionary(ListPage page) {
Map<String, Object> params = requestParams();
String dictionaryParentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_PARENT_ID) == null ? null : params.get(ISystemConstant.PARAMS_PARENT_ID).toString())) {
dictionaryParentId = params.get(ISystemConstant.PARAMS_PARENT_ID).toString();
}
params.put("dictionaryParentId", dictionaryParentId);
page.setParams(params);
return dataDictionaryService.listPageDictionary(page);
}
@ApiOperation(value = "zTree列表", notes = "zTree列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "父ID", paramType = "form", dataType = "String")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listztreedictionary")
public List<ZTreeDTO> listZTreeDictionary() throws SearchException {
Map<String, Object> params = requestParams();
String dictionaryParentId = "0";
if (!StringUtils.isBlank(params.get(ISystemConstant.PARAMS_ID) == null ? null : params.get(ISystemConstant.PARAMS_ID).toString())) {
dictionaryParentId = params.get(ISystemConstant.PARAMS_ID).toString();
}
params.put("dictionaryParentId", dictionaryParentId);
return dataDictionaryService.listZTreeDictionary(params);
}
}

View File

@ -0,0 +1,107 @@
package com.cm.common.plugin.controller.wechat.file;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.enums.UploadTypeEnum;
import com.cm.common.exception.base.SystemException;
import com.cm.common.plugin.service.file.IFileService;
import com.cm.common.pojo.dtos.FileDTO;
import com.cm.common.result.ErrorResult;
import com.cm.common.result.SuccessResultData;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: FileWechatController
* @Description: 微信文件
* @Author: WangGeng
* @Date: 2020/3/8 9:39 上午
* @Version: 1.0
**/
@Api(tags = ISystemConstant.API_TAGS_WECHAT_PREFIX + "文件管理接口")
@RestController
@RequestMapping(ISystemConstant.WECHAT_PREFIX + "/file")
public class FileWechatController extends AbstractController {
@Autowired
private IFileService fileService;
@ApiOperation(value = "上传文件", notes = "上传文件接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "file", value = "文件name", paramType = "form")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("uploadfile")
public SuccessResultData<String> uploadFile(@RequestHeader("token") String token, @RequestParam("file") MultipartFile file) throws SystemException {
Map<String, Object> params = requestParams();
return uploadSingle(token, file, UploadTypeEnum.FILE, params);
}
@ApiOperation(value = "上传图片", notes = "上传图片接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "image", value = "文件name", paramType = "form")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("uploadimage")
public SuccessResultData<String> uploadImage(@RequestHeader("token") String token, @RequestParam("image") MultipartFile image) throws SystemException {
Map<String, Object> params = requestParams();
return uploadSingle(token, image, UploadTypeEnum.IMAGE, params);
}
@ApiOperation(value = "上传视频", notes = "上传视频接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "video", value = "文件video", paramType = "form")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("uploadvideo")
public SuccessResultData<String> uploadVideo(@RequestHeader("token") String token, @RequestParam("video") MultipartFile video) throws SystemException {
Map<String, Object> params = requestParams();
return uploadSingle(token, video, UploadTypeEnum.VIDEO, params);
}
@ApiOperation(value = "上传音频", notes = "上传音频接口")
@ApiImplicitParams({@ApiImplicitParam(name = "token", value = "token", paramType = "header"),
@ApiImplicitParam(name = "audio", value = "文件audio", paramType = "form")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@PostMapping("uploadaudio")
public SuccessResultData<String> uploadAudio(@RequestHeader("token") String token, @RequestParam("audio") MultipartFile audio) throws SystemException {
Map<String, Object> params = requestParams();
return uploadSingle(token, audio, UploadTypeEnum.AUDIO, params);
}
@ApiOperation(value = "文件列表", notes = "文件列表接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "ids", value = "id列表逗号分隔", paramType = "form")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("listfilebyfileid")
public List<FileDTO> listFileByFileId(@RequestParam("ids") String ids) {
List<String> idList = Arrays.asList(ids.split(","));
return fileService.listFileByFileId(idList);
}
/**
* 上传文件
*
* @param uploadFile
* @param params
* @return
*/
private SuccessResultData<String> uploadSingle(String token, MultipartFile uploadFile, UploadTypeEnum uploadTypeEnum, Map<String, Object> params) throws SystemException {
return fileService.uploadSingle(token, uploadFile, uploadTypeEnum, params);
}
}

View File

@ -0,0 +1,52 @@
package com.cm.common.wechat.controller;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.exception.SearchException;
import com.cm.common.result.SuccessResultData;
import com.cm.common.utils.AesUtil;
import com.cm.common.wechat.manager.officialaccount.WechatOfficialAccountManager;
import com.cm.common.wechat.pojo.WechatOfficialAccountUser;
import io.swagger.annotations.Api;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: WechatOfficialAccountApiController
* @Description: 微信公众号公共接口
* @Author: WangGeng
* @Date: 2020/3/8 10:28 上午
* @Version: 1.0
**/
@Api(tags = ISystemConstant.API_TAGS_WECHAT_PREFIX + "公共接口")
@RestController
@RequestMapping(ISystemConstant.WECHAT_PREFIX + "/officialaccount")
public class WechatOfficialAccountApiController {
@GetMapping("getusertokenbyappidandopenidrelease/{appId}/{openId}")
public SuccessResultData<String> getUserTokenByAppIdAndOpenId(@PathVariable("appId") String appId,
@PathVariable("openId") String openId) throws Exception {
String wechatSignInfo = Base64.encodeBase64String(AesUtil.aesCommonEncoder("WECHAT_SIGN_INFO", new StringBuilder(openId).append("_WenG_").append(appId).toString()).getBytes("UTF-8"));
String token = WechatOfficialAccountManager.getInstance().getAppToken(wechatSignInfo);
return new SuccessResultData<>(token);
}
@GetMapping("getusertokenrelease")
public SuccessResultData<String> getUserToken(HttpServletRequest request) throws Exception {
Object accessToken = request.getSession().getAttribute(ISystemConstant.SESSION_WECHAT_ACCESS_TOKEN);
if (accessToken == null) {
throw new SearchException("用户未登录无token");
}
WechatOfficialAccountUser wechatOfficialAccountUser = (WechatOfficialAccountUser) accessToken;
return new SuccessResultData<>(wechatOfficialAccountUser.getToken());
}
}

View File

@ -1,10 +1,17 @@
package com.cm.common.wechat.controller; package com.cm.common.wechat.controller;
import com.cm.common.constants.ISystemConstant; import com.cm.common.constants.ISystemConstant;
import com.cm.common.result.SuccessResult;
import com.cm.common.result.SuccessResultData;
import com.cm.common.utils.AesUtil;
import com.cm.common.wechat.manager.officialaccount.WechatOfficialAccountManager;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.apache.commons.codec.binary.Base64;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;

View File

@ -1,11 +1,20 @@
package com.cm.common.wechat.filter; package com.cm.common.wechat.filter;
import com.alibaba.fastjson.JSON;
import com.cm.common.constants.ISystemConstant; import com.cm.common.constants.ISystemConstant;
import com.cm.common.enums.AppTokenTypeEnum;
import com.cm.common.enums.ErrorResultCodeEnum;
import com.cm.common.exception.TokenException;
import com.cm.common.result.ErrorResult;
import com.cm.common.token.app.AppTokenManager;
import com.cm.common.token.app.entity.AppToken;
import com.cm.common.token.app.entity.AppTokenUser;
import com.cm.common.wechat.config.pojo.WechatOfficialAccountProperties; import com.cm.common.wechat.config.pojo.WechatOfficialAccountProperties;
import com.cm.common.wechat.manager.officialaccount.WechatOfficialAccountManager; import com.cm.common.wechat.manager.officialaccount.WechatOfficialAccountManager;
import org.apache.shiro.crypto.hash.SimpleHash; import org.apache.shiro.crypto.hash.SimpleHash;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.util.AntPathMatcher; import org.springframework.util.AntPathMatcher;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -42,11 +51,11 @@ public class WechatFilter implements Filter {
/** /**
* 微信放行 * 微信放行
*/ */
private static final String WECHAT_API_RELEASE_URL = "/**/wechat/**release"; private static final String WECHAT_API_RELEASE_URL = "/**/wechat/**/**release/**";
/** /**
* 微信路由放行 * 微信路由放行
*/ */
private static final String WECHAT_ROUTE_RELEASE_URL = "/**/wechatroute/**release"; private static final String WECHAT_ROUTE_RELEASE_URL = "/**/wechatroute/**/**release/**";
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException { public void init(FilterConfig filterConfig) throws ServletException {
@ -67,6 +76,19 @@ public class WechatFilter implements Filter {
return; return;
} }
// 如果header存在token则校验token如果没有就校验session
String token = request.getHeader("token");
if (!StringUtils.isEmpty(token)) {
try {
checkToken(token);
} catch (TokenException e) {
errorResponse(response, e.getMessage());
return;
}
filterChain.doFilter(request, response);
return;
}
// 判断是不是微信配置校验 // 判断是不是微信配置校验
String signatureParameter = request.getParameter("signature"); String signatureParameter = request.getParameter("signature");
String timestampParameter = request.getParameter("timestamp"); String timestampParameter = request.getParameter("timestamp");
@ -109,6 +131,25 @@ public class WechatFilter implements Filter {
response.sendRedirect(WechatOfficialAccountManager.getInstance().getAuthorizeUrl(request.getRequestURL().toString())); response.sendRedirect(WechatOfficialAccountManager.getInstance().getAuthorizeUrl(request.getRequestURL().toString()));
} }
/**
* 校验token
*
* @param token
* @return
* @throws TokenException
*/
private void checkToken(String token) throws TokenException {
AppTokenManager appTokenManager = AppTokenManager.getInstance();
LOG.debug("检查token是否存在");
AppToken appToken = appTokenManager.getToken(token);
if (appToken != null) {
return;
}
LOG.debug("解析token是否合法");
AppTokenUser appTokenUser = appTokenManager.parseToAppTokenUser(token);
appTokenManager.addToken(token, AppTokenTypeEnum.WECHAT, appTokenUser);
}
/** /**
* 是来自微信的配置请求 * 是来自微信的配置请求
* *
@ -138,4 +179,18 @@ public class WechatFilter implements Filter {
this.wechatOfficialAccountProperties = wechatOfficialAccountProperties; this.wechatOfficialAccountProperties = wechatOfficialAccountProperties;
} }
/**
* 错误返回
*
* @param response
* @param errorInfo
* @throws IOException
*/
private void errorResponse(HttpServletResponse response, String errorInfo) throws IOException {
response.setStatus(HttpStatus.BAD_REQUEST.value());
response.setHeader("Content-Type", "application/json;charset=UTF-8");
ErrorResult result = new ErrorResult(ErrorResultCodeEnum.PARAMS_ERROR.getValue(), errorInfo);
response.getWriter().write(JSON.toJSONString(result));
}
} }

View File

@ -3,6 +3,7 @@ package com.cm.common.base;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cm.common.component.SecurityComponent; import com.cm.common.component.SecurityComponent;
import com.cm.common.constants.ISystemConstant; import com.cm.common.constants.ISystemConstant;
import com.cm.common.enums.RoleDataAuthorityEnum;
import com.cm.common.exception.AccessTokenException; import com.cm.common.exception.AccessTokenException;
import com.cm.common.exception.SearchException; import com.cm.common.exception.SearchException;
import com.cm.common.pojo.bos.UserInfoBO; import com.cm.common.pojo.bos.UserInfoBO;
@ -17,10 +18,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @ClassName: AbstractService * @ClassName: AbstractService
@ -255,4 +253,33 @@ public abstract class AbstractService {
} }
return listHeaders; return listHeaders;
} }
/**
* 设置数据权限信息
*
* @param params
*/
protected void setDataAuthorityInfo(Map<String, Object> params) {
UserInfoBO currentUser = securityComponent.getCurrentUser();
if (ISystemConstant.ADMIN.equals(securityComponent.getCurrentUser().getUserName())) {
return;
}
String dataAuthority = currentUser.getDataAuthority();
List<String> dataAuthorityUserIds = currentUser.getDataAuthorityUserIds();
if (org.apache.commons.lang3.StringUtils.equals(RoleDataAuthorityEnum.SELF.getDataAuthorityType(), dataAuthority)) {
params.put(ISystemConstant.DATA_AUTHORITY, dataAuthority);
params.put(ISystemConstant.DATA_CREATOR, currentUser.getUserId());
} else if (org.apache.commons.lang3.StringUtils.equals(RoleDataAuthorityEnum.DEPARTMENT.getDataAuthorityType(), dataAuthority)
|| org.apache.commons.lang3.StringUtils.equals(RoleDataAuthorityEnum.CUSTOM.getDataAuthorityType(), dataAuthority)) {
if (Objects.isNull(dataAuthorityUserIds) || dataAuthorityUserIds.isEmpty()) {
LOG.debug("权限列表为空,设置查看个人");
params.put(ISystemConstant.DATA_AUTHORITY, RoleDataAuthorityEnum.SELF.getDataAuthorityType());
params.put(ISystemConstant.DATA_CREATOR, currentUser.getUserId());
} else {
params.put(ISystemConstant.DATA_AUTHORITY, dataAuthority);
params.put(ISystemConstant.DATA_CREATORS, dataAuthorityUserIds);
}
}
}
} }

View File

@ -116,6 +116,10 @@ public interface ISystemConstant {
* 创建人 * 创建人
*/ */
String DATA_CREATOR = "data_creator"; String DATA_CREATOR = "data_creator";
/**
* 创建人列表
*/
String DATA_CREATORS = "data_creators";
/** /**
* 创建人列 * 创建人列
*/ */

View File

@ -0,0 +1,26 @@
package com.cm.common.enums;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: AppTokenTypeEnum
* @Description: appToken类别
* @Author: WangGeng
* @Date: 2020/3/8 10:09 上午
* @Version: 1.0
**/
public enum AppTokenTypeEnum {
WECHAT("wechat"),
APP("app");
private String type;
AppTokenTypeEnum(String type) {
this.type = type;
}
public String getType() {
return type == null ? "" : type.trim();
}
}

View File

@ -1,4 +1,4 @@
package com.cm.common.plugin.enums.role; package com.cm.common.enums;
/** /**
* When you feel like quitting. Think about why you started * When you feel like quitting. Think about why you started

View File

@ -1,6 +1,7 @@
package com.cm.common.filter; package com.cm.common.filter;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.cm.common.enums.AppTokenTypeEnum;
import com.cm.common.enums.ErrorResultCodeEnum; import com.cm.common.enums.ErrorResultCodeEnum;
import com.cm.common.exception.TokenException; import com.cm.common.exception.TokenException;
import com.cm.common.result.ErrorResult; import com.cm.common.result.ErrorResult;
@ -99,7 +100,7 @@ public class AppFilter implements Filter {
} }
LOG.debug("解析token是否合法"); LOG.debug("解析token是否合法");
AppTokenUser appTokenUser = appTokenManager.parseToAppTokenUser(token); AppTokenUser appTokenUser = appTokenManager.parseToAppTokenUser(token);
appTokenManager.addToken(token, appTokenUser); appTokenManager.addToken(token, AppTokenTypeEnum.APP, appTokenUser);
} }
/** /**

View File

@ -2,6 +2,7 @@ package com.cm.common.token.app;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cm.common.constants.ISystemConstant; import com.cm.common.constants.ISystemConstant;
import com.cm.common.enums.AppTokenTypeEnum;
import com.cm.common.exception.TokenException; import com.cm.common.exception.TokenException;
import com.cm.common.token.app.entity.AppToken; import com.cm.common.token.app.entity.AppToken;
import com.cm.common.token.app.entity.AppTokenUser; import com.cm.common.token.app.entity.AppTokenUser;
@ -59,11 +60,13 @@ public class AppTokenManager {
* 添加token * 添加token
* *
* @param token * @param token
* @param type
* @param appTokenUser * @param appTokenUser
*/ */
public synchronized void addToken(String token, AppTokenUser appTokenUser) { public synchronized void addToken(String token, AppTokenTypeEnum appTokenTypeEnum, AppTokenUser appTokenUser) {
AppToken appToken = new AppToken(); AppToken appToken = new AppToken();
appToken.setToken(token); appToken.setToken(token);
appToken.setAppTokenTypeEnum(appTokenTypeEnum);
appToken.setLastTime(System.currentTimeMillis()); appToken.setLastTime(System.currentTimeMillis());
appToken.setAppTokenUser(appTokenUser); appToken.setAppTokenUser(appTokenUser);
appToken.setUserId(appTokenUser.getId()); appToken.setUserId(appTokenUser.getId());

View File

@ -1,5 +1,7 @@
package com.cm.common.token.app.entity; package com.cm.common.token.app.entity;
import com.cm.common.enums.AppTokenTypeEnum;
/** /**
* When you feel like quitting. Think about why you started * When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始 * 当你想要放弃的时候想想当初你为何开始
@ -13,6 +15,7 @@ package com.cm.common.token.app.entity;
public class AppToken { public class AppToken {
private String token; private String token;
private AppTokenTypeEnum appTokenTypeEnum;
private long lastTime; private long lastTime;
private String userId; private String userId;
private AppTokenUser appTokenUser; private AppTokenUser appTokenUser;
@ -25,6 +28,14 @@ public class AppToken {
this.token = token; this.token = token;
} }
public AppTokenTypeEnum getAppTokenTypeEnum() {
return appTokenTypeEnum;
}
public void setAppTokenTypeEnum(AppTokenTypeEnum appTokenTypeEnum) {
this.appTokenTypeEnum = appTokenTypeEnum;
}
public long getLastTime() { public long getLastTime() {
return lastTime; return lastTime;
} }
@ -54,6 +65,8 @@ public class AppToken {
final StringBuilder sb = new StringBuilder("{"); final StringBuilder sb = new StringBuilder("{");
sb.append("\"token\":") sb.append("\"token\":")
.append("\"").append(token).append("\""); .append("\"").append(token).append("\"");
sb.append(",\"appTokenTypeEnum\":")
.append(appTokenTypeEnum);
sb.append(",\"lastTime\":") sb.append(",\"lastTime\":")
.append(lastTime); .append(lastTime);
sb.append(",\"userId\":") sb.append(",\"userId\":")

15
pom.xml
View File

@ -414,6 +414,21 @@
</configuration> </configuration>
</plugin> </plugin>
<!-- war end --> <!-- war end -->
<!-- source start -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- source end -->
</plugins> </plugins>
</build> </build>
</project> </project>