master
parent
4c94652173
commit
b575de3230
|
@ -23,6 +23,11 @@
|
|||
<artifactId>njzscloud-common-core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njzscloud</groupId>
|
||||
<artifactId>njzscloud-common-mvc</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.njzscloud.common.minio.config;
|
||||
|
||||
import com.njzscloud.common.minio.controller.OSSController;
|
||||
import io.minio.MinioAsyncClient;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
@ -19,4 +20,9 @@ public class MinioAutoConfiguration {
|
|||
.credentials(accessKey, secretKey)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public OSSController ossController() {
|
||||
return new OSSController();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
package com.njzscloud.common.minio.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njzscloud.common.core.tuple.Tuple2;
|
||||
import com.njzscloud.common.core.utils.R;
|
||||
import com.njzscloud.common.minio.util.Minio;
|
||||
import com.njzscloud.common.mvc.util.FileResponseUtil;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/oss")
|
||||
public class OSSController {
|
||||
|
||||
@GetMapping("/end_mlt_upload")
|
||||
public R<?> endMltUpload(String objectName, String uploadId, int partNum) {
|
||||
Minio.endMltUpload(objectName, uploadId, partNum);
|
||||
return R.success();
|
||||
}
|
||||
|
||||
@GetMapping("/start_mlt_upload")
|
||||
public R<Tuple2<String, List<String>>> startMltUpload(
|
||||
String objectName,
|
||||
String contentType,
|
||||
int partNum) {
|
||||
return R.success(Minio.startMltUpload(objectName, contentType, partNum));
|
||||
}
|
||||
|
||||
@GetMapping("/obtain_presigned_url")
|
||||
public R<Map<String, String>> obtainPresignedUrl(
|
||||
@RequestParam(value = "bucketName") String bucketName,
|
||||
@RequestParam(value = "filename") String filename) {
|
||||
String objectName = IdUtil.fastSimpleUUID();
|
||||
if (StrUtil.isNotBlank(filename)) {
|
||||
objectName = objectName + "." + FileUtil.extName(filename);
|
||||
}
|
||||
return R.success(Minio.obtainPresignedUrl(bucketName, objectName));
|
||||
}
|
||||
|
||||
@GetMapping("/download/{bucketName}/{objectName}")
|
||||
public void obtainFile(
|
||||
@PathVariable("bucketName") String bucketName,
|
||||
@PathVariable("objectName") String objectName,
|
||||
HttpServletResponse response) {
|
||||
Tuple2<InputStream, String> tuple2 = Minio.obtainFile(bucketName, objectName);
|
||||
FileResponseUtil.download(response, tuple2.get_0(), tuple2.get_1(), objectName);
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.njzscloud.common.mvc.support;
|
|||
|
||||
import com.njzscloud.common.core.ex.CliException;
|
||||
import com.njzscloud.common.core.ex.ExceptionMsg;
|
||||
import com.njzscloud.common.core.ex.SysError;
|
||||
import com.njzscloud.common.core.ex.SysException;
|
||||
import com.njzscloud.common.core.utils.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -283,6 +284,17 @@ public class GlobalExceptionController {
|
|||
return R.failed(e.expect, e.msg, e.message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统错误
|
||||
*/
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ExceptionHandler(SysError.class)
|
||||
public R<?> sysErrorHandler(SysError e) {
|
||||
printRequest();
|
||||
log.error(e.getMessage(), e);
|
||||
return R.failed(e.expect, e.msg, e.message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务器错误
|
||||
*/
|
||||
|
|
|
@ -49,10 +49,10 @@
|
|||
<groupId>com.njzscloud</groupId>
|
||||
<artifactId>njzscloud-common-gen</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>
|
||||
<dependency>
|
||||
<groupId>com.njzscloud</groupId>
|
||||
<artifactId>njzscloud-common-minio</artifactId>
|
||||
</dependency> -->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
|
|
|
@ -21,8 +21,8 @@ import java.nio.file.Paths;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/oss")
|
||||
// @RestController
|
||||
// @RequestMapping("/oss")
|
||||
public class OSSController {
|
||||
|
||||
@Value("${oss.path}")
|
||||
|
|
|
@ -24,6 +24,8 @@ public class UserDetailResult {
|
|||
*/
|
||||
private Gender gender;
|
||||
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package com.njzscloud.supervisory.user.pojo;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njzscloud.supervisory.user.contant.Gender;
|
||||
import com.njzscloud.common.mvc.validator.Constrained;
|
||||
import com.njzscloud.common.mvc.validator.Constraint;
|
||||
import com.njzscloud.common.mvc.validator.ValidRule;
|
||||
import com.njzscloud.supervisory.user.contant.Gender;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
|
@ -24,6 +24,8 @@ public class UserModifyParam implements Constrained {
|
|||
*/
|
||||
private String nickname;
|
||||
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 性别; 字典代码:gender
|
||||
*/
|
||||
|
|
|
@ -105,10 +105,15 @@ public class SysUserService extends ServiceImpl<SysUserMapper, SysUserEntity> im
|
|||
String wechatUnionid = account.getWechatUnionid();
|
||||
|
||||
List<SysUserAccountEntity> oldSysUserList = sysUserAccountService.list(Wrappers.<SysUserAccountEntity>lambdaQuery()
|
||||
.ne(SysUserAccountEntity::getId, id)
|
||||
.and(it1 -> it1
|
||||
.eq(SysUserAccountEntity::getUsername, username)
|
||||
.or().eq(StrUtil.isNotBlank(email), SysUserAccountEntity::getEmail, email)
|
||||
.or().eq(StrUtil.isNotBlank(phone), SysUserAccountEntity::getPhone, phone)
|
||||
.or(StrUtil.isNotBlank(wechatOpenid) && StrUtil.isNotBlank(wechatUnionid), it -> it.eq(SysUserAccountEntity::getWechatOpenid, wechatOpenid).eq(SysUserAccountEntity::getWechatUnionid, wechatUnionid))
|
||||
.or(StrUtil.isNotBlank(wechatOpenid) && StrUtil.isNotBlank(wechatUnionid),
|
||||
it -> it.eq(SysUserAccountEntity::getWechatOpenid, wechatOpenid)
|
||||
.eq(SysUserAccountEntity::getWechatUnionid, wechatUnionid))
|
||||
)
|
||||
);
|
||||
Assert.isTrue(oldSysUserList.stream().noneMatch(it -> username.equals(it.getUsername())), () -> Exceptions.exception("用户名【{}】已被使用", username));
|
||||
Assert.isTrue(StrUtil.isBlank(email) || oldSysUserList.stream().noneMatch(it -> email.equals(it.getEmail())), () -> Exceptions.exception("邮箱【{}】已被使用", email));
|
||||
|
|
|
@ -28,7 +28,7 @@ oss:
|
|||
endpoint: http://localhost:9000
|
||||
access-key: minioadmin
|
||||
secret-key: minioadmin
|
||||
bucket-name: test
|
||||
bucket-name: zsy
|
||||
|
||||
app:
|
||||
district:
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
SELECT a.id,
|
||||
a.nickname,
|
||||
a.gender,
|
||||
a.avatar,
|
||||
a.email,
|
||||
a.phone,
|
||||
b.id account_id,
|
||||
|
|
Loading…
Reference in New Issue