| | |
| | | |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.xcong.excoin.common.LoginUserUtils; |
| | | import com.xcong.excoin.common.contants.AppContants; |
| | | import com.xcong.excoin.common.response.Result; |
| | | import com.xcong.excoin.common.system.dto.Base64UploadDto; |
| | | import com.xcong.excoin.common.system.service.CommonService; |
| | | import com.xcong.excoin.configurations.properties.AliOssProperties; |
| | | import com.xcong.excoin.utils.MessageSourceUtils; |
| | | import com.xcong.excoin.utils.OssUtils; |
| | | import com.xcong.excoin.utils.RedisUtils; |
| | | import com.xcong.excoin.utils.SmsUtils; |
| | | import com.xcong.excoin.modules.member.entity.MemberDeviceInfo; |
| | | import com.xcong.excoin.modules.member.entity.MemberEntity; |
| | | import com.xcong.excoin.modules.member.service.MemberDeviceInfoService; |
| | | import com.xcong.excoin.utils.*; |
| | | import com.xcong.excoin.utils.mail.Sms106Send; |
| | | import com.xcong.excoin.utils.mail.SmsSend; |
| | | import com.xcong.excoin.utils.mail.SubMailSend; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | |
| | | @Resource |
| | | private AliOssProperties aliOssProperties; |
| | | |
| | | @Resource |
| | | private MemberDeviceInfoService memberDeviceInfoService; |
| | | |
| | | @ApiOperation(value = "获取验证码接口", notes = "获取验证码通用接口") |
| | | @GetMapping(value = "/verifyCode") |
| | | public Result verifyCode(@ApiParam(name = "account", value = "手机号或邮箱", required = true) @RequestParam(value = "account") String account, |
| | |
| | | |
| | | // 发送手机验证码 |
| | | if (AppContants.ACCOUNT_TYPE_MOBILE.equals(type)) { |
| | | boolean result = SmsSend.sendVerifyCode(account, code.toString(), 2); |
| | | boolean result = Sms106Send.sendVerifyCode(account, code.toString(), 2); |
| | | if (result) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | boolean flag = redisUtils.set(AppContants.VERIFY_CODE_PREFIX + account, code, 120); |
| | |
| | | } |
| | | return Result.fail(MessageSourceUtils.getString("uploadFile_controller_0001")); |
| | | } |
| | | |
| | | @ApiOperation(value = "设备信息", notes = "获取设备信息") |
| | | @GetMapping(value = "/userInfo") |
| | | public Result userInfo(HttpServletRequest request) { |
| | | String device = request.getHeader("device"); |
| | | |
| | | if (StrUtil.isBlank(device)) { |
| | | return Result.fail("device not found"); |
| | | } |
| | | MemberEntity member = LoginUserUtils.getAppLoginUser(); |
| | | QueryWrapper<MemberDeviceInfo> query = new QueryWrapper<>(); |
| | | query.eq("device_code", device); |
| | | Long memberId = null; |
| | | if (member != null) { |
| | | memberId = member.getId(); |
| | | query.eq("member_id", memberId); |
| | | } |
| | | MemberDeviceInfo deviceInfo = memberDeviceInfoService.getOne(query); |
| | | |
| | | String userAgent = HttpUtils.getUserAgent(request); |
| | | String ip = HttpUtils.getRealIp(request); |
| | | if (deviceInfo == null) { |
| | | deviceInfo = new MemberDeviceInfo(); |
| | | deviceInfo.setMemberId(memberId); |
| | | deviceInfo.setUserAgent(userAgent); |
| | | deviceInfo.setDeviceCode(device); |
| | | deviceInfo.setIp(ip); |
| | | memberDeviceInfoService.save(deviceInfo); |
| | | } else { |
| | | deviceInfo.setMemberId(memberId); |
| | | deviceInfo.setUserAgent(userAgent); |
| | | deviceInfo.setDeviceCode(device); |
| | | deviceInfo.setIp(ip); |
| | | memberDeviceInfoService.updateById(deviceInfo); |
| | | } |
| | | |
| | | return Result.ok("success"); |
| | | } |
| | | } |