Compare commits
13
Commits
22e415dd7b
...
v1.0.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19daaff907 | ||
|
|
1658be7d8d | ||
|
|
db94d8f932 | ||
|
|
6c537852a0 | ||
|
|
53618fe362 | ||
|
|
15bf9bd688 | ||
|
|
ce22661a9b | ||
|
|
523edffc4e | ||
|
|
c7ddb1a8b0 | ||
|
|
45c9fc814a | ||
|
|
407dc13ac4 | ||
|
|
0c06bf16c2 | ||
|
|
1db39e77d3 |
@@ -14,7 +14,7 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
deployment_status: ${{ steps.set_status.outputs.status }}
|
deployment_status: ${{ steps.set_status.outputs.status }}
|
||||||
env:
|
env:
|
||||||
JAVA_HOME: /usr/lib/jvm/java-21-openjdk
|
JAVA_HOME: /usr/lib/jvm/java-25-openjdk
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|||||||
@@ -173,7 +173,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.imyeyu.spring</groupId>
|
<groupId>com.imyeyu.spring</groupId>
|
||||||
<artifactId>timi-spring</artifactId>
|
<artifactId>timi-spring</artifactId>
|
||||||
<version>0.0.16</version>
|
<version>0.0.17</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.imyeyu.network</groupId>
|
<groupId>com.imyeyu.network</groupId>
|
||||||
@@ -183,7 +183,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.imyeyu.lang</groupId>
|
<groupId>com.imyeyu.lang</groupId>
|
||||||
<artifactId>timi-lang</artifactId>
|
<artifactId>timi-lang</artifactId>
|
||||||
<version>0.0.4</version>
|
<version>0.0.5</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.imyeyu.java</groupId>
|
||||||
|
<artifactId>timi-java</artifactId>
|
||||||
|
<version>0.0.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.imyeyu.utils</groupId>
|
<groupId>com.imyeyu.utils</groupId>
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class RequestRateLimitInterceptor extends RequestRateLimitAbstractInterce
|
|||||||
redis.setAndKeepTTL(key, ++count);
|
redis.setAndKeepTTL(key, ++count);
|
||||||
} else {
|
} else {
|
||||||
log.warn("请求频率过高:[" + key + "].C" + count + "L" + limit);
|
log.warn("请求频率过高:[" + key + "].C" + count + "L" + limit);
|
||||||
throw new TimiException(TimiCode.REQUEST_BAD).msgKey("request_rate_limit");
|
throw new TimiException(TimiCode.REQUEST_BAD, "request_rate_limit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ public enum CoreRoleCode implements BuiltinRoleCode {
|
|||||||
|
|
||||||
SYSTEM("系统", true, null),
|
SYSTEM("系统", true, null),
|
||||||
|
|
||||||
ADMIN("管理员", false, SYSTEM.name());
|
ADMIN("管理员", false, SYSTEM.name()),
|
||||||
|
|
||||||
|
USER_ROLE_ADMIN("授权管理", false, ADMIN.name());
|
||||||
|
|
||||||
final String defaultName;
|
final String defaultName;
|
||||||
final boolean protectedRole;
|
final boolean protectedRole;
|
||||||
|
|||||||
+5
-5
@@ -97,7 +97,7 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
|
|||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("delete mongo file error, id={}", attach.getId(), e);
|
log.error("delete mongo file error, id={}", attach.getId(), e);
|
||||||
throw new TimiException(TimiCode.ERROR).msgKey("TODO delete mongo file error");
|
throw new TimiException(TimiCode.ERROR, "TODO delete mongo file error");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
mapper.selectThumbsBySourceId(id).forEach(doDestroy::handler);
|
mapper.selectThumbsBySourceId(id).forEach(doDestroy::handler);
|
||||||
@@ -145,7 +145,7 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
|
|||||||
gridFsTemplate.delete(Query.query(Criteria.where("_id").is(mongoId)));
|
gridFsTemplate.delete(Query.query(Criteria.where("_id").is(mongoId)));
|
||||||
}
|
}
|
||||||
log.error("create error", e);
|
log.error("create error", e);
|
||||||
throw new TimiException(TimiCode.ARG_BAD).msgKey("TODO read attachment input stream error");
|
throw new TimiException(TimiCode.ARG_BAD, "TODO read attachment input stream error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
|
|||||||
gridFsTemplate.delete(Query.query(Criteria.where("_id").is(newMongoId)));
|
gridFsTemplate.delete(Query.query(Criteria.where("_id").is(newMongoId)));
|
||||||
}
|
}
|
||||||
log.error("update error", e);
|
log.error("update error", e);
|
||||||
throw new TimiException(TimiCode.ERROR).msgKey("TODO update file error");
|
throw new TimiException(TimiCode.ERROR, "TODO update file error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
|
|||||||
return thumb;
|
return thumb;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("create thumbnail error", e);
|
log.error("create thumbnail error", e);
|
||||||
throw new TimiException(TimiCode.ERROR).msgKey("exception.attachment.create.error");
|
throw new TimiException(TimiCode.ERROR, "exception.attachment.create.error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +354,7 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
|
|||||||
if (isNew) {
|
if (isNew) {
|
||||||
// 请求有、数据库无:将临时文件记录直接转存为永久附件
|
// 请求有、数据库无:将临时文件记录直接转存为永久附件
|
||||||
if (TimiJava.isEmpty(tempFileId)) {
|
if (TimiJava.isEmpty(tempFileId)) {
|
||||||
throw new TimiException(TimiCode.ERROR).msgKey("exception.attachment.file.required");
|
throw new TimiException(TimiCode.ERROR, "exception.attachment.file.required");
|
||||||
}
|
}
|
||||||
Attachment tempFile = mapper.selectRaw(tempFileId);
|
Attachment tempFile = mapper.selectRaw(tempFileId);
|
||||||
tempFile.setBizType(bizType);
|
tempFile.setBizType(bizType);
|
||||||
|
|||||||
+3
-3
@@ -51,11 +51,11 @@ public class ClipboardServiceImplement implements ClipboardService {
|
|||||||
public void setContent(String id, String content) {
|
public void setContent(String id, String content) {
|
||||||
validateId(id);
|
validateId(id);
|
||||||
if (content == null) {
|
if (content == null) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("剪切板内容不能为空");
|
throw new TimiException(TimiCode.ARG_MISS, "剪切板内容不能为空");
|
||||||
}
|
}
|
||||||
byte[] contentBytes = content.getBytes(StandardCharsets.UTF_8);
|
byte[] contentBytes = content.getBytes(StandardCharsets.UTF_8);
|
||||||
if (MAX_CONTENT_SIZE < contentBytes.length) {
|
if (MAX_CONTENT_SIZE < contentBytes.length) {
|
||||||
throw new TimiException(TimiCode.ARG_BAD).msgKey("剪切板内容不能超过 10MB");
|
throw new TimiException(TimiCode.ARG_BAD, "剪切板内容不能超过 10MB");
|
||||||
}
|
}
|
||||||
redisClipboard.set(getKey(id), content, Time.D * 7);
|
redisClipboard.set(getKey(id), content, Time.D * 7);
|
||||||
notifySubscribers(id, content);
|
notifySubscribers(id, content);
|
||||||
@@ -78,7 +78,7 @@ public class ClipboardServiceImplement implements ClipboardService {
|
|||||||
|
|
||||||
private void validateId(String id) {
|
private void validateId(String id) {
|
||||||
if (TimiJava.isEmpty(id)) {
|
if (TimiJava.isEmpty(id)) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("id 不能为空");
|
throw new TimiException(TimiCode.ARG_MISS, "id 不能为空");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -39,7 +39,9 @@ public class MultilingualServiceImplement extends AbstractEntityService<Multilin
|
|||||||
Multilingual result = redisLanguage.get(getKey(id));
|
Multilingual result = redisLanguage.get(getKey(id));
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
result = super.get(id);
|
result = super.get(id);
|
||||||
redisLanguage.set(getKey(id), result, Time.D * 7);
|
if (result != null) {
|
||||||
|
redisLanguage.set(getKey(id), result, Time.D * 7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,6 +107,14 @@ public class GaoCustomerController {
|
|||||||
return service.getByCode(code);
|
return service.getByCode(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@AOPLog
|
||||||
|
@RequestRateLimit
|
||||||
|
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||||
|
@PostMapping("/detail/code/nullable")
|
||||||
|
public GaoCustomer nullableDetailByCode(@RequestParam String code) {
|
||||||
|
return service.getNullableByCode(code);
|
||||||
|
}
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.imyeyu.api.modules.gao.entity;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||||
|
import com.imyeyu.api.modules.user.entity.User;
|
||||||
import com.imyeyu.api.modules.user.bean.Gender;
|
import com.imyeyu.api.modules.user.bean.Gender;
|
||||||
import com.imyeyu.spring.annotation.table.Transient;
|
import com.imyeyu.spring.annotation.table.Transient;
|
||||||
import com.imyeyu.spring.entity.UUIDEntity;
|
import com.imyeyu.spring.entity.UUIDEntity;
|
||||||
@@ -59,12 +60,18 @@ public class GaoCustomer extends UUIDEntity {
|
|||||||
/// 介绍人客户 ID
|
/// 介绍人客户 ID
|
||||||
private String introducerCustomerId;
|
private String introducerCustomerId;
|
||||||
|
|
||||||
|
/// 录入用户 ID
|
||||||
|
private String creatorUserId;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
private Long lastSignInAt;
|
private Long lastSignInAt;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
private GaoCustomer introducerCustomer;
|
private GaoCustomer introducerCustomer;
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
private User creatorUser;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
private Long invitedCount;
|
private Long invitedCount;
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ public interface GaoCustomerMapper extends BaseMapper<GaoCustomer, String> {
|
|||||||
@Select("SELECT * FROM `gao_customer` WHERE `code` = #{code} AND `deleted_at` IS NULL LIMIT 1")
|
@Select("SELECT * FROM `gao_customer` WHERE `code` = #{code} AND `deleted_at` IS NULL LIMIT 1")
|
||||||
GaoCustomer selectByCode(@Param("code") String code);
|
GaoCustomer selectByCode(@Param("code") String code);
|
||||||
|
|
||||||
|
@Select("SELECT * FROM `gao_customer` WHERE `name` = #{name} AND `deleted_at` IS NULL LIMIT 1")
|
||||||
|
GaoCustomer selectByName(@Param("name") String name);
|
||||||
|
|
||||||
List<GaoCustomer> search(@Param("keyword") String keyword, @Param("introducerCustomerId") String introducerCustomerId);
|
List<GaoCustomer> search(@Param("keyword") String keyword, @Param("introducerCustomerId") String introducerCustomerId);
|
||||||
|
|
||||||
Long countSearch(@Param("keyword") String keyword, @Param("introducerCustomerId") String introducerCustomerId);
|
Long countSearch(@Param("keyword") String keyword, @Param("introducerCustomerId") String introducerCustomerId);
|
||||||
|
|||||||
+20
-3
@@ -7,6 +7,8 @@ import com.imyeyu.api.modules.common.vo.attach.BizUpdateReq;
|
|||||||
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
||||||
import com.imyeyu.api.modules.gao.mapper.GaoCustomerMapper;
|
import com.imyeyu.api.modules.gao.mapper.GaoCustomerMapper;
|
||||||
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
||||||
|
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||||
|
import com.imyeyu.api.modules.user.service.UserService;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStatView;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStatView;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerInviteUpdateReq;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerInviteUpdateReq;
|
||||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerSearchReq;
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerSearchReq;
|
||||||
@@ -54,6 +56,8 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|||||||
|
|
||||||
private final GaoCustomerMapper mapper;
|
private final GaoCustomerMapper mapper;
|
||||||
private final AttachmentService attachmentService;
|
private final AttachmentService attachmentService;
|
||||||
|
private final UserLoginService userLoginService;
|
||||||
|
private final UserService userService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BaseMapper<GaoCustomer, String> mapper() {
|
protected BaseMapper<GaoCustomer, String> mapper() {
|
||||||
@@ -63,6 +67,7 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|||||||
@Override
|
@Override
|
||||||
public void create(GaoCustomer entity) {
|
public void create(GaoCustomer entity) {
|
||||||
checkEntity(entity, false);
|
checkEntity(entity, false);
|
||||||
|
entity.setCreatorUserId(userLoginService.getRequireLoginUserId());
|
||||||
super.create(entity);
|
super.create(entity);
|
||||||
saveAttachment(entity.getId(), resolveAttachmentList(entity));
|
saveAttachment(entity.getId(), resolveAttachmentList(entity));
|
||||||
loadTransient(entity);
|
loadTransient(entity);
|
||||||
@@ -254,14 +259,23 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|||||||
|
|
||||||
private void checkEntity(GaoCustomer entity, boolean requireId) {
|
private void checkEntity(GaoCustomer entity, boolean requireId) {
|
||||||
TimiException.required(entity, "not found customer");
|
TimiException.required(entity, "not found customer");
|
||||||
|
GaoCustomer dbCustomer;
|
||||||
if (requireId) {
|
if (requireId) {
|
||||||
TimiException.required(entity.getId(), "not found customer.id");
|
TimiException.required(entity.getId(), "not found customer.id");
|
||||||
|
dbCustomer = super.get(entity.getId());
|
||||||
|
entity.setCreatorUserId(dbCustomer.getCreatorUserId());
|
||||||
}
|
}
|
||||||
TimiException.required(entity.getName(), "not found customer.name");
|
TimiException.required(entity.getName(), "not found customer.name");
|
||||||
|
entity.setName(entity.getName().trim());
|
||||||
|
TimiException.requiredTrue(!entity.getName().isEmpty(), "not found customer.name");
|
||||||
|
GaoCustomer duplicateCustomer = mapper.selectByName(entity.getName());
|
||||||
|
if (duplicateCustomer != null && !duplicateCustomer.getId().equals(entity.getId())) {
|
||||||
|
throw new TimiException(TimiCode.ARG_BAD, "客户姓名已存在");
|
||||||
|
}
|
||||||
if (TimiJava.isNotEmpty(entity.getCode())) {
|
if (TimiJava.isNotEmpty(entity.getCode())) {
|
||||||
GaoCustomer dbCustomer = mapper.selectByCode(entity.getCode());
|
duplicateCustomer = mapper.selectByCode(entity.getCode());
|
||||||
if (dbCustomer != null && !dbCustomer.getId().equals(entity.getId())) {
|
if (duplicateCustomer != null && !duplicateCustomer.getId().equals(entity.getId())) {
|
||||||
throw new TimiException(TimiCode.ARG_BAD).msgKey("客户编码已存在");
|
throw new TimiException(TimiCode.ARG_BAD, "客户编码已存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TimiJava.isNotEmpty(entity.getIntroducerCustomerId())) {
|
if (TimiJava.isNotEmpty(entity.getIntroducerCustomerId())) {
|
||||||
@@ -277,6 +291,9 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|||||||
if (TimiJava.isNotEmpty(customer.getIntroducerCustomerId())) {
|
if (TimiJava.isNotEmpty(customer.getIntroducerCustomerId())) {
|
||||||
customer.setIntroducerCustomer(super.get(customer.getIntroducerCustomerId()));
|
customer.setIntroducerCustomer(super.get(customer.getIntroducerCustomerId()));
|
||||||
}
|
}
|
||||||
|
if (TimiJava.isNotEmpty(customer.getCreatorUserId())) {
|
||||||
|
customer.setCreatorUser(userService.get(customer.getCreatorUserId()));
|
||||||
|
}
|
||||||
customer.setInvitedCount(mapper.countInvited(customer.getId()));
|
customer.setInvitedCount(mapper.countInvited(customer.getId()));
|
||||||
customer.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, customer.getId(), GaoCustomer.AttachType.PHOTO.name()));
|
customer.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, customer.getId(), GaoCustomer.AttachType.PHOTO.name()));
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -18,6 +18,7 @@ import com.imyeyu.spring.bean.Page;
|
|||||||
import com.imyeyu.spring.bean.PageResult;
|
import com.imyeyu.spring.bean.PageResult;
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import com.imyeyu.spring.service.AbstractEntityService;
|
import com.imyeyu.spring.service.AbstractEntityService;
|
||||||
|
import com.imyeyu.utils.Time;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -98,7 +99,7 @@ public class GaoUserServiceImplement extends AbstractEntityService<GaoUser, Stri
|
|||||||
TimiException.required(userMapper.select(entity.getUserId()), "not found user");
|
TimiException.required(userMapper.select(entity.getUserId()), "not found user");
|
||||||
GaoUser dbGaoUser = mapper.selectByUserId(entity.getUserId());
|
GaoUser dbGaoUser = mapper.selectByUserId(entity.getUserId());
|
||||||
if (dbGaoUser != null && !dbGaoUser.getId().equals(entity.getId())) {
|
if (dbGaoUser != null && !dbGaoUser.getId().equals(entity.getId())) {
|
||||||
throw new TimiException(TimiCode.ARG_BAD).msgKey("GAO 用户已存在");
|
throw new TimiException(TimiCode.ARG_BAD, "GAO 用户已存在");
|
||||||
}
|
}
|
||||||
if (entity.getEnabled() == null) {
|
if (entity.getEnabled() == null) {
|
||||||
entity.setEnabled(true);
|
entity.setEnabled(true);
|
||||||
@@ -112,6 +113,7 @@ public class GaoUserServiceImplement extends AbstractEntityService<GaoUser, Stri
|
|||||||
}
|
}
|
||||||
User user = entity.getUser();
|
User user = entity.getUser();
|
||||||
TimiException.required(user, "not found gao user.user");
|
TimiException.required(user, "not found gao user.user");
|
||||||
|
user.setPhoneNoVerifyAt(TimiJava.defaultIfNull(user.getPhoneNoVerifyAt(), Time.now()));
|
||||||
userService.create(user);
|
userService.create(user);
|
||||||
entity.setUserId(user.getId());
|
entity.setUserId(user.getId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class JournalAPIInterceptor implements HandlerInterceptor {
|
|||||||
requiredUploadPermission = handlerMethod.getMethodAnnotation(RequiredUploadPermission.class) != null;
|
requiredUploadPermission = handlerMethod.getMethodAnnotation(RequiredUploadPermission.class) != null;
|
||||||
}
|
}
|
||||||
if (!canAccess()) {
|
if (!canAccess()) {
|
||||||
throw new TimiException(TimiCode.PERMISSION_MISS).msgKey("invalid.key");
|
throw new TimiException(TimiCode.PERMISSION_MISS, "invalid.key");
|
||||||
}
|
}
|
||||||
return !requiredUploadPermission || canUploadKey();
|
return !requiredUploadPermission || canUploadKey();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class LyricController {
|
|||||||
// @PostMapping("/correct")
|
// @PostMapping("/correct")
|
||||||
// public long correctRequest(CaptchaData<LyricCorrectRequest> request) {
|
// public long correctRequest(CaptchaData<LyricCorrectRequest> request) {
|
||||||
// if (IOSize.MB * 120 < request.getData().getFile().getSize()) {
|
// if (IOSize.MB * 120 < request.getData().getFile().getSize()) {
|
||||||
// throw new TimiException(TimiCode.ARG_BAD).msgKey("lyric.correct_request.too_big");
|
// throw new TimiException(TimiCode.ARG_BAD, "lyric.correct_request.too_big");
|
||||||
// }
|
// }
|
||||||
// return correctService.correctRequest(request.getData());
|
// return correctService.correctRequest(request.getData());
|
||||||
// }
|
// }
|
||||||
|
|||||||
+1
-1
@@ -135,7 +135,7 @@ public class LyricServiceImplement extends AbstractEntityService<Lyric, String>
|
|||||||
return lyric;
|
return lyric;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("fetch lyric fail", e);
|
log.error("fetch lyric fail", e);
|
||||||
throw new TimiException(TimiCode.ERROR).msgKey("无法获取歌词");
|
throw new TimiException(TimiCode.ERROR, "无法获取歌词");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ abstract class AbstractMirror {
|
|||||||
onException(mirror, e);
|
onException(mirror, e);
|
||||||
|
|
||||||
if (e instanceof TimiException te) {
|
if (e instanceof TimiException te) {
|
||||||
log.warn("[%s] Fail: %s".formatted(mirror.getBean(), te.getMsg()));
|
log.warn("[%s] Fail: %s".formatted(mirror.getBean(), te.getMessage()));
|
||||||
} else {
|
} else {
|
||||||
log.error("[%s] Error".formatted(mirror.getBean()), e);
|
log.error("[%s] Error".formatted(mirror.getBean()), e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ public class TerminalPipe implements TimiJava {
|
|||||||
*/
|
*/
|
||||||
public void exec(CallbackArg<String> callback, String command) {
|
public void exec(CallbackArg<String> callback, String command) {
|
||||||
if (status == Status.DIED) {
|
if (status == Status.DIED) {
|
||||||
throw new TimiException(TimiCode.RESULT_BAD).msgKey("该会话已终止");
|
throw new TimiException(TimiCode.RESULT_BAD, "该会话已终止");
|
||||||
}
|
}
|
||||||
this.status = Status.RUNNING;
|
this.status = Status.RUNNING;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class FileController implements TimiJava, OS.FileSystem {
|
|||||||
public ServerFile object(HttpServletRequest req, HttpServletResponse resp) {
|
public ServerFile object(HttpServletRequest req, HttpServletResponse resp) {
|
||||||
String path = req.getServletPath().substring("/system/file/object".length());
|
String path = req.getServletPath().substring("/system/file/object".length());
|
||||||
if (TimiJava.isEmpty(path)) {
|
if (TimiJava.isEmpty(path)) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("TODO 缺少参数:object");
|
throw new TimiException(TimiCode.ARG_MISS, "TODO 缺少参数:object");
|
||||||
}
|
}
|
||||||
ServerFile file = new ServerFile(new File(path));
|
ServerFile file = new ServerFile(new File(path));
|
||||||
service.checkAccessPermission(file.getAbsolutePath());
|
service.checkAccessPermission(file.getAbsolutePath());
|
||||||
@@ -105,10 +105,10 @@ public class FileController implements TimiJava, OS.FileSystem {
|
|||||||
@PostMapping("/search")
|
@PostMapping("/search")
|
||||||
public List<ServerFile> search(@RequestBody Map<String, String> params) {
|
public List<ServerFile> search(@RequestBody Map<String, String> params) {
|
||||||
if (TimiJava.isEmpty(params.get("path"))) {
|
if (TimiJava.isEmpty(params.get("path"))) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少参数:path");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少参数:path");
|
||||||
}
|
}
|
||||||
if (TimiJava.isEmpty(params.get("keyword"))) {
|
if (TimiJava.isEmpty(params.get("keyword"))) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少参数:keyword");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少参数:keyword");
|
||||||
}
|
}
|
||||||
return service.doFilter(service.search(params.get("path"), params.get("keyword")));
|
return service.doFilter(service.search(params.get("path"), params.get("keyword")));
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ public class FileController implements TimiJava, OS.FileSystem {
|
|||||||
public boolean exist(HttpServletRequest req, HttpServletResponse resp) {
|
public boolean exist(HttpServletRequest req, HttpServletResponse resp) {
|
||||||
String path = req.getServletPath().substring("/system/file/exist".length());
|
String path = req.getServletPath().substring("/system/file/exist".length());
|
||||||
if (TimiJava.isEmpty(path)) {
|
if (TimiJava.isEmpty(path)) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少参数:path");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少参数:path");
|
||||||
}
|
}
|
||||||
return service.canAccess(path) && service.isExist(path);
|
return service.canAccess(path) && service.isExist(path);
|
||||||
}
|
}
|
||||||
@@ -237,10 +237,10 @@ public class FileController implements TimiJava, OS.FileSystem {
|
|||||||
@PostMapping("/mkdir")
|
@PostMapping("/mkdir")
|
||||||
public String mkdir(@RequestBody Map<String, String> params) {
|
public String mkdir(@RequestBody Map<String, String> params) {
|
||||||
if (TimiJava.isEmpty(params.get("path"))) {
|
if (TimiJava.isEmpty(params.get("path"))) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少参数:path");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少参数:path");
|
||||||
}
|
}
|
||||||
if (TimiJava.isEmpty(params.get("name"))) {
|
if (TimiJava.isEmpty(params.get("name"))) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少参数:name");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少参数:name");
|
||||||
}
|
}
|
||||||
return service.mkdir(params.get("path"), params.get("name")).getAbsolutePath();
|
return service.mkdir(params.get("path"), params.get("name")).getAbsolutePath();
|
||||||
}
|
}
|
||||||
@@ -256,10 +256,10 @@ public class FileController implements TimiJava, OS.FileSystem {
|
|||||||
@PostMapping("/rename")
|
@PostMapping("/rename")
|
||||||
public boolean rename(@RequestBody Map<String, String> params) {
|
public boolean rename(@RequestBody Map<String, String> params) {
|
||||||
if (TimiJava.isEmpty(params.get("from"))) {
|
if (TimiJava.isEmpty(params.get("from"))) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少参数:from");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少参数:from");
|
||||||
}
|
}
|
||||||
if (TimiJava.isEmpty(params.get("to"))) {
|
if (TimiJava.isEmpty(params.get("to"))) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少参数:to");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少参数:to");
|
||||||
}
|
}
|
||||||
return service.rename(params.get("from"), params.get("to"));
|
return service.rename(params.get("from"), params.get("to"));
|
||||||
}
|
}
|
||||||
@@ -275,10 +275,10 @@ public class FileController implements TimiJava, OS.FileSystem {
|
|||||||
@PostMapping("/zip")
|
@PostMapping("/zip")
|
||||||
public String zip(@RequestBody ListFileToRequest listFileToRequest) {
|
public String zip(@RequestBody ListFileToRequest listFileToRequest) {
|
||||||
if (TimiJava.isEmpty(listFileToRequest.getList())) {
|
if (TimiJava.isEmpty(listFileToRequest.getList())) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少参数:list[]");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少参数:list[]");
|
||||||
}
|
}
|
||||||
if (TimiJava.isEmpty(listFileToRequest.getTo())) {
|
if (TimiJava.isEmpty(listFileToRequest.getTo())) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少参数:to");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少参数:to");
|
||||||
}
|
}
|
||||||
// 异步任务
|
// 异步任务
|
||||||
FileZipAsyncTask task = new FileZipAsyncTask(listFileToRequest.getList(), listFileToRequest.getTo());
|
FileZipAsyncTask task = new FileZipAsyncTask(listFileToRequest.getList(), listFileToRequest.getTo());
|
||||||
@@ -298,14 +298,14 @@ public class FileController implements TimiJava, OS.FileSystem {
|
|||||||
public String unzip(@RequestBody Map<String, String> params) {
|
public String unzip(@RequestBody Map<String, String> params) {
|
||||||
String zipFilePath = params.get("zipFile");
|
String zipFilePath = params.get("zipFile");
|
||||||
if (TimiJava.isEmpty(zipFilePath)) {
|
if (TimiJava.isEmpty(zipFilePath)) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少参数:zipFile");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少参数:zipFile");
|
||||||
}
|
}
|
||||||
File zipFile = new File(zipFilePath);
|
File zipFile = new File(zipFilePath);
|
||||||
if (!zipFile.exists()) {
|
if (!zipFile.exists()) {
|
||||||
throw new TimiException(TimiCode.ARG_BAD).msgKey("文件不存在:" + zipFilePath);
|
throw new TimiException(TimiCode.ARG_BAD, "文件不存在:" + zipFilePath);
|
||||||
}
|
}
|
||||||
if (TimiJava.isEmpty(params.get("to"))) {
|
if (TimiJava.isEmpty(params.get("to"))) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少参数:to");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少参数:to");
|
||||||
}
|
}
|
||||||
// 异步任务
|
// 异步任务
|
||||||
FileUnZipAsyncTask task = new FileUnZipAsyncTask(zipFile, params.get("to"));
|
FileUnZipAsyncTask task = new FileUnZipAsyncTask(zipFile, params.get("to"));
|
||||||
@@ -341,14 +341,14 @@ public class FileController implements TimiJava, OS.FileSystem {
|
|||||||
// TODO 具名入参
|
// TODO 具名入参
|
||||||
String tarFilePath = params.get("tarFile");
|
String tarFilePath = params.get("tarFile");
|
||||||
if (TimiJava.isEmpty(tarFilePath)) {
|
if (TimiJava.isEmpty(tarFilePath)) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少参数:tarFile");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少参数:tarFile");
|
||||||
}
|
}
|
||||||
File tarFile = new File(tarFilePath);
|
File tarFile = new File(tarFilePath);
|
||||||
if (!tarFile.exists()) {
|
if (!tarFile.exists()) {
|
||||||
throw new TimiException(TimiCode.ARG_BAD).msgKey("文件不存在:" + tarFilePath);
|
throw new TimiException(TimiCode.ARG_BAD, "文件不存在:" + tarFilePath);
|
||||||
}
|
}
|
||||||
if (TimiJava.isEmpty(params.get("to"))) {
|
if (TimiJava.isEmpty(params.get("to"))) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少参数:to");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少参数:to");
|
||||||
}
|
}
|
||||||
FileUnTarAsyncTask task = new FileUnTarAsyncTask(tarFile, params.get("to"));
|
FileUnTarAsyncTask task = new FileUnTarAsyncTask(tarFile, params.get("to"));
|
||||||
asyncTaskService.addAsyncTask(task);
|
asyncTaskService.addAsyncTask(task);
|
||||||
|
|||||||
+3
-3
@@ -116,7 +116,7 @@ public abstract class AbstractAsyncTask extends AsyncTask {
|
|||||||
/** 开始 */
|
/** 开始 */
|
||||||
void start() {
|
void start() {
|
||||||
if (status != AsyncTask.Status.IDLE && status != AsyncTask.Status.PAUSE) {
|
if (status != AsyncTask.Status.IDLE && status != AsyncTask.Status.PAUSE) {
|
||||||
throw new TimiException(TimiCode.RESULT_BAD).msgKey("can not start this task");
|
throw new TimiException(TimiCode.RESULT_BAD, "can not start this task");
|
||||||
}
|
}
|
||||||
synchronized (pauseLocker) {
|
synchronized (pauseLocker) {
|
||||||
pauseLocker.notifyAll();
|
pauseLocker.notifyAll();
|
||||||
@@ -127,7 +127,7 @@ public abstract class AbstractAsyncTask extends AsyncTask {
|
|||||||
/** 暂停 */
|
/** 暂停 */
|
||||||
void pause() {
|
void pause() {
|
||||||
if (!canPause || (status != AsyncTask.Status.WAITING && status != AsyncTask.Status.RUNNING)) {
|
if (!canPause || (status != AsyncTask.Status.WAITING && status != AsyncTask.Status.RUNNING)) {
|
||||||
throw new TimiException(TimiCode.RESULT_BAD).msgKey("can not pause this task");
|
throw new TimiException(TimiCode.RESULT_BAD, "can not pause this task");
|
||||||
}
|
}
|
||||||
status = Status.PAUSE;
|
status = Status.PAUSE;
|
||||||
onPause();
|
onPause();
|
||||||
@@ -139,7 +139,7 @@ public abstract class AbstractAsyncTask extends AsyncTask {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!canInterrupt || (status != AsyncTask.Status.WAITING && status != AsyncTask.Status.RUNNING && status != AsyncTask.Status.PAUSE)) {
|
if (!canInterrupt || (status != AsyncTask.Status.WAITING && status != AsyncTask.Status.RUNNING && status != AsyncTask.Status.PAUSE)) {
|
||||||
throw new TimiException(TimiCode.RESULT_BAD).msgKey("can not interrupt this task");
|
throw new TimiException(TimiCode.RESULT_BAD, "can not interrupt this task");
|
||||||
}
|
}
|
||||||
if (status == AsyncTask.Status.PAUSE) {
|
if (status == AsyncTask.Status.PAUSE) {
|
||||||
status = AsyncTask.Status.INTERRUPT;
|
status = AsyncTask.Status.INTERRUPT;
|
||||||
|
|||||||
+1
-1
@@ -109,7 +109,7 @@ public class AsyncTaskServiceImplement implements AsyncTaskService {
|
|||||||
task.setMessage(task.logBuffer.toString());
|
task.setMessage(task.logBuffer.toString());
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
throw new TimiException(TimiCode.RESULT_NULL).msgKey("TODO not found task");
|
throw new TimiException(TimiCode.RESULT_NULL, "TODO not found task");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+10
-10
@@ -114,7 +114,7 @@ public class FileServiceImplement implements TimiJava, FileService {
|
|||||||
if (canAccess(path)) {
|
if (canAccess(path)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new TimiException(TimiCode.PERMISSION_ERROR).msgKey("TODO invalid permission");
|
throw new TimiException(TimiCode.PERMISSION_ERROR, "TODO invalid permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -139,7 +139,7 @@ public class FileServiceImplement implements TimiJava, FileService {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
throw new TimiException(TimiCode.RESULT_NULL).msgKey("文件或路径不存在");
|
throw new TimiException(TimiCode.RESULT_NULL, "文件或路径不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ public class FileServiceImplement implements TimiJava, FileService {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
throw new TimiException(TimiCode.RESULT_NULL).msgKey("文件或路径不存在");
|
throw new TimiException(TimiCode.RESULT_NULL, "文件或路径不存在");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +186,7 @@ public class FileServiceImplement implements TimiJava, FileService {
|
|||||||
try {
|
try {
|
||||||
return IO.dir(uri);
|
return IO.dir(uri);
|
||||||
} catch (NoPermissionException e) {
|
} catch (NoPermissionException e) {
|
||||||
throw new TimiException(TimiCode.PERMISSION_ERROR).msgKey("权限错误");
|
throw new TimiException(TimiCode.PERMISSION_ERROR, "权限错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ public class FileServiceImplement implements TimiJava, FileService {
|
|||||||
try {
|
try {
|
||||||
return IO.getInputStream(getPath(path));
|
return IO.getInputStream(getPath(path));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
throw new TimiException(TimiCode.RESULT_NULL).msgKey("找不到文件");
|
throw new TimiException(TimiCode.RESULT_NULL, "找不到文件");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,25 +213,25 @@ public class FileServiceImplement implements TimiJava, FileService {
|
|||||||
public void upload(TransferFile file) {
|
public void upload(TransferFile file) {
|
||||||
String path = getPath(Decoder.url(file.getPath()));
|
String path = getPath(Decoder.url(file.getPath()));
|
||||||
if (file.getName() == null) {
|
if (file.getName() == null) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少参数:name");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少参数:name");
|
||||||
}
|
}
|
||||||
String fileName = Decoder.url(file.getName());
|
String fileName = Decoder.url(file.getName());
|
||||||
if (!OS.isValidFileName(path)) {
|
if (!OS.isValidFileName(path)) {
|
||||||
throw new TimiException(TimiCode.ARG_BAD).msgKey("路径名称不合法:" + path);
|
throw new TimiException(TimiCode.ARG_BAD, "路径名称不合法:" + path);
|
||||||
}
|
}
|
||||||
if (!OS.isValidFileName(fileName)) {
|
if (!OS.isValidFileName(fileName)) {
|
||||||
throw new TimiException(TimiCode.ARG_BAD).msgKey("文件名称不合法:" + fileName);
|
throw new TimiException(TimiCode.ARG_BAD, "文件名称不合法:" + fileName);
|
||||||
}
|
}
|
||||||
if (file.getLength() == file.getFile().getSize()) {
|
if (file.getLength() == file.getFile().getSize()) {
|
||||||
try {
|
try {
|
||||||
toFile(new File(path + fileName), file.getFile().getInputStream());
|
toFile(new File(path + fileName), file.getFile().getInputStream());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("get request input stream error", e);
|
log.error("get request input stream error", e);
|
||||||
throw new TimiException(TimiCode.ARG_BAD).msgKey("获取文件输入流失败");
|
throw new TimiException(TimiCode.ARG_BAD, "获取文件输入流失败");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.error("request submit request size: {}, receive request size: {}", file.getLength(), file.getFile().getSize());
|
log.error("request submit request size: {}, receive request size: {}", file.getLength(), file.getFile().getSize());
|
||||||
throw new TimiException(TimiCode.ERROR).msgKey("不完整上传文件,已忽略");
|
throw new TimiException(TimiCode.ERROR, "不完整上传文件,已忽略");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ public class FileMoveAsyncTask extends AbstractAsyncTask {
|
|||||||
File toFile = new File(IO.fitPath(to) + item.getValue());
|
File toFile = new File(IO.fitPath(to) + item.getValue());
|
||||||
IO.dir(toFile.getParent());
|
IO.dir(toFile.getParent());
|
||||||
if (!item.getKey().renameTo(toFile)) {
|
if (!item.getKey().renameTo(toFile)) {
|
||||||
throw new TimiException(TimiCode.ERROR).msgKey("移动失败:" + item.getKey().getAbsolutePath() + " -> " + toFile.getAbsolutePath());
|
throw new TimiException(TimiCode.ERROR, "移动失败:" + item.getKey().getAbsolutePath() + " -> " + toFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,10 +67,10 @@ public class DockerEngineClient {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
log.error("docker engine request interrupted: {}", requestPath, e);
|
log.error("docker engine request interrupted: {}", requestPath, e);
|
||||||
throw new TimiException(TimiCode.ERROR).msgKey("TODO docker engine request interrupted");
|
throw new TimiException(TimiCode.ERROR, "TODO docker engine request interrupted");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("docker engine request error: {}", requestPath, e);
|
log.error("docker engine request error: {}", requestPath, e);
|
||||||
throw new TimiException(TimiCode.ERROR).msgKey("TODO docker engine request error");
|
throw new TimiException(TimiCode.ERROR, "TODO docker engine request error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class SystemAPIInterceptor implements HandlerInterceptor {
|
|||||||
// TimiSpring.setRequestAttr(HIGH_AUTHORITY, keyMap.get(key));
|
// TimiSpring.setRequestAttr(HIGH_AUTHORITY, keyMap.get(key));
|
||||||
// return true;
|
// return true;
|
||||||
// }
|
// }
|
||||||
// throw new TimiException(TimiCode.PERMISSION_ERROR).msgKey("TODO invalid key");
|
// throw new TimiException(TimiCode.PERMISSION_ERROR, "TODO invalid key");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,14 +43,14 @@ public class UpsStatusClient {
|
|||||||
|
|
||||||
public JsonNode getStatusJson() {
|
public JsonNode getStatusJson() {
|
||||||
if (statusUrl == null || statusUrl.isBlank()) {
|
if (statusUrl == null || statusUrl.isBlank()) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("缺少配置:ups.status-url");
|
throw new TimiException(TimiCode.ARG_MISS, "缺少配置:ups.status-url");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
String response = CommonRequest.post(statusUrl).bodyEntity(ArgMap.of("portName", "USBusbdev3").toEntity()).asString();
|
String response = CommonRequest.post(statusUrl).bodyEntity(ArgMap.of("portName", "USBusbdev3").toEntity()).asString();
|
||||||
return jackson.readTree(response);
|
return jackson.readTree(response);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("request ups status error: {}", statusUrl, e);
|
log.error("request ups status error: {}", statusUrl, e);
|
||||||
throw new TimiException(TimiCode.ERROR).msgKey("UPS 状态请求失败");
|
throw new TimiException(TimiCode.ERROR, "UPS 状态请求失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.imyeyu.api.annotation.RequireCorePermission;
|
|||||||
import com.imyeyu.api.annotation.RequireCoreRole;
|
import com.imyeyu.api.annotation.RequireCoreRole;
|
||||||
import com.imyeyu.api.bean.CorePermissionCode;
|
import com.imyeyu.api.bean.CorePermissionCode;
|
||||||
import com.imyeyu.api.bean.CoreRoleCode;
|
import com.imyeyu.api.bean.CoreRoleCode;
|
||||||
|
import com.imyeyu.api.bean.RoleMatchMode;
|
||||||
import com.imyeyu.api.modules.user.entity.Permission;
|
import com.imyeyu.api.modules.user.entity.Permission;
|
||||||
import com.imyeyu.api.modules.user.service.PermissionService;
|
import com.imyeyu.api.modules.user.service.PermissionService;
|
||||||
import com.imyeyu.api.modules.user.vo.permission.BatchCreateReq;
|
import com.imyeyu.api.modules.user.vo.permission.BatchCreateReq;
|
||||||
@@ -32,7 +33,7 @@ public class PermissionController {
|
|||||||
|
|
||||||
private final PermissionService service;
|
private final PermissionService service;
|
||||||
|
|
||||||
@RequireCoreRole(CoreRoleCode.ADMIN)
|
@RequireCoreRole(value = {CoreRoleCode.ADMIN, CoreRoleCode.USER_ROLE_ADMIN}, mode = RoleMatchMode.ANY)
|
||||||
@RequireCorePermission(CorePermissionCode.PERMISSION_READ)
|
@RequireCorePermission(CorePermissionCode.PERMISSION_READ)
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public PageResult<Permission> list(@RequestBody Page<Permission> page) {
|
public PageResult<Permission> list(@RequestBody Page<Permission> page) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.imyeyu.api.annotation.RequireCoreRole;
|
|||||||
import com.imyeyu.api.bean.CorePermissionCode;
|
import com.imyeyu.api.bean.CorePermissionCode;
|
||||||
import com.imyeyu.api.bean.CoreRoleCode;
|
import com.imyeyu.api.bean.CoreRoleCode;
|
||||||
import com.imyeyu.api.bean.ModuleCode;
|
import com.imyeyu.api.bean.ModuleCode;
|
||||||
|
import com.imyeyu.api.bean.RoleMatchMode;
|
||||||
import com.imyeyu.api.modules.user.entity.Permission;
|
import com.imyeyu.api.modules.user.entity.Permission;
|
||||||
import com.imyeyu.api.modules.user.entity.Role;
|
import com.imyeyu.api.modules.user.entity.Role;
|
||||||
import com.imyeyu.api.modules.user.service.PermissionService;
|
import com.imyeyu.api.modules.user.service.PermissionService;
|
||||||
@@ -38,7 +39,7 @@ public class RoleController {
|
|||||||
private final RoleService service;
|
private final RoleService service;
|
||||||
private final PermissionService permissionService;
|
private final PermissionService permissionService;
|
||||||
|
|
||||||
@RequireCoreRole(CoreRoleCode.ADMIN)
|
@RequireCoreRole(value = {CoreRoleCode.ADMIN, CoreRoleCode.USER_ROLE_ADMIN}, mode = RoleMatchMode.ANY)
|
||||||
@RequireCorePermission(CorePermissionCode.ROLE_READ)
|
@RequireCorePermission(CorePermissionCode.ROLE_READ)
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public PageResult<Role> list(@RequestBody Page<Role> page) {
|
public PageResult<Role> list(@RequestBody Page<Role> page) {
|
||||||
@@ -49,7 +50,7 @@ public class RoleController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequireCoreRole(CoreRoleCode.ADMIN)
|
@RequireCoreRole(value = {CoreRoleCode.ADMIN, CoreRoleCode.USER_ROLE_ADMIN}, mode = RoleMatchMode.ANY)
|
||||||
@RequireCorePermission(CorePermissionCode.ROLE_READ)
|
@RequireCorePermission(CorePermissionCode.ROLE_READ)
|
||||||
@PostMapping("/detail")
|
@PostMapping("/detail")
|
||||||
public Role detail(@RequestParam String id) {
|
public Role detail(@RequestParam String id) {
|
||||||
@@ -82,7 +83,7 @@ public class RoleController {
|
|||||||
service.delete(id);
|
service.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequireCoreRole(CoreRoleCode.ADMIN)
|
@RequireCoreRole(value = {CoreRoleCode.ADMIN, CoreRoleCode.USER_ROLE_ADMIN}, mode = RoleMatchMode.ANY)
|
||||||
@RequireCorePermission(CorePermissionCode.USER_ROLE_READ)
|
@RequireCorePermission(CorePermissionCode.USER_ROLE_READ)
|
||||||
@PostMapping("/authorized/list")
|
@PostMapping("/authorized/list")
|
||||||
public List<Role> listUserRole(@RequestParam String userId, @RequestParam(required = false) ModuleCode moduleCode) {
|
public List<Role> listUserRole(@RequestParam String userId, @RequestParam(required = false) ModuleCode moduleCode) {
|
||||||
@@ -93,14 +94,14 @@ public class RoleController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@RequireCoreRole(CoreRoleCode.ADMIN)
|
@RequireCoreRole(value = {CoreRoleCode.ADMIN, CoreRoleCode.USER_ROLE_ADMIN}, mode = RoleMatchMode.ANY)
|
||||||
@RequireCorePermission(value = {CorePermissionCode.USER_ROLE_CREATE, CorePermissionCode.USER_ROLE_DELETE})
|
@RequireCorePermission(value = {CorePermissionCode.USER_ROLE_CREATE, CorePermissionCode.USER_ROLE_DELETE})
|
||||||
@PostMapping("/authorized/create")
|
@PostMapping("/authorized/create")
|
||||||
public void authorizeUserRole(@RequestBody UserRoleAuthorizeReq req) {
|
public void authorizeUserRole(@RequestBody UserRoleAuthorizeReq req) {
|
||||||
service.authorizeUserRole(req);
|
service.authorizeUserRole(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequireCoreRole(CoreRoleCode.ADMIN)
|
@RequireCoreRole(value = {CoreRoleCode.ADMIN, CoreRoleCode.USER_ROLE_ADMIN}, mode = RoleMatchMode.ANY)
|
||||||
@RequireCorePermission(CorePermissionCode.USER_ROLE_READ)
|
@RequireCorePermission(CorePermissionCode.USER_ROLE_READ)
|
||||||
@PostMapping("/authorized/permission")
|
@PostMapping("/authorized/permission")
|
||||||
public List<Permission> listAuthorizedPermission(@RequestParam String userId) {
|
public List<Permission> listAuthorizedPermission(@RequestParam String userId) {
|
||||||
|
|||||||
+2
-2
@@ -53,7 +53,7 @@ public class PermissionCheckerImplement implements PermissionChecker {
|
|||||||
public void checkAll(ModuleCode moduleCode, String... permissionCodeList) {
|
public void checkAll(ModuleCode moduleCode, String... permissionCodeList) {
|
||||||
if (!hasAll(moduleCode, permissionCodeList)) {
|
if (!hasAll(moduleCode, permissionCodeList)) {
|
||||||
String codeList = buildPermissionKeys(moduleCode, permissionCodeList).toString();
|
String codeList = buildPermissionKeys(moduleCode, permissionCodeList).toString();
|
||||||
throw new TimiException(TimiCode.PERMISSION_ERROR).msgKey("权限不足:%s".formatted(codeList));
|
throw new TimiException(TimiCode.PERMISSION_ERROR, "权限不足:%s".formatted(codeList));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ public class PermissionCheckerImplement implements PermissionChecker {
|
|||||||
public void checkAny(ModuleCode moduleCode, String... permissionCodeList) {
|
public void checkAny(ModuleCode moduleCode, String... permissionCodeList) {
|
||||||
if (!hasAny(moduleCode, permissionCodeList)) {
|
if (!hasAny(moduleCode, permissionCodeList)) {
|
||||||
String codeList = buildPermissionKeys(moduleCode, permissionCodeList).toString();
|
String codeList = buildPermissionKeys(moduleCode, permissionCodeList).toString();
|
||||||
throw new TimiException(TimiCode.PERMISSION_ERROR).msgKey("权限不足:%s".formatted(codeList));
|
throw new TimiException(TimiCode.PERMISSION_ERROR, "权限不足:%s".formatted(codeList));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -8,8 +8,8 @@ import com.imyeyu.api.modules.user.mapper.PermissionMapper;
|
|||||||
import com.imyeyu.api.modules.user.mapper.RolePermissionMapper;
|
import com.imyeyu.api.modules.user.mapper.RolePermissionMapper;
|
||||||
import com.imyeyu.api.modules.user.service.PermissionService;
|
import com.imyeyu.api.modules.user.service.PermissionService;
|
||||||
import com.imyeyu.api.modules.user.vo.permission.BatchCreateReq;
|
import com.imyeyu.api.modules.user.vo.permission.BatchCreateReq;
|
||||||
import com.imyeyu.api.util.RedisMultilingual;
|
|
||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
|
import com.imyeyu.lang.message.MessageResolver;
|
||||||
import com.imyeyu.spring.TimiSpring;
|
import com.imyeyu.spring.TimiSpring;
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
import com.imyeyu.spring.mapper.BaseMapper;
|
||||||
import com.imyeyu.spring.service.AbstractEntityService;
|
import com.imyeyu.spring.service.AbstractEntityService;
|
||||||
@@ -35,7 +35,7 @@ public class PermissionServiceImplement extends AbstractEntityService<Permission
|
|||||||
|
|
||||||
private final MultilingualMapper multilingualMapper;
|
private final MultilingualMapper multilingualMapper;
|
||||||
private final MultilingualService multilingualService;
|
private final MultilingualService multilingualService;
|
||||||
private final RedisMultilingual multilingual;
|
private final MessageResolver messageResolver;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BaseMapper<Permission, String> mapper() {
|
protected BaseMapper<Permission, String> mapper() {
|
||||||
@@ -61,7 +61,7 @@ public class PermissionServiceImplement extends AbstractEntityService<Permission
|
|||||||
permission.setId(UUID.randomUUID().toString());
|
permission.setId(UUID.randomUUID().toString());
|
||||||
permission.setModuleCode(req.getModuleCode());
|
permission.setModuleCode(req.getModuleCode());
|
||||||
permission.setCode(req.getPrefixCode() + "_" + type.name());
|
permission.setCode(req.getPrefixCode() + "_" + type.name());
|
||||||
permission.setName(req.getPrefixName() + multilingual.map(TimiSpring.getLanguage()).text(type.name().toLowerCase()));
|
permission.setName(req.getPrefixName() + messageResolver.resolve(type.name().toLowerCase(), null, TimiSpring.getLanguage()));
|
||||||
permission.setCreatedAt(Time.now());
|
permission.setCreatedAt(Time.now());
|
||||||
permissionList.add(permission);
|
permissionList.add(permission);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -47,14 +47,14 @@ public class RoleCheckerImplement implements RoleChecker {
|
|||||||
@Override
|
@Override
|
||||||
public void checkAll(ModuleCode moduleCode, String... roleCodeList) {
|
public void checkAll(ModuleCode moduleCode, String... roleCodeList) {
|
||||||
if (!hasAll(moduleCode, roleCodeList)) {
|
if (!hasAll(moduleCode, roleCodeList)) {
|
||||||
throw new TimiException(TimiCode.PERMISSION_ERROR).msgKey("require role: %s".formatted(buildRoleKeys(moduleCode, roleCodeList)));
|
throw new TimiException(TimiCode.PERMISSION_ERROR, "require role: %s".formatted(buildRoleKeys(moduleCode, roleCodeList)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkAny(ModuleCode moduleCode, String... roleCodeList) {
|
public void checkAny(ModuleCode moduleCode, String... roleCodeList) {
|
||||||
if (!hasAny(moduleCode, roleCodeList)) {
|
if (!hasAny(moduleCode, roleCodeList)) {
|
||||||
throw new TimiException(TimiCode.PERMISSION_ERROR).msgKey("require role: %s".formatted(buildRoleKeys(moduleCode, roleCodeList)));
|
throw new TimiException(TimiCode.PERMISSION_ERROR, "require role: %s".formatted(buildRoleKeys(moduleCode, roleCodeList)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -159,7 +159,7 @@ public class RoleServiceImplement extends AbstractEntityService<Role, String> im
|
|||||||
TimiException.required(req, "not found req");
|
TimiException.required(req, "not found req");
|
||||||
TimiException.required(req.getUserId(), "not found req.userId");
|
TimiException.required(req.getUserId(), "not found req.userId");
|
||||||
if (req.getModuleCode() == null) {
|
if (req.getModuleCode() == null) {
|
||||||
throw new TimiException(TimiCode.ARG_MISS).msgKey("moduleCode");
|
throw new TimiException(TimiCode.ARG_MISS, "moduleCode");
|
||||||
}
|
}
|
||||||
List<UserRole> bindingList = userRoleService.listByUserId(req.getUserId());
|
List<UserRole> bindingList = userRoleService.listByUserId(req.getUserId());
|
||||||
List<String> bindingRoleIdList = bindingList.stream().map(UserRole::getRoleId).toList();
|
List<String> bindingRoleIdList = bindingList.stream().map(UserRole::getRoleId).toList();
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ public class UserServiceImplement extends AbstractEntityService<User, String> im
|
|||||||
dbUser.setPassword(Digest.argon2id(user.getPassword()));
|
dbUser.setPassword(Digest.argon2id(user.getPassword()));
|
||||||
dbUser.setEmail(user.getEmail());
|
dbUser.setEmail(user.getEmail());
|
||||||
dbUser.setPhoneNo(user.getPhoneNo());
|
dbUser.setPhoneNo(user.getPhoneNo());
|
||||||
|
dbUser.setPhoneNoVerifyAt(user.getPhoneNoVerifyAt());
|
||||||
dbUser.setExp(TimiJava.defaultIfNull(user.getExp(), 0));
|
dbUser.setExp(TimiJava.defaultIfNull(user.getExp(), 0));
|
||||||
super.create(dbUser);
|
super.create(dbUser);
|
||||||
user.setId(dbUser.getId());
|
user.setId(dbUser.getId());
|
||||||
|
|||||||
@@ -200,10 +200,10 @@ public class CaptchaManager {
|
|||||||
String cacheKey = CACHE_KEY.formatted(uniqueId);
|
String cacheKey = CACHE_KEY.formatted(uniqueId);
|
||||||
String cacheValue = redisCaptcha.get(cacheKey);
|
String cacheValue = redisCaptcha.get(cacheKey);
|
||||||
if (TimiJava.isEmpty(cacheValue)) {
|
if (TimiJava.isEmpty(cacheValue)) {
|
||||||
throw new TimiException(TimiCode.ARG_EXPIRED).msgKey("captcha.expire");
|
throw new TimiException(TimiCode.ARG_EXPIRED, "captcha.expire");
|
||||||
}
|
}
|
||||||
if (!value.trim().equalsIgnoreCase(cacheValue)) {
|
if (!value.trim().equalsIgnoreCase(cacheValue)) {
|
||||||
throw new TimiException(TimiCode.RESULT_BAD).msgKey("captcha.error");
|
throw new TimiException(TimiCode.RESULT_BAD, "captcha.error");
|
||||||
}
|
}
|
||||||
// 清除缓存
|
// 清除缓存
|
||||||
redisCaptcha.destroy(cacheKey);
|
redisCaptcha.destroy(cacheKey);
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package com.imyeyu.api.util;
|
package com.imyeyu.api.util;
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.service.SettingService;
|
import com.imyeyu.api.modules.common.service.SettingService;
|
||||||
import com.imyeyu.lang.mapper.AbstractLanguageMapper;
|
|
||||||
import com.imyeyu.spring.TimiSpring;
|
|
||||||
import com.imyeyu.spring.util.GlobalReturnHandler;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.eclipse.jgit.api.ArchiveCommand;
|
import org.eclipse.jgit.api.ArchiveCommand;
|
||||||
@@ -42,20 +39,11 @@ public class InitApplication implements ApplicationRunner {
|
|||||||
private String devLang;
|
private String devLang;
|
||||||
|
|
||||||
private final SettingService settingService;
|
private final SettingService settingService;
|
||||||
private final RedisMultilingual redisMultilingual;
|
|
||||||
private final GlobalReturnHandler globalReturnHandler;
|
|
||||||
|
|
||||||
private void initGitCommand() {
|
private void initGitCommand() {
|
||||||
ArchiveCommand.registerFormat("tar.gz", new TarFormat());
|
ArchiveCommand.registerFormat("tar.gz", new TarFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initMultilingual() {
|
|
||||||
globalReturnHandler.setMultilingualHeader(mapping -> {
|
|
||||||
AbstractLanguageMapper map = redisMultilingual.map(TimiSpring.getLanguage());
|
|
||||||
return map.textArgs(mapping.getMsgKey(), mapping.getMsgArgs());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
Method[] methods = getClass().getDeclaredMethods();
|
Method[] methods = getClass().getDeclaredMethods();
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
package com.imyeyu.api.util;
|
|
||||||
|
|
||||||
import com.imyeyu.api.TimiServerAPI;
|
|
||||||
import com.imyeyu.api.modules.common.service.MultilingualService;
|
|
||||||
import com.imyeyu.java.bean.Language;
|
|
||||||
import com.imyeyu.lang.mapper.AbstractLanguageMapper;
|
|
||||||
import com.imyeyu.utils.StringInterpolator;
|
|
||||||
import org.jcodec.api.NotSupportedException;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 夜雨
|
|
||||||
* @version 2024-04-03 11:01
|
|
||||||
*/
|
|
||||||
public class RedisLanguage extends AbstractLanguageMapper {
|
|
||||||
|
|
||||||
private static final StringInterpolator INTERPOLATOR = new StringInterpolator(StringInterpolator.SIMPLE_OBJ);
|
|
||||||
|
|
||||||
public RedisLanguage(Language.Enum language) {
|
|
||||||
super(language);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void add(String id, String value) {
|
|
||||||
throw new NotSupportedException("not supported to add value, MultilingualService will auto cache when not found value");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean has(String id) {
|
|
||||||
return text(id).equals(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String text(String id) {
|
|
||||||
return TimiServerAPI.applicationContext.getBean(MultilingualService.class).get(id).getValue(language);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String textArgs(String id, Map<String, Object> args) {
|
|
||||||
return INTERPOLATOR.inject(text(id), args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.imyeyu.api.util;
|
||||||
|
|
||||||
|
import com.imyeyu.api.modules.common.entity.Multilingual;
|
||||||
|
import com.imyeyu.api.modules.common.service.MultilingualService;
|
||||||
|
import com.imyeyu.java.TimiJava;
|
||||||
|
import com.imyeyu.java.bean.Language;
|
||||||
|
import com.imyeyu.lang.message.MessageResolver;
|
||||||
|
import com.imyeyu.utils.StringInterpolator;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redis 消息解析器
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-08-01 00:00
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RedisMessageResolver implements MessageResolver {
|
||||||
|
|
||||||
|
private static final StringInterpolator INTERPOLATOR = new StringInterpolator(StringInterpolator.SIMPLE_OBJ);
|
||||||
|
|
||||||
|
private final MultilingualService multilingualService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String resolve(String messageCode, Map<String, Object> messageArgs, Language.Enum language) {
|
||||||
|
if (TimiJava.isEmpty(messageCode)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
Language.Enum actualLanguage = language == null ? Language.Enum.zh_CN : language;
|
||||||
|
Multilingual multilingual = multilingualService.get(messageCode);
|
||||||
|
if (multilingual == null) {
|
||||||
|
return INTERPOLATOR.inject(messageCode, messageArgs);
|
||||||
|
}
|
||||||
|
String template = multilingual.getValue(actualLanguage);
|
||||||
|
if (TimiJava.isEmpty(template)) {
|
||||||
|
return INTERPOLATOR.inject(messageCode, messageArgs);
|
||||||
|
}
|
||||||
|
return INTERPOLATOR.inject(template, messageArgs);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.imyeyu.api.util;
|
|
||||||
|
|
||||||
import com.imyeyu.java.bean.Language;
|
|
||||||
import com.imyeyu.lang.multi.Multilingual;
|
|
||||||
import jakarta.annotation.PostConstruct;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 夜雨
|
|
||||||
* @version 2024-04-03 11:15
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class RedisMultilingual extends Multilingual {
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
private void postConstruct() {
|
|
||||||
Language.Enum[] languages = Language.Enum.values();
|
|
||||||
for (Language.Enum language : languages) {
|
|
||||||
add(language, new RedisLanguage(language));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
ALTER TABLE `gao_customer`
|
||||||
|
DROP INDEX `uk_gao_customer_code`,
|
||||||
|
ADD COLUMN `active_code` VARCHAR(64) GENERATED ALWAYS AS (
|
||||||
|
CASE WHEN `deleted_at` IS NULL THEN `code` ELSE NULL END
|
||||||
|
) STORED COMMENT '未删除客户编码' INVISIBLE,
|
||||||
|
ADD UNIQUE KEY `uk_gao_customer_active_code` (`active_code`);
|
||||||
|
|
||||||
|
ALTER TABLE `permission`
|
||||||
|
DROP INDEX `uk_module_code_code`,
|
||||||
|
ADD COLUMN `active_code` VARCHAR(50) GENERATED ALWAYS AS (
|
||||||
|
CASE WHEN `deleted_at` IS NULL THEN `code` ELSE NULL END
|
||||||
|
) STORED COMMENT '未删除权限代码' INVISIBLE,
|
||||||
|
ADD UNIQUE KEY `uk_permission_module_active_code` (`module_code`, `active_code`);
|
||||||
|
|
||||||
|
ALTER TABLE `role`
|
||||||
|
DROP INDEX `uk_module_code_code`,
|
||||||
|
ADD COLUMN `active_code` VARCHAR(50) GENERATED ALWAYS AS (
|
||||||
|
CASE WHEN `deleted_at` IS NULL THEN `code` ELSE NULL END
|
||||||
|
) STORED COMMENT '未删除角色代码' INVISIBLE,
|
||||||
|
ADD UNIQUE KEY `uk_role_module_active_code` (`module_code`, `active_code`);
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
ALTER TABLE `gao_customer`
|
||||||
|
ADD COLUMN `active_name` VARCHAR(64) GENERATED ALWAYS AS (
|
||||||
|
CASE WHEN `deleted_at` IS NULL THEN NULLIF(TRIM(`name`), '') ELSE NULL END
|
||||||
|
) STORED COMMENT '未删除客户姓名' INVISIBLE,
|
||||||
|
ADD UNIQUE KEY `uk_gao_customer_active_name` (`active_name`);
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
ALTER TABLE `gao_customer`
|
||||||
|
ADD COLUMN `creator_user_id` VARCHAR(36) NULL COMMENT '录入用户 ID' AFTER `introducer_customer_id`,
|
||||||
|
ADD KEY `idx_gao_customer_creator_user_id` (`creator_user_id`);
|
||||||
Reference in New Issue
Block a user