| | |
| | | import com.sinata.common.core.domain.entity.SysUser; |
| | | import com.sinata.common.core.domain.model.LoginBody; |
| | | import com.sinata.common.core.domain.model.LoginUser; |
| | | import com.sinata.common.core.redis.RedisCache; |
| | | import com.sinata.common.utils.SecurityUtils; |
| | | import com.sinata.common.utils.StringUtils; |
| | | import com.sinata.framework.web.service.SysLoginService; |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | private AliSmsService aliSmsService; |
| | | @Resource |
| | | private ISysUserService userService; |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | |
| | | @PostMapping("/getCode") |
| | |
| | | public AjaxResult getCode(String phone) |
| | | { |
| | | Random random = new Random(); |
| | | |
| | | List<SysUser> list = userService.lambdaQuery().eq(SysUser::getPhonenumber, phone).list(); |
| | | if (list.isEmpty()){ |
| | | return AjaxResult.error("当前手机号没有对应用户,请联系管理员"); |
| | | } |
| | | int i = 100000 + random.nextInt(900000); |
| | | aliSmsService.sendLoginCode(phone, String.valueOf(i)); |
| | | redisCache.setCacheObject(String.valueOf(phone), String.valueOf(i)); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/set/getCode") |
| | | @ApiOperation("获取验证码") |
| | | public AjaxResult setgetCode(String phone) |
| | | { |
| | | Random random = new Random(); |
| | | int i = 100000 + random.nextInt(900000); |
| | | aliSmsService.sendLoginCode(phone, String.valueOf(i)); |
| | | redisCache.setCacheObject(String.valueOf(phone), String.valueOf(i)); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | @Resource |
| | | private WeChatUtil weChatUtil; |
| | | |
| | |
| | | // } |
| | | |
| | | List<SysMenu> menus = roleService.roleInfoFromUserId(loginUser.getUserId()); |
| | | |
| | | String string = redisCache.getCacheObject(loginBody.getUsername()).toString(); |
| | | if (!loginBody.getCode().equals(string)){ |
| | | return AjaxResult.error("验证码错误,请重试"); |
| | | } |
| | | // ajax.put("menus", menus); |
| | | ajax.put("userInfo", loginUser); |
| | | return ajax; |