| | |
| | | package com.yeshi.buwan.controller.parser; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.yeshi.buwan.domain.Collection; |
| | | import com.yeshi.buwan.domain.*; |
| | |
| | | import com.yeshi.buwan.dto.search.SolrShortVideoSearchFilter; |
| | | import com.yeshi.buwan.dto.search.SolrVideoSearchFilter; |
| | | import com.yeshi.buwan.dto.user.LoginInfoDto; |
| | | import com.yeshi.buwan.dto.user.QQUserInfo; |
| | | import com.yeshi.buwan.exception.SMSException; |
| | | import com.yeshi.buwan.exception.user.LoginUserException; |
| | | import com.yeshi.buwan.exception.user.RegisterUserException; |
| | |
| | | import com.yeshi.buwan.util.factory.vo.UserInfoVOFactory; |
| | | import com.yeshi.buwan.util.log.LoggerUtil; |
| | | import com.yeshi.buwan.util.log.UserActiveLogFactory; |
| | | import com.yeshi.buwan.util.login.QQLoginUtil; |
| | | import com.yeshi.buwan.util.video.VideoCategoryConstant; |
| | | import com.yeshi.buwan.util.video.VideoConstant; |
| | | import com.yeshi.buwan.util.video.VideoUtil; |
| | | import com.yeshi.buwan.util.wx.MyWXLoginUtil; |
| | | import com.yeshi.buwan.videos.pptv.PPTVUtil; |
| | | import com.yeshi.buwan.vo.AcceptData; |
| | | import com.yeshi.buwan.vo.video.VideoListResultVO; |
| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.yeshi.utils.entity.wx.WeiXinUser; |
| | | import org.yeshi.utils.exception.MailSendException; |
| | | import org.yeshi.utils.mail.EmailApiUtil; |
| | | import org.yeshi.utils.mail.EmailInfo; |
| | |
| | | |
| | | @Resource |
| | | private SMSService smsService; |
| | | |
| | | @Resource |
| | | DetailSystemConfigService detailSystemConfigService; |
| | | |
| | | public void getUid(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | DetailSystem detailSystem = systemService.getDetailSystemByPackage(acceptData.getPackageName()); |
| | |
| | | return; |
| | | } |
| | | |
| | | if (!StringUtil.isNullOrEmpty(account) && !account.trim().endsWith("@qq.com")) { |
| | | if (!StringUtil.isNullOrEmpty(account) && !account.trim().endsWith("@qq.com") && !acceptData.getPackage().equalsIgnoreCase("com.yeshi.buwanshequ.ios")) { |
| | | out.print(JsonUtil.loadFalseJson("只支持QQ邮箱注册")); |
| | | return; |
| | | } |
| | |
| | | out.print(JsonUtil.loadFalseJson("请上传Email")); |
| | | return; |
| | | } |
| | | if (!StringUtil.isNullOrEmpty(account) && !account.trim().endsWith("@qq.com")) { |
| | | if (!StringUtil.isNullOrEmpty(account) && !account.trim().endsWith("@qq.com") && !acceptData.getPackage().equalsIgnoreCase("com.yeshi.buwanshequ.ios")) { |
| | | out.print(JsonUtil.loadFalseJson("只支持QQ邮箱注册")); |
| | | return; |
| | | } |
| | |
| | | * @param out |
| | | */ |
| | | public void login(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | String account = request.getParameter("Email");// 邮箱 |
| | | String pwd = request.getParameter("Pwd");// 密码 |
| | | if (StringUtil.isNullOrEmpty(account)) { |
| | | out.print(JsonUtil.loadFalseJson("请上传Email")); |
| | | return; |
| | | String loginType = request.getParameter("LoginType"); |
| | | int logintTypeInt = LoginUser.LOGIN_TYPE_EMAIL; |
| | | if (!StringUtil.isNullOrEmpty(loginType)) { |
| | | logintTypeInt = Integer.parseInt(loginType); |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(pwd)) { |
| | | out.print(JsonUtil.loadFalseJson("请上传Pwd")); |
| | | return; |
| | | } |
| | | |
| | | // DetailSystem ds = |
| | | // systemService.getDetailSystemByPackage(packageName); |
| | | // 注册 --用户名,昵称,密码 |
| | | |
| | | LoginInfoDto loginInfoDto = new LoginInfoDto(); |
| | | loginInfoDto.setLoginType(LoginUser.LOGIN_TYPE_EMAIL); |
| | | loginInfoDto.setSystemId(acceptData.getDetailSystem().getSystem().getId()); |
| | | loginInfoDto.setEmail(account); |
| | | loginInfoDto.setPwd(StringUtil.Md5(pwd)); |
| | | loginInfoDto.setIpInfo(IPUtil.getRemotIP(request) + ":" + request.getRemotePort()); |
| | | switch (logintTypeInt) { |
| | | case LoginUser.LOGIN_TYPE_EMAIL: { |
| | | String account = request.getParameter("Email");// 邮箱 |
| | | String pwd = request.getParameter("Pwd");// 密码 |
| | | if (StringUtil.isNullOrEmpty(account)) { |
| | | out.print(JsonUtil.loadFalseJson("请上传Email")); |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(pwd)) { |
| | | out.print(JsonUtil.loadFalseJson("请上传Pwd")); |
| | | return; |
| | | } |
| | | loginInfoDto.setLoginType(LoginUser.LOGIN_TYPE_EMAIL); |
| | | loginInfoDto.setSystemId(acceptData.getDetailSystem().getSystem().getId()); |
| | | loginInfoDto.setEmail(account); |
| | | loginInfoDto.setPwd(StringUtil.Md5(pwd)); |
| | | } |
| | | break; |
| | | case LoginUser.LOGIN_TYPE_PHONE: { |
| | | String account = request.getParameter("Phone");// 邮箱 |
| | | String pwd = request.getParameter("Pwd");// 密码 |
| | | if (StringUtil.isNullOrEmpty(account)) { |
| | | out.print(JsonUtil.loadFalseJson("请上传电话号码")); |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(pwd)) { |
| | | out.print(JsonUtil.loadFalseJson("请上传密码")); |
| | | return; |
| | | } |
| | | loginInfoDto.setLoginType(LoginUser.LOGIN_TYPE_PHONE); |
| | | loginInfoDto.setPhone(account); |
| | | loginInfoDto.setPwd(StringUtil.Md5(pwd)); |
| | | |
| | | } |
| | | break; |
| | | case LoginUser.LOGIN_TYPE_QQ: { |
| | | String accessToken = request.getParameter("AccessToken"); |
| | | String openId = request.getParameter("OpenId"); |
| | | if (StringUtil.isNullOrEmpty(accessToken) || StringUtil.isNullOrEmpty(openId)) { |
| | | out.print(JsonUtil.loadFalseJson("请上传QQ授权信息")); |
| | | return; |
| | | } |
| | | |
| | | String qqAppId = detailSystemConfigService.getConfigValueByKey("qq_app_id", acceptData.getDetailSystem().getId(), acceptData.getVersion()); |
| | | if (StringUtil.isNullOrEmpty(qqAppId)) { |
| | | out.print(JsonUtil.loadFalseJson("QQ APPID获取出错")); |
| | | return; |
| | | } |
| | | QQLoginUtil.QQUserInfoEntity userEntity = QQLoginUtil.getUserInfo(qqAppId.trim(), accessToken, openId); |
| | | if (userEntity == null) { |
| | | out.print(JsonUtil.loadFalseJson("QQ用户信息解析出错")); |
| | | return; |
| | | } |
| | | |
| | | QQUserInfo userInfo = new QQUserInfo(); |
| | | userInfo.setSex(userEntity.getGender()); |
| | | userInfo.setPortrait(userEntity.getFigureurl()); |
| | | userInfo.setOpenId(openId); |
| | | userInfo.setName(userEntity.getNickname()); |
| | | loginInfoDto.setLoginType(LoginUser.LOGIN_TYPE_QQ); |
| | | loginInfoDto.setQqUserInfo(userInfo); |
| | | } |
| | | break; |
| | | case LoginUser.LOGIN_TYPE_WX: { |
| | | String code = request.getParameter("Code"); |
| | | if (StringUtil.isNullOrEmpty(code)) { |
| | | out.print(JsonUtil.loadFalseJson("请上传微信授权码")); |
| | | return; |
| | | } |
| | | |
| | | WeiXinUser weiXinUser = MyWXLoginUtil.getUserInfo(code, MyWXLoginUtil.WEIXIN_APPID, MyWXLoginUtil.WEIXIN_SECRET); |
| | | if (weiXinUser == null) { |
| | | out.print(JsonUtil.loadFalseJson("获取授权信息失败,请稍后再试")); |
| | | return; |
| | | } |
| | | loginInfoDto.setLoginType(LoginUser.LOGIN_TYPE_WX); |
| | | loginInfoDto.setWeiXinUser(weiXinUser); |
| | | } |
| | | break; |
| | | default: |
| | | out.print(JsonUtil.loadFalseJson("登录方式错误")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | LoginUser user = userService.login(loginInfoDto); |
| | | out.print(JsonUtil.loadTrueJson(StringUtil.outPutResultJson(user))); |
| | | } catch (LoginUserException e) { |
| | | out.print(JsonUtil.loadFalseJson(e.getMessage())); |
| | | if ((logintTypeInt == LoginUser.LOGIN_TYPE_WX || logintTypeInt == LoginUser.LOGIN_TYPE_QQ) && e.getCode() == LoginUserException.CODE_NO_USER) { |
| | | //注册 |
| | | try { |
| | | LoginUser lu = userService.register(loginInfoDto); |
| | | if (lu != null) { |
| | | JSONObject object = new JSONObject(); |
| | | object.put("user", new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().toJson(lu)); |
| | | out.print(JsonUtil.loadTrueJson(object.toString())); |
| | | } else { |
| | | out.print(JsonUtil.loadFalseJson("登录失败")); |
| | | } |
| | | } catch (RegisterUserException e1) { |
| | | out.print(JsonUtil.loadFalseJson("登录失败")); |
| | | } |
| | | } else { |
| | | out.print(JsonUtil.loadFalseJson(e.getMessage())); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | user.setPortrait(potrait); |
| | | if (!StringUtil.isNullOrEmpty(sex)) |
| | | user.setSex(sex); |
| | | if (!StringUtil.isNullOrEmpty(acceptData.getSign())) |
| | | if (!StringUtil.isNullOrEmpty(personalSign)) |
| | | user.setSign(personalSign); |
| | | if (!StringUtil.isNullOrEmpty(birthDay)) |
| | | user.setBirthday(birthDay); |
| | |
| | | * @param out |
| | | */ |
| | | public void setPwd(AcceptData acceptData, HttpServletRequest request, PrintWriter out) { |
| | | |
| | | |
| | | String email = request.getParameter("Email");// 个性签名 |
| | | String pwd = request.getParameter("Pwd");// 密码 |
| | | String verifyCode = request.getParameter("VerifyCode");// 验证码 |
| | |
| | | } |
| | | |
| | | // 注册 --用户名,昵称,密码 |
| | | LoginUser user = userService.getLoginUserByOpenId(email); |
| | | LoginUser user = userService.getValidLoginUserByEmail(email, acceptData.getDetailSystem().getSystem().getId()); |
| | | if (user == null) { |
| | | out.print(JsonUtil.loadFalseJson("该用户不存在")); |
| | | } else { |
| | |
| | | public static String savePortrait(String base64, HttpSession session) { |
| | | if (StringUtil.isNullOrEmpty(base64)) |
| | | return ""; |
| | | base64 = base64.replace("\r\n",""); |
| | | base64 = base64.replace("\r\n", ""); |
| | | |
| | | String fileName = "portrait_" + System.currentTimeMillis() + ".jpg"; |
| | | // 定义上传路径 |