| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import java.time.Instant; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import com.ruoyi.common.annotation.Anonymous; |
| | | import com.ruoyi.framework.web.domain.server.Sys; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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.RestController; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysMenu; |
| | |
| | | |
| | | @Autowired |
| | | private SysPermissionService permissionService; |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | |
| | | /** |
| | | * 登录方法 |
| | |
| | | return AjaxResult.success(tokenMap); |
| | | } |
| | | |
| | | /** |
| | | * 获取用户当前剩余的试用天数 |
| | | */ |
| | | |
| | | @GetMapping("/leave") |
| | | public AjaxResult getUserLeave(){ |
| | | Long userId = SecurityUtils.getUserId(); |
| | | SysUser sysUser = userService.selectUserById(userId); |
| | | Date startTime = sysUser.getCreateTime(); |
| | | |
| | | // 安全转换 |
| | | Instant instant = startTime.toInstant(); |
| | | LocalDateTime startDateTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime(); |
| | | long daysPassed = ChronoUnit.DAYS.between(startDateTime, LocalDateTime.now()); |
| | | |
| | | return AjaxResult.success("试用提醒:您还有 "+ (7L - daysPassed) + " 天的试用天数"); |
| | | } |
| | | |
| | | /** |
| | | * 管理员授予会员 |
| | | */ |
| | | @GetMapping("/member/{userId}") |
| | | public AjaxResult setMember(@PathVariable("userId") Long userId){ |
| | | SysUser sysUser = userService.selectUserById(userId); |
| | | sysUser.setStatus("0"); |
| | | sysUser.setPaid(1); |
| | | System.out.println("[{{{{{"+sysUser); |
| | | userService.updateUser(sysUser); |
| | | |
| | | return AjaxResult.success(sysUser.getUserName() + " 用户已成为会员"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取用户信息 |