From fb9f95e888411a348652f4bd210bd998fee01afd Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期二, 02 七月 2024 09:16:05 +0800 Subject: [PATCH] bug修改 --- ruoyi-service/ruoyi-management/src/main/java/com/ruoyi/management/controller/TUserController.java | 106 ++++++++++++++++++++++++++++++----------------------- 1 files changed, 60 insertions(+), 46 deletions(-) diff --git a/ruoyi-service/ruoyi-management/src/main/java/com/ruoyi/management/controller/TUserController.java b/ruoyi-service/ruoyi-management/src/main/java/com/ruoyi/management/controller/TUserController.java index fb71737..891c4cd 100644 --- a/ruoyi-service/ruoyi-management/src/main/java/com/ruoyi/management/controller/TUserController.java +++ b/ruoyi-service/ruoyi-management/src/main/java/com/ruoyi/management/controller/TUserController.java @@ -19,9 +19,8 @@ import com.ruoyi.study.api.dto.AppUserQuery; import com.ruoyi.study.api.dto.UserInfoQuery; import com.ruoyi.study.api.feignClient.StudyClient; -import com.ruoyi.study.api.vo.AppUserVO; -import com.ruoyi.study.api.vo.UserInfoVO; -import com.ruoyi.study.api.vo.VipOrderVO; +import com.ruoyi.study.api.model.TGameRecord; +import com.ruoyi.study.api.vo.*; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; @@ -29,6 +28,8 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.List; /** @@ -78,51 +79,63 @@ @PostMapping("/getUserInfo") @ApiOperation(value = "查看用户详情", tags = {"用户管理"}) public AjaxResult<UserInfoVO> getUserInfo(UserInfoQuery dto) { -// SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd"); -// UserInfoVO res = new UserInfoVO(); -// PageInfo<UserGameRecordVO> list = new PageInfo<>(dto.getPageNumber(), dto.getPageSize()); -// -// -// TUser byId = userService.getById(dto.getId()); -// String name = byId.getName(); -// String phone = byId.getPhone(); -// Date insertTime = byId.getInsertTime(); -// Date vipPayTime = byId.getVipPayTime(); -// Date vipEndTime = byId.getVipEndTime(); -// if (vipEndTime == null){ -// res.setIsVip(0); -// }else{ -// if (vipEndTime.getTime() > System.currentTimeMillis()){ -// res.setIsVip(1); -// }else{ -// res.setIsVip(0); -// } -// } -// if (vipPayTime!=null){ -// res.setVipPayTime(format.format(vipPayTime)); -// } -// res.setState(byId.getState()); -// res.setName(name); -// res.setPhone(phone); -// res.setInsertTime(format.format(insertTime)); -// res.setIntegral(byId.getIntegral()); -// // todo 查询进度 -// res.setCurrent(0); -// res.setSurplus(0); -// res.setTotalHours(0d); -// res.setTodayHours(0d); -// res.setWeekHours(0d); -// res.setMonthHours(0d); -// // todo 查询用户的游戏记录 -// List<UserGameRecordVO> userGameRecordVOS = new ArrayList<>(); -// list.setRecords(userGameRecordVOS); -// list.setTotal(0); -// res.setGameRecords(list); - UserInfoVO data = studyClient.getUserInfo(dto).getData(); - - return AjaxResult.success(data); + UserInfoVO data1 = studyClient.getUserInfo(dto).getData(); + UserInfoVO userInfoVO = new UserInfoVO(); + userInfoVO.setState(data1.getState()); + userInfoVO.setName(data1.getName()); + userInfoVO.setPhone(data1.getPhone()); + userInfoVO.setInsertTime(data1.getInsertTime()); + userInfoVO.setIsVip(data1.getIsVip()); + userInfoVO.setVipPayTime(data1.getVipPayTime()); + userInfoVO.setIntegral(data1.getIntegral()); + userInfoVO.setCurrent(convertToChineseOrdinal(Integer.parseInt(data1.getCurrent()))); + userInfoVO.setSurplus(convertToChineseOrdinal1(Integer.parseInt(data1.getSurplus()))); + userInfoVO.setTotalHours(data1.getTotalHours()); + userInfoVO.setTodayHours(data1.getTodayHours()); + userInfoVO.setWeekHours(data1.getWeekHours()); + userInfoVO.setMonthHours(data1.getMonthHours()); + PageInfo<TGameRecord> gameRecords = data1.getGameRecords(); + List<TGameRecord> records = gameRecords.getRecords(); + for (TGameRecord record : records) { + String s = convertSecondsToHoursMinutes(record.getUseTime()); + record.setUseTime1(s); + } + userInfoVO.setGameRecords(data1.getGameRecords()); + return AjaxResult.success(userInfoVO); } + public static String convertSecondsToHoursMinutes(int seconds) { + int hours = seconds / 3600; + int minutes = (seconds % 3600) / 60; + return String.format("%d小时%d分钟", hours, minutes); + } + public static String convertToChineseOrdinal(int number) { + if (number <= 0 || number > 50) { + return "未知"; + } + String[] chineseNumbers = { + "一", "二", "三", "四", "五", "六", "七", "八", "九", "十", + "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", + "二十一", "二十二", "二十三", "二十四", "二十五", "二十六", "二十七", "二十八", "二十九", "三十", + "三十一", "三十二", "三十三", "三十四", "三十五", "三十六", "三十七", "三十八", "三十九", "四十", + "四十一", "四十二", "四十三", "四十四", "四十五", "四十六", "四十七", "四十八", "四十九", "五十" + }; + return "周目" + chineseNumbers[number - 1]; + } + public static String convertToChineseOrdinal1(int number) { + if (number <= 0 || number > 50) { + return "未知"; + } + String[] chineseNumbers = { + "一", "二", "三", "四", "五", "六", "七", "八", "九", "十", + "十一", "十二", "十三", "十四", "十五", "十六", "十七", "十八", "十九", "二十", + "二十一", "二十二", "二十三", "二十四", "二十五", "二十六", "二十七", "二十八", "二十九", "三十", + "三十一", "三十二", "三十三", "三十四", "三十五", "三十六", "三十七", "三十八", "三十九", "四十", + "四十一", "四十二", "四十三", "四十四", "四十五", "四十六", "四十七", "四十八", "四十九", "五十" + }; + + return chineseNumbers[number - 1]+"周目" ; + } @PostMapping("/freeze") @ApiOperation(value = "冻结/解冻", tags = {"用户管理"}) public AjaxResult freeze(Integer id) { @@ -168,6 +181,7 @@ { return AjaxResult.error("新密码不能与旧密码相同"); } + one.setPassword(SecurityUtils.encryptPassword(password)); return AjaxResult.success(); } @GetMapping("/sendPhoneCode") -- Gitblit v1.7.1