package com.YuyeTech.TPlat.controller; import com.YuyeTech.TPlat.VO.AiInfoVO; import com.YuyeTech.TPlat.VO.ResultVO; import com.YuyeTech.TPlat.dataobject.AiInfo; import com.YuyeTech.TPlat.service.AiInfoService; import com.YuyeTech.TPlat.utils.AliyunOSSUtil; import com.YuyeTech.TPlat.utils.ResultVOUtil; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; /** * 游戏端的信息处理 * 比如给ai 获取头像,性别,姓名等 * @author:slambb * @date:2020/3/25 */ @RestController @RequestMapping("/client_game") public class ClientGameInfoController { @Autowired private AiInfoService aiInfoService; @Autowired private AliyunOSSUtil aliyunOSSUtil; @GetMapping("/ai_random_info") public ResultVO getRandomAIInfo(){ List aiInfoList = aiInfoService.getAllAiInfo(); Random random = new Random(); int n = random.nextInt(aiInfoList.size()); AiInfo aiInfo= aiInfoList.get(n); //输出一个前端用的vo AiInfoVO aiInfoVO = new AiInfoVO(); BeanUtils.copyProperties(aiInfo, aiInfoVO); //修改url,添加访问域名 String url = aliyunOSSUtil.addDomainName(aiInfoVO.getAiAvatar()); aiInfoVO.setAiAvatar(url); return ResultVOUtil.success(aiInfoVO); } @GetMapping("/transfer_picture") public ResultVO transferPicture(String url){ Map map = new HashMap(); map.put("url",url); return ResultVOUtil.success(url); } }