mirror of
https://gitee.com/elegant_wings/dbd-meeting.git
synced 2025-06-21 12:29:36 +08:00
修改了对应的登录接口
This commit is contained in:
parent
21d0b3d54f
commit
0c87cb27f3
@ -69,4 +69,5 @@ public interface IcsCustomerStaffMapper extends BaseMapper<IcsCustomerStaff> {
|
||||
*/
|
||||
String checkMobileUnique(IcsCustomerStaff icsCustomerStaff);
|
||||
|
||||
IcsCustomerStaff selectUserByOpenid(String openid);
|
||||
}
|
||||
|
@ -68,4 +68,7 @@ public interface IIcsCustomerStaffService extends IService<IcsCustomerStaff> {
|
||||
* @return
|
||||
*/
|
||||
String checkMobileUnique(IcsCustomerStaff icsCustomerStaff);
|
||||
|
||||
IcsCustomerStaff selectUserByOpenid(String openid);
|
||||
|
||||
}
|
||||
|
@ -94,4 +94,10 @@ public class IcsCustomerStaffServiceImpl extends ServiceImpl<IcsCustomerStaffMap
|
||||
public String checkMobileUnique(IcsCustomerStaff icsCustomerStaff){
|
||||
return icsCustomerStaffMapper.checkMobileUnique(icsCustomerStaff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IcsCustomerStaff selectUserByOpenid(String openid) {
|
||||
|
||||
return icsCustomerStaffMapper.selectUserByOpenid(openid);
|
||||
}
|
||||
}
|
||||
|
@ -149,5 +149,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectIcsCustomerStaffVo"/>
|
||||
WHERE mobile=#{mobile}
|
||||
</select>
|
||||
<select id="selectUserByOpenid" resultType="com.ics.admin.domain.IcsCustomerStaff">
|
||||
<include refid="selectIcsCustomerStaffVo"/>
|
||||
WHERE openid=#{openId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
@ -125,4 +125,9 @@ public class Constants {
|
||||
* 企业访客
|
||||
*/
|
||||
public static final String CUSTOMER_VISIT = "2";
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ import java.util.Map;
|
||||
|
||||
public class SmallWxOkHttp {
|
||||
|
||||
static String APP_ID = "wxa29895567831500a";
|
||||
static String SECRET = "46a11f73665fffaa888061d806661a93";
|
||||
static String APP_ID = "wxd9f93ef41a607dd5";
|
||||
static String SECRET = "417507767334672bc46bb6eb3bf1c29b";
|
||||
|
||||
public static JSONObject sendGet(String url , Map<String, String> map){
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
|
@ -9,10 +9,14 @@ import cn.binarywang.wx.miniapp.util.WxMaConfigHolder;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyun.oss.ServiceException;
|
||||
import com.ics.admin.domain.IcsCustomerStaff;
|
||||
import com.ics.admin.service.IIcsCustomerStaffService;
|
||||
import com.ics.common.annotation.LoginUser;
|
||||
import com.ics.common.constant.Constants;
|
||||
import com.ics.common.core.controller.BaseController;
|
||||
import com.ics.common.core.domain.R;
|
||||
import com.ics.common.exception.user.UserPasswordNotMatchException;
|
||||
import com.ics.common.utils.DateUtils;
|
||||
import com.ics.common.utils.MessageUtils;
|
||||
import com.ics.common.utils.RandomUtil;
|
||||
@ -47,7 +51,9 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class WxLoginAPIController {
|
||||
public class WxLoginAPIController extends BaseController {
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
private IIcsCustomerStaffService icsCustomerStaffService;
|
||||
@ -65,6 +71,44 @@ public class WxLoginAPIController {
|
||||
String smallWxAccessTokenKey = "smallWxAccessToken";
|
||||
String smallWxUserPassword = "123456";
|
||||
|
||||
|
||||
|
||||
@PostMapping("/weixin/login")
|
||||
public R login(@RequestBody Map<String, String> paramMap) {
|
||||
// 参数
|
||||
String jsCode = paramMap.get("jsCode");
|
||||
// 必填
|
||||
if (org.apache.commons.lang3.StringUtils.isBlank(jsCode)) {
|
||||
throw new RuntimeException("请传递jsCode");
|
||||
}
|
||||
// 小程序登录
|
||||
JSONObject sessionObject = SmallWxOkHttp.code2Session(jsCode);
|
||||
String openid = sessionObject.getString("openid");
|
||||
String unionid = sessionObject.getString("unionid");
|
||||
//
|
||||
R ajax = R.ok();
|
||||
// 校验用户是否存在
|
||||
IcsCustomerStaff sysUser = icsCustomerStaffService.selectUserByOpenid(openid);
|
||||
// 用户存在直接获取token
|
||||
if (sysUser != null) {
|
||||
String phonenumber = sysUser.getMobile();
|
||||
User user = new User();
|
||||
PublishFactory.recordLoginInfo(sysUser.getUsername(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
||||
BeanUtils.copyBeanProp(user, sysUser);
|
||||
Map<String, Object> token = tokenService.createToken(user);
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
// ajax.put(Constants.TOKEN, token);
|
||||
ajax.put("user", sysUser);
|
||||
ajax.put("openid", openid);
|
||||
return ajax;
|
||||
} else { // 用户不存在返回openid进行注册登录
|
||||
ajax.put("openid", openid);
|
||||
return ajax;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/social_user_login/login")
|
||||
public R social(@RequestBody Map<String, String> paramMap) {
|
||||
try {
|
||||
@ -92,9 +136,22 @@ public class WxLoginAPIController {
|
||||
User user = new User();
|
||||
PublishFactory.recordLoginInfo(list.get(0).getUsername(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
||||
BeanUtils.copyBeanProp(user,list.get(0));
|
||||
return R.ok(tokenService.createToken(user));
|
||||
Map<String, Object> token = tokenService.createToken(user);
|
||||
R ajax = R.ok();
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
// ajax.put(Constants.TOKEN, token);
|
||||
ajax.put("user", user);
|
||||
ajax.put("openid", openid);
|
||||
return ajax;
|
||||
}else {
|
||||
return R.error("登录失败");
|
||||
// 新增用户信息
|
||||
icsCustomerStaff.setUsername(phoneNumber);
|
||||
icsCustomerStaff.setDataType(Constants.CUSTOMER_VISIT);
|
||||
icsCustomerStaff.setOpenid(openid);
|
||||
icsCustomerStaff.setGender("0");
|
||||
icsCustomerStaff.setStatus("0");
|
||||
int i = icsCustomerStaffService.insertIcsCustomerStaff(icsCustomerStaff);
|
||||
return toAjax(i);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
@ -115,7 +172,7 @@ public class WxLoginAPIController {
|
||||
return smallWxAccessToken;
|
||||
}
|
||||
|
||||
@PostMapping("/wx/login")
|
||||
@PostMapping("/wx/getUserInfo")
|
||||
public R login(@RequestBody String mobile) {
|
||||
try {
|
||||
//检查是否是否存在
|
||||
@ -123,16 +180,15 @@ public class WxLoginAPIController {
|
||||
icsCustomerStaff.setMobile(mobile);
|
||||
List<IcsCustomerStaff> list = icsCustomerStaffService.selectIcsCustomerStaffList(icsCustomerStaff);
|
||||
if(list.size()>0){
|
||||
User user = new User();
|
||||
PublishFactory.recordLoginInfo(list.get(0).getUsername(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"));
|
||||
BeanUtils.copyBeanProp(user,list.get(0));
|
||||
return R.ok(tokenService.createToken(user));
|
||||
IcsCustomerStaff icsCustomerStaff1 = list.get(0);
|
||||
return R.ok().put("data",icsCustomerStaff1);
|
||||
}else {
|
||||
return R.error("登录失败");
|
||||
return R.error("获取微信用户数据失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("调用微信服务器出现异常", e);
|
||||
return R.error("获取微信用户数据失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.ics.controller.mobile.meeting;
|
||||
|
||||
import com.ics.admin.domain.meeting.RoomContent;
|
||||
import com.ics.admin.service.meeting.IRoomContentService;
|
||||
import com.ics.common.core.controller.BaseController;
|
||||
import com.ics.common.core.domain.R;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/roomContent")
|
||||
public class ApiRoomContentController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IRoomContentService roomContentService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取房间内容
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public R list(RoomContent roomContent) {
|
||||
List<RoomContent> roomContents = roomContentService.selectRoomContentList(roomContent);
|
||||
|
||||
return result(roomContents);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user