92 lines
3.4 KiB
Java
92 lines
3.4 KiB
Java
|
|
package com.unisinsight.project.controller;
|
||
|
|
|
||
|
|
import com.unisinsight.project.entity.req.DeviceUserReq;
|
||
|
|
import com.unisinsight.project.entity.res.ImageRes;
|
||
|
|
import com.unisinsight.project.exception.BaseErrorCode;
|
||
|
|
import com.unisinsight.project.exception.Result;
|
||
|
|
import com.unisinsight.project.service.ClientService;
|
||
|
|
import com.unisinsight.project.service.DeviceUserMappingService;
|
||
|
|
import io.swagger.annotations.Api;
|
||
|
|
import io.swagger.annotations.ApiOperation;
|
||
|
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
||
|
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
|
||
|
|
import javax.annotation.Resource;
|
||
|
|
import java.util.HashMap;
|
||
|
|
import java.util.List;
|
||
|
|
import java.util.Objects;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @description:
|
||
|
|
* @author: rdpnr_puzhi
|
||
|
|
* @create: 2025/08/08
|
||
|
|
*/
|
||
|
|
@Slf4j
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/api/nex/v1/client")
|
||
|
|
@Api(tags = "客户端类")
|
||
|
|
public class ClientController {
|
||
|
|
|
||
|
|
@Resource
|
||
|
|
private ClientService clientService;
|
||
|
|
|
||
|
|
@Resource
|
||
|
|
private DeviceUserMappingService deviceUserMappingService;
|
||
|
|
|
||
|
|
@ApiOperation(value = "用户认证")
|
||
|
|
@PostMapping("/auth")
|
||
|
|
public Result<List<ImageRes>> authentication(@RequestParam("deviceId") String deviceId) {
|
||
|
|
if (Objects.isNull(deviceId)) {
|
||
|
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
||
|
|
}
|
||
|
|
log.info("用户认证请求参数为:{}", deviceId);
|
||
|
|
return Result.successResult();
|
||
|
|
}
|
||
|
|
|
||
|
|
@ApiOperation(value = "用户登录")
|
||
|
|
@PostMapping("/login")
|
||
|
|
public Result<?> loginUser(@RequestParam("deviceId") String deviceId,
|
||
|
|
@RequestParam("username") String username,
|
||
|
|
@RequestParam("password") String password) {
|
||
|
|
if (Objects.isNull(deviceId) || Objects.isNull(username) || Objects.isNull(password)) {
|
||
|
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
||
|
|
}
|
||
|
|
log.info("用户登录请求参数为,deviceId:{},username:{},password:{}", deviceId, username, password);
|
||
|
|
DeviceUserReq deviceUserReq = new DeviceUserReq();
|
||
|
|
deviceUserReq.setDeviceId(deviceId);
|
||
|
|
deviceUserReq.setUserName(username);
|
||
|
|
deviceUserReq.setPassword(password);
|
||
|
|
return deviceUserMappingService.loginUser(deviceUserReq);
|
||
|
|
}
|
||
|
|
|
||
|
|
@ApiOperation(value = "获取镜像列表")
|
||
|
|
@PostMapping("/getImageList")
|
||
|
|
public Result<?> getImageList(@RequestParam("deviceId") String deviceId,
|
||
|
|
@RequestParam("token") String token) {
|
||
|
|
if (Objects.isNull(deviceId) || Objects.isNull(token)) {
|
||
|
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
||
|
|
}
|
||
|
|
log.info("获取镜像列表请求参数为,deviceId:{},token:{}", deviceId, token);
|
||
|
|
|
||
|
|
return clientService.getImageList(deviceId, token);
|
||
|
|
}
|
||
|
|
|
||
|
|
@ApiOperation(value = "版本更新")
|
||
|
|
@PostMapping("/update")
|
||
|
|
public Result<?> getImageUpdate(@RequestParam("deviceId") String deviceId) {
|
||
|
|
if (Objects.isNull(deviceId)) {
|
||
|
|
return Result.errorResult(BaseErrorCode.PARAMS_CHK_ERROR);
|
||
|
|
}
|
||
|
|
log.info("获取镜像列表请求参数为,deviceId:{}", deviceId);
|
||
|
|
HashMap<String, Object> hashMap = new HashMap<>();
|
||
|
|
hashMap.put("version", "1.0.0");
|
||
|
|
hashMap.put("url", "https://intent-bathhouse.name");
|
||
|
|
return Result.successResult(hashMap);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|