Commit 68c5376c authored by hanfeng's avatar hanfeng

Merge branch 'base-modify' of http://10.5.52.3/youjj/cloud-platform into base-modify

parents f9ffae79 8d0eacc7
...@@ -166,4 +166,40 @@ public class AuthController { ...@@ -166,4 +166,40 @@ public class AuthController {
} }
/**
* 根据用户id登录 Unbelievable ! ! !
* @param userId
* @return
* @throws Exception
*/
@PostMapping(value = "/applet/uid/login")
public JSONObject appletLoginByUserId(@RequestParam("userId") Integer userId) throws Exception{
JSONObject data = appAuthService.appletLoginByUserId(userId);
if(data!=null&&data.getInteger("status")== ResultCode.SUCCESS_CODE){
JSONObject result=data.getJSONObject("data");
if(result==null){
data.put("status",1001);
}else {
String token=appAuthService.getToken(String.valueOf(data.get("username")),data.getInteger("userId"));
data.put("token",token);
}
}
return data;
}
@PostMapping(value = "/applet/registry")
public JSONObject registryWithApplet(@RequestParam("username") String phone,@RequestParam("password") String pwd,@RequestParam("mobilecode") String code)throws Exception {
JSONObject data=appAuthService.appletRegistry(phone,pwd,code);
if(data!=null&&data.getInteger("status")== ResultCode.SUCCESS_CODE){
JSONObject result=data.getJSONObject("data");
if(result==null){
data.put("status",1001);
}else {
String token=appAuthService.getToken(String.valueOf(data.get("username")),data.getInteger("userId"));
data.put("token",token);
}
}
return data;
}
} }
...@@ -6,10 +6,7 @@ import com.github.wxiaoqi.security.api.vo.user.UserInfo; ...@@ -6,10 +6,7 @@ import com.github.wxiaoqi.security.api.vo.user.UserInfo;
import com.github.wxiaoqi.security.auth.configuration.FeignConfiguration; import com.github.wxiaoqi.security.auth.configuration.FeignConfiguration;
import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest; import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/** /**
...@@ -51,4 +48,22 @@ public interface IUserService { ...@@ -51,4 +48,22 @@ public interface IUserService {
public JSONObject reset( @RequestParam(value="username")String username, public JSONObject reset( @RequestParam(value="username")String username,
@RequestParam(value="mobilecode")String mobilecode, @RequestParam(value="mobilecode")String mobilecode,
@RequestParam(value="password")String password); @RequestParam(value="password")String password);
/**
* 小程序通过用户id登录登录
* @param userid
* @return
*/
@PostMapping("/api/app/applet/uid/login")
JSONObject appletLogin(@RequestParam(value = "userid") Integer userid);
/**
* 小程序注册
* @param phone
* @param pwd
* @param code
* @return
*/
@PostMapping("/api/app/applet/registry")
JSONObject appletRegistry(@RequestParam(value = "phone") String phone,@RequestParam("pwd") String pwd,@RequestParam("code") String code);
} }
...@@ -3,6 +3,7 @@ package com.github.wxiaoqi.security.auth.service; ...@@ -3,6 +3,7 @@ package com.github.wxiaoqi.security.auth.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest; import com.github.wxiaoqi.security.auth.util.user.JwtAuthenticationRequest;
import org.springframework.web.bind.annotation.RequestParam;
public interface AuthService { public interface AuthService {
String login(JwtAuthenticationRequest authenticationRequest) throws Exception; String login(JwtAuthenticationRequest authenticationRequest) throws Exception;
...@@ -16,4 +17,20 @@ public interface AuthService { ...@@ -16,4 +17,20 @@ public interface AuthService {
JSONObject tlogin(String username, String password,String mobilecode,Integer type) throws Exception; JSONObject tlogin(String username, String password,String mobilecode,Integer type) throws Exception;
String getToken(String username,Integer id) throws Exception; String getToken(String username,Integer id) throws Exception;
JSONObject reset(String username, String mobilecode, String password) throws Exception; JSONObject reset(String username, String mobilecode, String password) throws Exception;
/**
* 使用用户id登录 Unbelievable ! ! !
* @param userid
* @return
*/
JSONObject appletLoginByUserId(Integer userid);
/**
* 通过小程序注册
* @param phone
* @param pwd
* @param code
* @return
*/
JSONObject appletRegistry(String phone,String pwd,String code);
} }
...@@ -86,4 +86,14 @@ public class AppAuthServiceImpl implements AuthService { ...@@ -86,4 +86,14 @@ public class AppAuthServiceImpl implements AuthService {
return userService.reset(username,mobilecode,password); return userService.reset(username,mobilecode,password);
} }
@Override
public JSONObject appletLoginByUserId(Integer userid) {
return userService.appletLogin(userid);
}
@Override
public JSONObject appletRegistry(String phone, String pwd, String code) {
return userService.appletRegistry(phone,pwd,code);
}
} }
...@@ -83,4 +83,14 @@ public class AuthServiceImpl implements AuthService { ...@@ -83,4 +83,14 @@ public class AuthServiceImpl implements AuthService {
public JSONObject reset(String username, String mobilecode, String password) throws Exception { public JSONObject reset(String username, String mobilecode, String password) throws Exception {
return userService.reset(username,mobilecode,password); return userService.reset(username,mobilecode,password);
} }
@Override
public JSONObject appletLoginByUserId(Integer userid) {
return userService.appletLogin(userid);
}
@Override
public JSONObject appletRegistry(String phone, String pwd, String code) {
return userService.appletRegistry(phone,pwd,code);
}
} }
...@@ -100,7 +100,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -100,7 +100,7 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
public AppUserLogin checkeUserLogin(String username) { public AppUserLogin checkeUserLogin(String username) {
Example example = new Example(AppUserLogin.class); Example example = new Example(AppUserLogin.class);
example.createCriteria().andEqualTo("username", username).andEqualTo("isdel", 0); example.createCriteria().andEqualTo("username", username).andEqualTo("isdel", 0).andEqualTo("status",0);
List<AppUserLogin> userLoginList = mapper.selectByExample(example); List<AppUserLogin> userLoginList = mapper.selectByExample(example);
if (userLoginList != null && userLoginList.size() != 0) { if (userLoginList != null && userLoginList.size() != 0) {
return userLoginList.get(0); return userLoginList.get(0);
...@@ -149,6 +149,4 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> { ...@@ -149,6 +149,4 @@ public class AppUserLoginBiz extends BaseBiz<AppUserLoginMapper, AppUserLogin> {
public AppUserLogin getUserById(Integer userId){ public AppUserLogin getUserById(Integer userId){
return mapper.selectByPrimaryKey(userId); return mapper.selectByPrimaryKey(userId);
} }
} }
...@@ -171,5 +171,20 @@ public class AppUserRest { ...@@ -171,5 +171,20 @@ public class AppUserRest {
return appPermissionService.upAuthentication(userId,name,idNumber,status); return appPermissionService.upAuthentication(userId,name,idNumber,status);
} }
/**
* 通过用户id登录 unbelievable! ! !
* @param userid
* @return
*/
@PostMapping("/applet/uid/login")
public JSONObject appletLogin(@RequestParam(value = "userid") Integer userid){
return appPermissionService.appletLoginByUserId(userid);
}
@PostMapping("/applet/registry")
public JSONObject appletRegistry(@RequestParam(value = "phone") String phone,@RequestParam("pwd") String pwd,@RequestParam("code") String code){
return appPermissionService.appletRegistry(phone,pwd,code);
}
} }
...@@ -283,7 +283,7 @@ public class AppPermissionService { ...@@ -283,7 +283,7 @@ public class AppPermissionService {
//userRedisTemplate.opsForValue().set("imtoken_" + userid,imtoken_,SystemConfig.REDISTOKENTIME, TimeUnit.SECONDS); //userRedisTemplate.opsForValue().set("imtoken_" + userid,imtoken_,SystemConfig.REDISTOKENTIME, TimeUnit.SECONDS);
// 返回结果 // 返回结果
// data.put("token", token); // data.put("token", token);
data.put("username", username); data.put("username", StringUtils.isNotEmpty(username)?username:userLoign.getUsername());
data.put("userId", userid); data.put("userId", userid);
} }
...@@ -657,4 +657,42 @@ public class AppPermissionService { ...@@ -657,4 +657,42 @@ public class AppPermissionService {
} }
/**
* 通过用户id登录*** Unbelievable! ! !
* @param uid
* @return
*/
public JSONObject appletLoginByUserId(Integer uid) {
JSONObject data = autoLogin(uid, null, null, null);
if (data!=null){
return JsonResultUtil.createSuccessResultWithObj(data);
}
return JsonResultUtil.createFailedResult(ResultCode.NOTEXIST_CODE, "用户不存在");
}
/**
*通过小程序注册
* @param username
* @param password
* @param mobilecode
* @return
*/
public JSONObject appletRegistry(String username,String password,String mobilecode){
try {
// 是否已存在
AppUserLogin user = appUserLoginBiz.checkeUserLogin(username);
JSONObject data=new JSONObject();
if (null == user) {
data=register(username, password, SystemConfig.USER_HEADER_URL_DEFAULT,SystemConfig.USER_NIKENAME_DEFAULT+(int)((Math.random()*9+1)*100000), mobilecode, null, null,0);
}else{
data=login(username,null,mobilecode,2);
}
return data;
} catch (Exception e) {
e.printStackTrace();
return JsonResultUtil.createFailedResult(ResultCode.EXCEPTION_CODE, "出现异常");
}
}
} }
...@@ -28,7 +28,7 @@ public interface ThirdFeign { ...@@ -28,7 +28,7 @@ public interface ThirdFeign {
@RequestMapping(value = "/sms/app/unauth/send", method = RequestMethod.GET) @RequestMapping(value = "/sms/app/unauth/send", method = RequestMethod.GET)
public JSONObject send(@RequestParam(value = "phone") String phone); public JSONObject send(@RequestParam(value = "phone") String phone);
@RequestMapping(value = "/file/app/unauth/uploadFiles", method = RequestMethod.POST) @RequestMapping(value = "/file/app/unauth/uploadFiles", method = RequestMethod.POST)
public JSONObject uploadFiles(@RequestParam("files") MultipartFile[] files); public JSONObject uploadFiles(@RequestParam(value = "files") MultipartFile[] files);
@RequestMapping(value = "/pay/app/wx", method = RequestMethod.POST) @RequestMapping(value = "/pay/app/wx", method = RequestMethod.POST)
public JSONObject wx(@RequestBody OrderPayVo orderPayVo); public JSONObject wx(@RequestBody OrderPayVo orderPayVo);
@RequestMapping(value = "/refund/app/wx", method = RequestMethod.POST) @RequestMapping(value = "/refund/app/wx", method = RequestMethod.POST)
...@@ -61,9 +61,9 @@ public interface ThirdFeign { ...@@ -61,9 +61,9 @@ public interface ThirdFeign {
// @GetMapping(value = "/dictionary/getParents") // @GetMapping(value = "/dictionary/getParents")
@RequestMapping(value = "/dictionary/getParents", method = RequestMethod.GET) @RequestMapping(value = "/dictionary/getParents", method = RequestMethod.GET)
public ObjectRestResponse<List<Dictionary>> dictionaryGetParent(@RequestParam String type); public ObjectRestResponse<List<Dictionary>> dictionaryGetParent(@RequestParam(value = "type") String type);
// @GetMapping(value = "/dictionary/get") // @GetMapping(value = "/dictionary/get")
@RequestMapping(value = "/dictionary/get", method = RequestMethod.GET) @RequestMapping(value = "/dictionary/get", method = RequestMethod.GET)
public ObjectRestResponse<List<Dictionary>> dictionaryGet(@RequestParam Map<String, Object> dictionary); public ObjectRestResponse<List<Dictionary>> dictionaryGet(@RequestParam(value = "dictionary") Map<String, Object> dictionary);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment