huwhois 3 years ago
parent
commit
83ed6c689a

+ 6 - 2
src/main/java/io/renren/common/utils/ConfigConstant.java

@ -22,14 +22,18 @@ public class ConfigConstant {
22 22
    /**
23 23
     * 验证码过期时间
24 24
     */
25
    public final static int EXPIRE_TIME = 5;
25
    public final static int EXPIRE_TIME = 15;
26 26
27 27
    /**
28 28
     * 阿里云短信签名
29 29
     */
30 30
    public final static String SignName = "中国腐蚀与防护学会";
31 31
    /**
32
     * 阿里云短信模板id
32
     * 阿里云短信模板id_验证码
33 33
     */
34 34
    public final static String TemplateCode = "SMS_202813596";
35
    /**
36
     * 阿里云短信模板id_通知
37
     */
38
    public final static String TemplateCodeNotice = "SMS_225386750";
35 39
}

+ 12 - 4
src/main/java/io/renren/modules/app/controller/AppAttendersController.java

@ -9,6 +9,7 @@ import io.renren.modules.admin.service.AttendersService;
9 9
import io.renren.modules.admin.service.AttendersviewService;
10 10
import io.renren.modules.admin.service.MemberService;
11 11
import io.renren.modules.app.annotation.Login;
12
import io.renren.modules.app.service.SmsCodeService;
12 13
import io.renren.modules.admin.entity.HotalEntity;
13 14
14 15
import java.util.Date;
@ -22,7 +23,6 @@ import org.springframework.web.bind.annotation.RequestBody;
22 23
import org.springframework.web.bind.annotation.RequestMapping;
23 24
import org.springframework.web.bind.annotation.RestController;
24 25
25
26 26
@RestController
27 27
@RequestMapping("/app/attenders")
28 28
public class AppAttendersController {
@ -32,14 +32,16 @@ public class AppAttendersController {
32 32
    private MemberService memberService;
33 33
    @Autowired
34 34
    private AttendersviewService attendersviewService;
35
    @Autowired
36
    private SmsCodeService smsCodeService;
35 37
36 38
    @GetMapping("notToken")
37
    public R notToken(){
39
    public R notToken() {
38 40
        return R.ok().put("msg", "无需token也能访问。。。");
39 41
    }
40 42
41 43
    @PostMapping("save")
42
    public R save(@RequestBody AttendersviewEntity attendersform){
44
    public R save(@RequestBody AttendersviewEntity attendersform) {
43 45
        Long meetingId = attendersform.getMeetingId();
44 46
        if (meetingId == 0L) {
45 47
            return R.error("会议id不可为空");
@ -69,7 +71,7 @@ public class AppAttendersController {
69 71
        member.setMailingAddress(attendersform.getMailingAddress());
70 72
        member.setPostcode(attendersform.getPostcode());
71 73
72
        if (member.getId()==null || member.getId() == 0L) {
74
        if (member.getId() == null || member.getId() == 0L) {
73 75
            memberService.saveMember(member);
74 76
        } else {
75 77
            memberService.updateMember(member);
@ -98,6 +100,12 @@ public class AppAttendersController {
98 100
99 101
        attendersService.save(attenders);
100 102
103
        try {
104
            smsCodeService.registerSuccess(attendersform.getTruename(), attendersform.getPhone());
105
        } catch (Exception e) {
106
            e.printStackTrace();
107
        }
108
        
101 109
        return R.ok();
102 110
    }
103 111

+ 5 - 0
src/main/java/io/renren/modules/app/service/SmsCodeService.java

@ -25,4 +25,9 @@ public interface SmsCodeService extends IService<SmsCodeEntity> {
25 25
     * @return  true:成功  false:失败
26 26
     */
27 27
    void validate(String uuid, String code, String phone) throws RRException;
28
29
    /**
30
     * 报名成功通知短信
31
     */
32
    String registerSuccess(String truename, String phone) throws Exception;
28 33
}

+ 17 - 0
src/main/java/io/renren/modules/app/service/impl/SmsCodeServiceImpl.java

@ -59,4 +59,21 @@ public class SmsCodeServiceImpl extends ServiceImpl<SmsCodeDao, SmsCodeEntity> i
59 59
            throw new RRException("验证码不正确2");
60 60
        }
61 61
    }
62
63
    @Override
64
    public String registerSuccess(String truename, String phone) throws Exception {
65
        if (StringUtils.isBlank(truename) || StringUtils.isBlank(phone) ) {
66
            throw new RRException("姓名, 电话不能为空");
67
        }
68
        String result = "";
69
        try {
70
            // 发送短信
71
            result = AliyunSmsUtils.sendSms(phone, ConfigConstant.SignName, ConfigConstant.TemplateCodeNotice,
72
                    "{\"name\":" + truename + "}");
73
            System.out.println(result);
74
        } catch (Exception e) {
75
            e.printStackTrace();
76
        }
77
        return result;
78
    }
62 79
}