diff --git a/luoo_user/pom.xml b/luoo_user/pom.xml
index 144d112..3b65228 100644
--- a/luoo_user/pom.xml
+++ b/luoo_user/pom.xml
@@ -77,6 +77,10 @@
common-random
1.0.21
+
+ com.h2database
+ h2
+
app
diff --git a/luoo_user/src/main/java/com/luoo/user/config/InterceptorConfig.java b/luoo_user/src/main/java/com/luoo/user/config/InterceptorConfig.java
index f95541b..cfd835d 100644
--- a/luoo_user/src/main/java/com/luoo/user/config/InterceptorConfig.java
+++ b/luoo_user/src/main/java/com/luoo/user/config/InterceptorConfig.java
@@ -13,7 +13,7 @@ public class InterceptorConfig extends WebMvcConfigurationSupport {
@Autowired
private JwtInterceptor jwtInterceptor;
protected void addInterceptors(InterceptorRegistry registry) {
- String[] excludePathPatterns = { "/user/login/**","/user/appLogin/**","/user/sendsms/**","/doc.html/**","/swagger-resources/**","/webjars/**","/v2/**"};
+ String[] excludePathPatterns = { "/user/login/**","/user/appLogin/**","/user/sendsms/**","/user/touristLogin","/doc.html/**","/swagger-resources/**","/webjars/**","/v2/**"};
registry.addInterceptor(jwtInterceptor).
addPathPatterns("/**").
diff --git a/luoo_user/src/main/java/com/luoo/user/controller/UserController.java b/luoo_user/src/main/java/com/luoo/user/controller/UserController.java
index 0c2de6e..853c592 100644
--- a/luoo_user/src/main/java/com/luoo/user/controller/UserController.java
+++ b/luoo_user/src/main/java/com/luoo/user/controller/UserController.java
@@ -91,7 +91,14 @@ public class UserController {
}
UserVO userVO=userService.loginOrRegister(mobile);
return ResultVO.success(userVO);
- }
+ }
+
+ @ApiOperation(value="3.游客模式返回token",notes="token中的subject和roles均为tourist")
+ @RequestMapping(value = "/touristLogin",method = RequestMethod.GET)
+ public ResultVO touristLogin(){
+ UserVO userVO=userService.touristLogin();
+ return ResultVO.success(userVO);
+ }
/**
* 发送短信验证码
diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/User.java b/luoo_user/src/main/java/com/luoo/user/pojo/User.java
index 5eff48a..d1dd294 100644
--- a/luoo_user/src/main/java/com/luoo/user/pojo/User.java
+++ b/luoo_user/src/main/java/com/luoo/user/pojo/User.java
@@ -1,8 +1,14 @@
package com.luoo.user.pojo;
import javax.persistence.Entity;
+import javax.persistence.EntityListeners;
import javax.persistence.Id;
import javax.persistence.Table;
+
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
import java.io.Serializable;
/**
* 实体类
@@ -11,13 +17,12 @@ import java.io.Serializable;
*/
@Entity
@Table(name="tb_user")
+@EntityListeners(AuditingEntityListener.class)
public class User implements Serializable{
+ private static final long serialVersionUID = 1L;
@Id
private String id;//ID
-
-
-
private String mobile;//手机号码
private String loginname;//用户名
private String password;//密码
@@ -26,7 +31,9 @@ public class User implements Serializable{
private java.util.Date birthday;//出生年月日
private String avatar;//头像
private String email;//E-Mail
+ @CreatedDate
private java.util.Date regdate;//注册日期
+ @LastModifiedDate
private java.util.Date updatedate;//修改日期
private java.util.Date lastdate;//最后登陆日期
private Long online;//在线时长(分钟)
diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserService.java b/luoo_user/src/main/java/com/luoo/user/service/UserService.java
index 12d2fa7..823524b 100644
--- a/luoo_user/src/main/java/com/luoo/user/service/UserService.java
+++ b/luoo_user/src/main/java/com/luoo/user/service/UserService.java
@@ -274,4 +274,15 @@ public class UserService {
User user = userDao.findByMobile(mobile);
return user;
}
+
+
+ public UserVO touristLogin() {
+ UserVO userVO=new UserVO();
+ userVO.setId(String.valueOf(idWorker.nextId()));
+ userVO.setNickname(RandomSource.personInfoSource().randomChineseNickName(8));
+ userVO.setAvatar("default");
+ String token = jwtUtil.createJWT(userVO.getId(),"tourist","tourist");
+ userVO.setToken(token);
+ return userVO;
+ }
}