package com.yami.trading.api.controller;
|
|
import com.yami.trading.common.domain.Result;
|
import com.yami.trading.common.manager.email.EmailMessage;
|
import com.yami.trading.common.util.IPHelper;
|
import com.yami.trading.service.IdentifyingCodeService;
|
import com.yami.trading.service.IdentifyingCodeTimeWindowService;
|
import com.yami.trading.service.InternalEmailSenderService;
|
import io.swagger.annotations.Api;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.Random;
|
|
@RequestMapping("api/idcode")
|
@RestController
|
@Api(tags = "idcode")
|
public class ApiIdentifyingCodeController {
|
|
@Autowired
|
private IdentifyingCodeService identifyingCodeService;
|
@Autowired
|
private InternalEmailSenderService internalEmailSenderService;
|
@Autowired
|
private IdentifyingCodeTimeWindowService identifyingCodeTimeWindowService;
|
|
@RequestMapping("execute")
|
public Result execute(@RequestParam String target) {
|
// identifyingCodeService.send(target, IPHelper.getIpAddr());
|
Random random = new Random();
|
String code = String.valueOf(random.nextInt(999999) % 900000 + 100000);
|
this.identifyingCodeTimeWindowService.putAuthCode(target, code);
|
EmailMessage emailMessage = new EmailMessage();
|
emailMessage.setContent(code);
|
emailMessage.setTomail(target);
|
internalEmailSenderService.aokSend(emailMessage);
|
return Result.succeed(null);
|
}
|
|
}
|