'包结构调整'

This commit is contained in:
2019-04-12 11:28:07 +08:00
parent 55d240ce81
commit fe3ea393ba
6 changed files with 12 additions and 12 deletions

View File

@@ -1,56 +0,0 @@
package net.tccn.user;
import net.tccn.base.JBean;
import net.tccn.service.BaseService;
import org.redkale.net.http.RestMapping;
import org.redkale.net.http.RestService;
import org.redkale.net.http.RestSessionid;
/**
* @author: liangxianyou at 2018/11/22 17:16.
*/
@RestService(name = "user", automapping = true, comment = "用户服务")
public class UserService extends BaseService {
@RestMapping(name = "login", auth = false, comment = "登陆验证")
public JBean login(@RestSessionid String sessionid,
String username,
String pwd) {
User bean = new User();
bean.setUsername(username);
User user = User.dao.findFirst(bean);
if (user == null) {
return JBean.by(-1, "登陆失败:账号无效");
}
JBean jBean = user.checkLogin(pwd);
if (jBean.getCode() == 0) {
cacheSource.set(30 * 60 * 2,sessionid, User.class, user);
user.setSessionid(sessionid);
user.setLoginTime(System.currentTimeMillis());
user.update();
}
return jBean;
}
@RestMapping(name = "current")
public User current(@RestSessionid String sessionid) {
return getT("user_" + sessionid, User.class, () -> User.dao.findFirst(new User(sessionid)));
}
@RestMapping(name = "logout", comment = "退出登陆")
public JBean logout(@RestSessionid String sessionid) {
User user = User.dao.findFirst(new User(sessionid));
if (user != null) {
user.setSessionid("");
user.update();
}
cacheSource.removeAsync("user_" + sessionid);
return new JBean();
}
}