| | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.sinata.common.constant.Constants; |
| | | import com.sinata.common.core.domain.AjaxResult; |
| | |
| | | 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.*; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Random; |
| | |
| | | public AjaxResult getCode(String phone) |
| | | { |
| | | Random random = new Random(); |
| | | List<SysUser> list = userService.lambdaQuery().eq(SysUser::getPhonenumber, phone).list(); |
| | | List<SysUser> list = userService.lambdaQuery().eq(SysUser::getUserName, phone).list(); |
| | | if (list.isEmpty()){ |
| | | return AjaxResult.error("当前手机号没有对应用户,请联系管理员"); |
| | | } |
| | |
| | | |
| | | List<SysMenu> menus = roleService.roleInfoFromUserId(loginUser.getUserId()); |
| | | String string = redisCache.getCacheObject(loginBody.getUsername()).toString(); |
| | | if (StringUtils.isBlank(string)) { |
| | | return AjaxResult.error("验证码已失效"); |
| | | } |
| | | if (!loginBody.getCode().equals(string)){ |
| | | return AjaxResult.error("验证码错误,请重试"); |
| | | } |