| | |
| | | package com.panzhihua.applets.api; |
| | | |
| | | import com.panzhihua.common.constants.FtpConstants; |
| | | import com.panzhihua.common.constants.UserConstants; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.user.UserPhoneVO; |
| | | import com.panzhihua.common.utlis.SFTPUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.apache.commons.lang3.RandomUtils; |
| | | import org.springframework.data.redis.core.StringRedisTemplate; |
| | | import org.springframework.data.redis.core.ValueOperations; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.InputStream; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | |
| | | @RequestMapping("/common/") |
| | | @Api(tags = {"公共接口"}) |
| | | public class CommonApi { |
| | | @Resource |
| | | private StringRedisTemplate stringRedisTemplate; |
| | | |
| | | @ApiOperation(value = "上传照片") |
| | | @PostMapping(value = "uploadimage",consumes = "multipart/*",headers = "content-type=multipart/form-date") |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | @ApiOperation(value = "发送验证码") |
| | | @PostMapping(value = "smscode") |
| | | public R smscode(@RequestBody UserPhoneVO userPhoneVO) { |
| | | String newPhone = userPhoneVO.getNewPhone(); |
| | | if (ObjectUtils.isEmpty(newPhone)) { |
| | | return R.fail("新手机号不能为空"); |
| | | } |
| | | //todo 发送验证码接第三方 |
| | | int nextInt = RandomUtils.nextInt(99999, 1000000); |
| | | ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); |
| | | valueOperations.set(UserConstants.PHONE_PUT+newPhone,nextInt+"",3, TimeUnit.MINUTES); |
| | | return R.ok(nextInt); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | int nextInt = RandomUtils.nextInt(99999, 1000000); |
| | | System.out.println(nextInt); |
| | | } |
| | | } |