| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.utils.DateUtils; |
| | | import com.kidgrow.common.utils.StringUtils; |
| | | import com.kidgrow.redis.util.RedisUtils; |
| | | import com.kidgrow.sms.util.SmsChuangLanUtils; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.*; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Random; |
| | | |
| | | @RestController |
| | | @RequestMapping("smsChangLan") |
| | |
| | | return ResultBody.failed("该手机号没有验证码"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 可爱高小程序发送短信 |
| | | * @param map |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "可爱高小程序发送短信") |
| | | @PostMapping("/sendKagMess") |
| | | public ResultBody sendKagMess(@RequestBody Map map){ |
| | | try { |
| | | String phone = MapUtils.getString(map, "phone"); |
| | | if (StringUtils.isBlank(phone)) { |
| | | return ResultBody.failed("手机号无效"); |
| | | } |
| | | String sendContent = MapUtils.getString(map, "content"); |
| | | //region 组装发送消息的内容 |
| | | //API账号 |
| | | map.put("account", CHUANGLAN_SMS_ACCOUNT); |
| | | //API密码 |
| | | map.put("password", CHUANGLAN_SMS_PASSWORD); |
| | | map.put("msg", sendContent); |
| | | //endregion |
| | | |
| | | String send = SmsChuangLanUtils.send(map, CHUANGLAN_SMS_SENDURL); |
| | | JSONObject jsonObject = JSON.parseObject(send); |
| | | if ("0".equals(jsonObject.get("code"))) { |
| | | return ResultBody.ok().msg("发送短信成功"); |
| | | } |
| | | }catch (Exception ex){ |
| | | return ResultBody.failed().msg("发送短信错误"); |
| | | } |
| | | return ResultBody.failed().msg("发送短信失败"); |
| | | } |
| | | |
| | | //获取 存放 Redis的时间 秒(到今晚的秒数) |
| | | public Long getSecondsNextEarlyMorning() { |
| | | Date afterDay = DateUtils.getAfterDay(new Date()); |