Quellcode durchsuchen

登录接口,未实现

master
郑根木 vor 2 Jahren
Ursprung
Commit
1ba965991a
5 geänderte Dateien mit 166 neuen und 0 gelöschten Zeilen
  1. +86
    -0
      smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/login/AuthService.java
  2. +11
    -0
      smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/login/LoginAckVO.java
  3. +12
    -0
      smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/login/LoginVO.java
  4. +29
    -0
      smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/login/MenuPO.java
  5. +28
    -0
      smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/login/UserPO.java

+ 86
- 0
smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/login/AuthService.java Datei anzeigen

@@ -0,0 +1,86 @@
package cc.smtweb.system.bpm.web.login;

import cc.smtweb.framework.core.annotation.*;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.session.SessionManager;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.framework.core.db.DbEngine;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;

@Slf4j
@SwService
public class AuthService {
@SwParam
private DbEngine dbEngine;

@SwParam
private SessionManager sessionManager;

@SwPerm(SwPerm.NONE)
public R login(@SwBody LoginVO loginPO) {
if (StringUtils.isBlank(loginPO.getUsername())) {
return R.error("账号不能为空");
}

if (StringUtils.isBlank(loginPO.getPassword())) {
return R.error("密码不能为空");
}

UserPO user = dbEngine.queryEntity("select user_id,user_nick_name,user_nick_code,user_pwd,user_create_party_id from sw_user.sys_user where user_nick_code=?", UserPO.class, loginPO.getUsername());

if (user == null) {
return R.error("账号不存在");
}

// digest:md5("goodpj" + user.userId + password)
String pass = DigestUtils.md5Hex("goodpj" + user.getUserId() + loginPO.getPassword());

if (!pass.equals(user.getUserPwd())) {
return R.error("账号或者密码出错");
}

UserSession userSession = new UserSession();
userSession.setUserId(user.getUserId());
userSession.setSiteId(user.getUserCreatePartyId());

String token = sessionManager.login(userSession);

LoginAckVO data = new LoginAckVO();

data.setUserId(user.getUserId());
data.setUserName(user.getUserNickName());
data.setUserAvatar(user.getUserAvatar());
data.setToken(token);

return R.success(data);
}

@SwPerm()
public R ping(@SwParam("msg") String msg) {
return R.success(msg);
}

@SwPerm("user:edit")
public R config(@SwParam("username") String username) {
return R.success("config: " + username);
}


/**
* 退出登录
* @return code
*/
public R logout() {
sessionManager.logout();
return R.success();
}

// defaultRun 命名的函数是默认函数
// @SwPerm(SwPerm.NONE)
// public R defaultRun(@SwPathParam String path) {
// return R.success(path).put("dao", authDao);
// }

}

+ 11
- 0
smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/login/LoginAckVO.java Datei anzeigen

@@ -0,0 +1,11 @@
package cc.smtweb.system.bpm.web.login;

import lombok.Data;

@Data
public class LoginAckVO {
private Long userId;
private String userAvatar;
private String userName;
private String token;
}

+ 12
- 0
smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/login/LoginVO.java Datei anzeigen

@@ -0,0 +1,12 @@
package cc.smtweb.system.bpm.web.login;

import lombok.Data;

import java.io.Serializable;

@Data
public class LoginVO implements Serializable {
private String username;

private String password;
}

+ 29
- 0
smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/login/MenuPO.java Datei anzeigen

@@ -0,0 +1,29 @@
package cc.smtweb.system.bpm.web.login;

import cc.smtweb.framework.core.annotation.SwColumn;
import cc.smtweb.framework.core.annotation.SwTable;
import lombok.Data;

import java.io.Serializable;

@Data
@SwTable("sw_user.sys_menu")
public class MenuPO implements Serializable {
@SwColumn(type={SwColumn.Type.ID})
private Long menuId;

@SwColumn(type={SwColumn.Type.PARENT_ID})
private Long menuParentId;

private String menuName;

private Long menuSiteId;


private String menuPermiss;

private String menuUrl;

@SwColumn(type={SwColumn.Type.ORDER})
private Integer menuSort;
}

+ 28
- 0
smtweb-framework/sw-system-bpm/src/main/java/cc/smtweb/system/bpm/web/login/UserPO.java Datei anzeigen

@@ -0,0 +1,28 @@
package cc.smtweb.system.bpm.web.login;

import cc.smtweb.framework.core.annotation.SwColumn;
import cc.smtweb.framework.core.annotation.SwTable;
import lombok.Data;

import java.io.Serializable;

@Data
@SwTable("sw_user.sys_user")
public class UserPO implements Serializable {
@SwColumn(type={SwColumn.Type.ID})
private Long userId;

private String userNickCode;

private String userNickName;

private Long userCreatePartyId;

private String userPwd;

private String userPhone;

private Integer userStatus;

private String userAvatar;
}

Laden…
Abbrechen
Speichern