//package com.usky.demo.controller.api;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.baomidou.mybatisplus.core.toolkit.Wrappers;
//import com.usky.common.core.bean.ApiResult;
//import com.usky.common.core.exception.BusinessException;
//import com.usky.common.core.util.BeanMapperUtils;
//import com.usky.common.core.util.FileUtils;
//import com.usky.common.core.util.GlobalUtils;
//import com.usky.demo.domain.SysUser;
//import com.usky.demo.service.SysUserService;
//import com.usky.system.RemoteUserService;
//import com.usky.system.domain.SysUserVO;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.multipart.MultipartFile;
//
//import java.io.File;
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Optional;
//
//@RestController
//public class SysUserControllerApi implements RemoteUserService {
//
//    @Autowired
//    private SysUserService sysUserService;
//    @Override
//    public ApiResult<List<SysUserVO>> getByUserName(String userName) {
//        LambdaQueryWrapper<SysUser> queryWrapper = Wrappers.lambdaQuery();
//        queryWrapper.eq(SysUser::getUserName,userName);
//        return ApiResult.success(BeanMapperUtils.mapList(sysUserService.list(queryWrapper),SysUser.class,SysUserVO.class));
//    }
//
//    @Override
//    public ApiResult<List<SysUserVO>> add(SysUserVO sysUserVO) {
//        sysUserService.save(BeanMapperUtils.map(sysUserVO, SysUser.class));
//        return ApiResult.success(new ArrayList<>());
//    }
//
//    @Override
//    public ApiResult<String> upload(MultipartFile multipartFile) {
//        Optional.ofNullable(multipartFile).orElseThrow(() ->  new BusinessException("文件为空"));
//        String originalFilename = multipartFile.getOriginalFilename();
//        String newFileName = System.currentTimeMillis() + originalFilename;
//        File file = FileUtils.getFile(GlobalUtils.getTempBaseDir(), newFileName);
//        String urlPath = "";
//        try {
//            try {
//                multipartFile.transferTo(file);
//            } catch (IOException e) {
//                throw new BusinessException("文件上传失败");
//            }
//        } catch (Exception e) {
//
//        }
//        return ApiResult.success(urlPath);
//    }
//}
