2 changed files with 80 additions and 0 deletions
@ -0,0 +1,24 @@ |
|||
package cn.chjyj.szwh.service; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 用户登录服务接口层 |
|||
*/ |
|||
public interface LoginService { |
|||
/** |
|||
* 校验用户权限 |
|||
* @param accountId |
|||
* @param nick |
|||
* @return |
|||
*/ |
|||
Map checkUser(String accountId, String nick); |
|||
|
|||
/** |
|||
* 管理员登录 |
|||
* @param phone |
|||
* @param password |
|||
* @return |
|||
*/ |
|||
Map adminLogin(String phone,String password); |
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
package cn.chjyj.szwh.service.impl; |
|||
|
|||
import cn.chjyj.szwh.service.LoginService; |
|||
import cn.chjyj.szwh.utils.ProperUtils; |
|||
import cn.chjyj.szwh.utils.RequestUtils; |
|||
import cn.chjyj.szwh.utils.SignUtils; |
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class LoginServiceImpl implements LoginService { |
|||
/** |
|||
* 校验用户权限 |
|||
* @param accountId |
|||
* @param nick |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public Map checkUser(String accountId, String nick) { |
|||
//待返回的map
|
|||
Map retmap = new HashMap(); |
|||
|
|||
String host = ProperUtils.getSzwhProp("REAL_URL"); |
|||
// 请求路径
|
|||
String path=host+"/slb/adminmgt/v1/permission/getPathByNick" + |
|||
"?accountId="+accountId; |
|||
// 创建签名
|
|||
String sign= SignUtils.createSign("user_real"); |
|||
// 请求头
|
|||
Map<String,Object> hmap =new HashMap(); |
|||
hmap.put("api_token",sign); |
|||
hmap.put("nick",nick); |
|||
hmap.put("Content-Type","application/json"); |
|||
|
|||
//执行请求
|
|||
JSONObject jsonObject = RequestUtils.GetData(path,hmap); |
|||
String code = jsonObject.getString("code"); |
|||
if(!"200".equals(code)){ |
|||
retmap.put("code",400); |
|||
}else{ |
|||
retmap.put("code",200); |
|||
} |
|||
JSONArray jsonArray = jsonObject.getJSONArray("data"); |
|||
retmap.put("data",jsonArray); |
|||
return retmap; |
|||
} |
|||
|
|||
@Override |
|||
public Map adminLogin(String phone, String password) { |
|||
return null; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue