mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-06-08 02:04:04 +08:00
完善
This commit is contained in:
parent
866b8e0759
commit
32f6966706
@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import xyz.playedu.api.config.MinioConfig;
|
||||
import xyz.playedu.api.service.ImageCaptchaService;
|
||||
import xyz.playedu.api.types.ImageCaptchaResult;
|
||||
import xyz.playedu.api.types.JsonResponse;
|
||||
@ -18,6 +19,9 @@ public class SystemController {
|
||||
@Autowired
|
||||
private ImageCaptchaService imageCaptchaService;
|
||||
|
||||
@Autowired
|
||||
private MinioConfig minioConfig;
|
||||
|
||||
@GetMapping("/image-captcha")
|
||||
public JsonResponse imageCaptcha() throws IOException {
|
||||
ImageCaptchaResult imageCaptchaResult = imageCaptchaService.generate();
|
||||
@ -29,4 +33,11 @@ public class SystemController {
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
@GetMapping("/config")
|
||||
public JsonResponse config() {
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("minio_endpoint", minioConfig.getEndPoint());
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package xyz.playedu.api.controller.backend;
|
||||
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.PostPolicy;
|
||||
import io.minio.PutObjectArgs;
|
||||
import io.minio.*;
|
||||
import io.minio.http.Method;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -100,11 +99,17 @@ public class UploadController {
|
||||
String resourceType = BackendConstant.RESOURCE_EXT_2_TYPE.get(extension.toLowerCase());
|
||||
|
||||
try {
|
||||
PostPolicy postPolicy = new PostPolicy(minioConfig.getBucket(), ZonedDateTime.now().plusDays(1));
|
||||
postPolicy.addStartsWithCondition("Content-Type", contentType);
|
||||
postPolicy.addEqualsCondition("key", HelperUtil.randomString(32));
|
||||
Map<String, String> data = minioClient.getPresignedPostFormData(postPolicy);
|
||||
String url = minioClient.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder()
|
||||
.bucket(minioConfig.getBucket())
|
||||
.object(HelperUtil.randomString(32) + "." + extension)
|
||||
.method(Method.PUT)
|
||||
.expiry(60 * 60 * 24)
|
||||
.build());
|
||||
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
data.put("resource_type", resourceType);
|
||||
data.put("url", url);
|
||||
|
||||
return JsonResponse.data(data);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
|
@ -9,6 +9,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import xyz.playedu.api.constant.BPermissionConstant;
|
||||
import xyz.playedu.api.constant.SystemConstant;
|
||||
import xyz.playedu.api.domain.Department;
|
||||
import xyz.playedu.api.domain.User;
|
||||
import xyz.playedu.api.domain.UserDepartment;
|
||||
import xyz.playedu.api.event.UserDestroyEvent;
|
||||
@ -133,8 +134,11 @@ public class UserController {
|
||||
public JsonResponse edit(@PathVariable(name = "id") Integer id) throws NotFoundException {
|
||||
User user = userService.findOrFail(id);
|
||||
|
||||
List<Integer> depIds = userService.getDepIdsByUserId(user.getId());
|
||||
|
||||
HashMap<String, Object> data = new HashMap<>();
|
||||
data.put("user", user);
|
||||
data.put("dep_ids", depIds);
|
||||
|
||||
return JsonResponse.data(data);
|
||||
}
|
||||
|
@ -27,4 +27,6 @@ public interface UserService extends IService<User> {
|
||||
User createWithDepIds(String email, String name, String avatar, String password, String idCard, Integer[] depIds);
|
||||
|
||||
User updateWithDepIds(User user, String email, String nickname, String name, String avatar, String password, String idCard, Integer[] depIds);
|
||||
|
||||
List<Integer> getDepIdsByUserId(Integer userId);
|
||||
}
|
||||
|
@ -201,6 +201,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
userDepartmentService.resetStoreDepIds(newUser.getId(), depIds);
|
||||
return newUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getDepIdsByUserId(Integer userId) {
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
List<UserDepartment> userDepartments = userDepartmentService.list(userDepartmentService.query().getWrapper().eq("user_id", userId));
|
||||
for (UserDepartment userDepartment : userDepartments) {
|
||||
ids.add(userDepartment.getDepId());
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user