| | |
| | | package com.yeshi.location.app.controller.client.api; |
| | | |
| | | import com.ks.lib.common.exception.ParamsException; |
| | | import com.ks.push.exception.BPushDeviceTokenException; |
| | | import com.ks.push.pojo.DO.BPushDeviceToken; |
| | | import com.ks.push.pojo.DO.PushPlatform; |
| | | import com.ks.push.service.BDeviceTokenService; |
| | | import com.yeshi.location.app.dto.user.LoginInfoDTO; |
| | | import com.yeshi.location.app.entity.SystemEnum; |
| | | import com.yeshi.location.app.entity.user.UserInfo; |
| | | import com.yeshi.location.app.entity.user.UserLoginRecord; |
| | | import com.yeshi.location.app.entity.vip.UserVIPInfo; |
| | |
| | | import com.yeshi.location.app.service.inter.user.UserInfoService; |
| | | import com.yeshi.location.app.service.inter.vip.VIPService; |
| | | import com.yeshi.location.app.utils.ApiCodeConstant; |
| | | import com.yeshi.location.app.utils.ThreadUtil; |
| | | import com.yeshi.location.app.utils.annotation.UserLogin; |
| | | import com.yeshi.location.app.vo.AcceptData; |
| | | import com.yeshi.location.app.vo.user.UserInfoVO; |
| | | import net.sf.json.util.JSONUtils; |
| | | import org.apache.commons.lang3.ThreadUtils; |
| | | import org.apache.dubbo.config.annotation.Reference; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | |
| | | @Resource |
| | | private VIPService vipService; |
| | | |
| | | @Reference(check = false) |
| | | private BDeviceTokenService bDeviceTokenService; |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("loginPhone") |
| | | public String loginPhone(AcceptData acceptData, String phone, String vcode, String token) { |
| | |
| | | loginInfo.setSystem(acceptData.getSystem()); |
| | | try { |
| | | UserInfo userInfo = userAccountService.login(loginInfo); |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | try { |
| | | //登录成功 |
| | | bDeviceTokenService.bindUid(acceptData.getSystem().name(), acceptData.getUtdId(), userInfo.getId() + ""); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | } |
| | | }); |
| | | |
| | | return JsonUtil.loadTrueResult(JsonUtil.getApiCommonGson().toJson(userInfo)); |
| | | } catch (LoginException e) { |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | |
| | | @ResponseBody |
| | | @RequestMapping("logout") |
| | | public String logout(AcceptData acceptData, Long uid) { |
| | | try { |
| | | //解绑UID |
| | | bDeviceTokenService.unBindUid(acceptData.getSystem().name(), acceptData.getUtdId()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | |
| | | return JsonUtil.loadTrueResult(vo); |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping("uploadPushRegId") |
| | | public String uploadPushRegId(AcceptData acceptData, Long uid, String regId) { |
| | | |
| | | BPushDeviceToken deviceToken = new BPushDeviceToken(); |
| | | deviceToken.setAppCode(acceptData.getSystem().name()); |
| | | deviceToken.setDeviceId(acceptData.getUtdId()); |
| | | deviceToken.setBuildModel(acceptData.getDeviceType()); |
| | | deviceToken.setBuildVersion(acceptData.getOsVersion()); |
| | | deviceToken.setToken(regId); |
| | | deviceToken.setType(PushPlatform.jpush); |
| | | if (uid != null) { |
| | | deviceToken.setUid(uid + ""); |
| | | } |
| | | deviceToken.setVersionCode(acceptData.getVersion()); |
| | | |
| | | try { |
| | | bDeviceTokenService.save(deviceToken); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } catch (BPushDeviceTokenException e) { |
| | | return JsonUtil.loadTrueResult(e.getMessage()); |
| | | } catch (ParamsException e) { |
| | | return JsonUtil.loadTrueResult(e.getMessage()); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | } |