Compare commits
37
Commits
8db6f962c9
...
v1.0.17
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecd2fa1c33 | ||
|
|
dcc75efa87 | ||
|
|
a9465299a9 | ||
|
|
42152c7b79 | ||
|
|
1a896ef457 | ||
|
|
9d8990a028 | ||
|
|
17d88fc338 | ||
|
|
bb40f347a3 | ||
|
|
e3236d262d | ||
|
|
3d4e32e5da | ||
|
|
c8e2e16ba5 | ||
|
|
bdc4cbb240 | ||
|
|
99b44faf09 | ||
|
|
7f6cebd4e2 | ||
|
|
75fd4bed18 | ||
|
|
b3e3cbf84b | ||
|
|
0aee11d824 | ||
|
|
fcf358a768 | ||
|
|
619369104c | ||
|
|
4f1408b9d0 | ||
|
|
029eea70cc | ||
|
|
22b1e65385 | ||
|
|
2170c48763 | ||
|
|
c2d1c48aae | ||
|
|
e14958c643 | ||
|
|
da288338cd | ||
|
|
ea430f2468 | ||
|
|
f76f79744a | ||
|
|
19daaff907 | ||
|
|
db94d8f932 | ||
|
|
53618fe362 | ||
|
|
523edffc4e | ||
|
|
c7ddb1a8b0 | ||
|
|
45c9fc814a | ||
|
|
407dc13ac4 | ||
|
|
0c06bf16c2 | ||
|
|
1db39e77d3 |
@@ -46,6 +46,11 @@ jobs:
|
||||
<username>${{ vars.TIMI_NEXUS_USERNAME }}</username>
|
||||
<password>${{ vars.TIMI_NEXUS_PASSWORD }}</password>
|
||||
</server>
|
||||
<server>
|
||||
<id>e2ins_nexus</id>
|
||||
<username>${{ vars.E2INS_NEXUS_USERNAME }}</username>
|
||||
<password>${{ vars.E2INS_NEXUS_PASSWORD }}</password>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
||||
EOF
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<groupId>com.imyeyu.timiserverapi</groupId>
|
||||
<artifactId>TimiServerAPI</artifactId>
|
||||
<version>1.0.14</version>
|
||||
<version>1.0.17</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>TimiServerAPI</name>
|
||||
<description>imyeyu.com API</description>
|
||||
@@ -167,6 +167,16 @@
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>e2ins_nexus</id>
|
||||
<url>https://nexus.e2ins.com/repository/maven-public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@@ -225,6 +235,11 @@
|
||||
<groupId>org.flywaydb</groupId>
|
||||
<artifactId>flyway-mysql</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.e2ins.ms.notify</groupId>
|
||||
<artifactId>e2ins-msg-notify-service-sdk</artifactId>
|
||||
<version>0.0.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-freemarker</artifactId>
|
||||
|
||||
@@ -50,6 +50,11 @@ public enum CorePermissionCode implements BuiltinPermissionCode {
|
||||
USER_UPDATE("USER:UPDATE", "用户修改", false, true),
|
||||
USER_DELETE("USER:DELETE", "用户删除", false, true),
|
||||
|
||||
FEEDBACK_CREATE("FEEDBACK:CREATE", "反馈创建", false, true),
|
||||
FEEDBACK_READ("FEEDBACK:READ", "反馈读取", false, true),
|
||||
FEEDBACK_UPDATE("FEEDBACK:UPDATE", "反馈修改", false, true),
|
||||
FEEDBACK_DELETE("FEEDBACK:DELETE", "反馈删除", false, true),
|
||||
|
||||
USER_ROLE_CREATE("USER_ROLE:CREATE", "用户角色创建", true, true),
|
||||
USER_ROLE_READ("USER_ROLE:READ", "用户角色读取", true, true),
|
||||
USER_ROLE_DELETE("USER_ROLE:DELETE", "用户角色删除", true, true);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.imyeyu.api.config;
|
||||
|
||||
import com.e2ins.ms.notify.SmsNotifyService;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.MapperFeature;
|
||||
@@ -31,6 +32,12 @@ public class BeanConfig {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SmsNotifyService smsNotifyService() {
|
||||
// TODO
|
||||
return new SmsNotifyService(null, null);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Yaml yaml() {
|
||||
return new Yaml();
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.imyeyu.api.modules.common.controller;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.imyeyu.api.annotation.RequireCorePermission;
|
||||
import com.imyeyu.api.bean.CorePermissionCode;
|
||||
import com.imyeyu.api.modules.common.entity.Feedback;
|
||||
import com.imyeyu.api.modules.common.service.FeedbackService;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.spring.TimiSpring;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.CaptchaValid;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.CaptchaData;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.util.ResponseView;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/// 通用反馈接口
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-19
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/feedback")
|
||||
public class FeedbackController {
|
||||
|
||||
private final FeedbackService service;
|
||||
private final UserLoginService userLoginService;
|
||||
|
||||
/// 提交反馈。登录用户和匿名用户均需提交图形验证码,匿名用户按 IP 限流
|
||||
///
|
||||
/// @param req 带图形验证码的反馈请求
|
||||
/// @return 已创建反馈
|
||||
@AOPLog
|
||||
@JsonView(ResponseView.Public.class)
|
||||
@CaptchaValid
|
||||
@RequestRateLimit(value = 3, inSeconds = 60)
|
||||
@PostMapping("/submit")
|
||||
public Feedback submit(@RequestBody @Valid CaptchaData<Feedback> req) {
|
||||
Feedback feedback = req.getData();
|
||||
feedback.setIp(TimiSpring.getRequestIP());
|
||||
if (userLoginService.getLoginUser() != null) {
|
||||
feedback.setUserId(userLoginService.getLoginUser().getId());
|
||||
}
|
||||
service.create(feedback);
|
||||
return feedback;
|
||||
}
|
||||
|
||||
/// 查询反馈列表
|
||||
///
|
||||
/// @param page 分页参数
|
||||
/// @return 反馈分页
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.FEEDBACK_READ)
|
||||
@PostMapping("/list")
|
||||
public PageResult<Feedback> list(@RequestBody Page<Feedback> page) {
|
||||
return service.page(page);
|
||||
}
|
||||
|
||||
/// 查询反馈详情
|
||||
///
|
||||
/// @param id 反馈 ID
|
||||
/// @return 反馈详情
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.FEEDBACK_READ)
|
||||
@PostMapping("/detail")
|
||||
public Feedback detail(@RequestParam String id) {
|
||||
return service.get(id);
|
||||
}
|
||||
|
||||
/// 后台创建反馈
|
||||
///
|
||||
/// @param feedback 反馈
|
||||
/// @return 反馈
|
||||
@AOPLog
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.FEEDBACK_CREATE)
|
||||
@PostMapping("/create")
|
||||
public Feedback create(@RequestBody Feedback feedback) {
|
||||
service.create(feedback);
|
||||
return feedback;
|
||||
}
|
||||
|
||||
/// 更新反馈
|
||||
///
|
||||
/// @param feedback 反馈
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.FEEDBACK_UPDATE)
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody Feedback feedback) {
|
||||
feedback.setRespondedBy(userLoginService.getRequireLoginUserId());
|
||||
service.update(feedback);
|
||||
}
|
||||
|
||||
/// 删除反馈
|
||||
///
|
||||
/// @param id 反馈 ID
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.FEEDBACK_DELETE)
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestParam String id) {
|
||||
service.delete(id);
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,10 @@ public class Article extends UUIDEntity implements SettingSupport {
|
||||
public enum BizType {
|
||||
|
||||
/** 博客 */
|
||||
BLOG
|
||||
BLOG,
|
||||
|
||||
/// 反馈
|
||||
FEEDBACK
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,4 +82,7 @@ public class Article extends UUIDEntity implements SettingSupport {
|
||||
|
||||
@Transient
|
||||
protected List<Comment> commentList;
|
||||
|
||||
@Transient
|
||||
protected List<Attachment> attachmentList;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ public class Attachment extends UUIDEntity {
|
||||
/// @since 2026-07-17 20:52
|
||||
public enum BizType {
|
||||
|
||||
ARTICLE,
|
||||
|
||||
USER,
|
||||
|
||||
GAO_CUSTOMER,
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.imyeyu.api.modules.common.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.spring.annotation.table.Transient;
|
||||
import com.imyeyu.spring.entity.UUIDEntity;
|
||||
import com.imyeyu.spring.util.ResponseView;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/// 通用反馈
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-19
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Feedback extends UUIDEntity {
|
||||
|
||||
/// 反馈处理状态
|
||||
public enum Status {
|
||||
|
||||
/// 待处理
|
||||
PENDING,
|
||||
|
||||
/// 已回复
|
||||
REPLIED,
|
||||
|
||||
/// 已关闭
|
||||
CLOSED
|
||||
}
|
||||
|
||||
/// 所属模块
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private ModuleCode module;
|
||||
|
||||
/// 提交用户 ID,匿名反馈为 null
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
private String userId;
|
||||
|
||||
/// 反馈内容文章 ID
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private String contentId;
|
||||
|
||||
/// 联系方式
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private String contact;
|
||||
|
||||
/// 提交 IP
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
private String ip;
|
||||
|
||||
/// 处理状态
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private Status status;
|
||||
|
||||
/// 管理员回复文章 ID
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private String responseId;
|
||||
|
||||
/// 回复用户 ID
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
private String respondedBy;
|
||||
|
||||
/// 回复时间
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private Long respondedAt;
|
||||
|
||||
/// 管理员回复文章
|
||||
@Transient
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private Article content;
|
||||
|
||||
/// 管理员回复文章
|
||||
@Transient
|
||||
@JsonView(ResponseView.Public.class)
|
||||
private Article response;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public interface AttachmentMapper extends BaseMapper<Attachment, String>, RawMap
|
||||
|
||||
List<Attachment> selectByBizId(Attachment.BizType bizType, String bizId, List<String> attachTypes, Page<Attachment> page);
|
||||
|
||||
List<Attachment> selectByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, List<String> attachTypes);
|
||||
List<Attachment> selectAllByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, List<String> attachTypes);
|
||||
|
||||
long countByBizId(Attachment.BizType bizType, String bizId, List<String> attachTypes);
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.imyeyu.api.modules.common.mapper;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Feedback;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
|
||||
/// 通用反馈 Mapper
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-19
|
||||
public interface FeedbackMapper extends BaseMapper<Feedback, String> {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.imyeyu.api.modules.common.service;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Feedback;
|
||||
import com.imyeyu.spring.service.BaseService;
|
||||
|
||||
/// 通用反馈服务
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-19
|
||||
public interface FeedbackService extends BaseService<Feedback, String> {
|
||||
}
|
||||
+54
@@ -1,8 +1,15 @@
|
||||
package com.imyeyu.api.modules.common.service.implement;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Article;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.mapper.ArticleMapper;
|
||||
import com.imyeyu.api.modules.common.service.ArticleService;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.system.entity.Logger;
|
||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -20,10 +27,57 @@ import org.springframework.stereotype.Service;
|
||||
@RequiredArgsConstructor
|
||||
public class ArticleServiceImplement extends AbstractEntityService<Article, String> implements ArticleService {
|
||||
|
||||
private final LoggerService loggerService;
|
||||
private final AttachmentService attachmentService;
|
||||
|
||||
private final ArticleMapper mapper;
|
||||
|
||||
@Override
|
||||
protected BaseMapper<Article, String> mapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(Article article) {
|
||||
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_ARTICLE_CREATE");
|
||||
try {
|
||||
super.create(article);
|
||||
attachmentService.updateByBizId(Attachment.BizType.ARTICLE, article.getId(), article.getAttachmentList());
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(article.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("create article error", e);
|
||||
throw new TimiException(TimiCode.ERROR, "create article error", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Article article) {
|
||||
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_ARTICLE_UPDATE");
|
||||
try {
|
||||
super.update(article);
|
||||
attachmentService.updateByBizId(Attachment.BizType.ARTICLE, article.getId(), article.getAttachmentList());
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(article.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("update article error", e);
|
||||
throw new TimiException(TimiCode.ERROR, "update article error", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -319,12 +319,12 @@ public class AttachmentServiceImplement extends AbstractEntityService<Attachment
|
||||
|
||||
@Override
|
||||
public List<Attachment> listByBizId(Attachment.BizType bizType, String bizId, String... attachTypes) {
|
||||
return mapper.selectByBizId(bizType, bizId, List.of(attachTypes), null);
|
||||
return mapper.selectAllByBizIdList(bizType, List.of(bizId), List.of(attachTypes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<Attachment>> mapByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, String... attachTypes) {
|
||||
return mapper.selectByBizIdList(bizType, bizIdList, List.of(attachTypes)).stream().collect(Collectors.groupingBy(Attachment::getBizId));
|
||||
return mapper.selectAllByBizIdList(bizType, bizIdList, List.of(attachTypes)).stream().collect(Collectors.groupingBy(Attachment::getBizId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
package com.imyeyu.api.modules.common.service.implement;
|
||||
|
||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||
import com.imyeyu.api.modules.common.entity.Feedback;
|
||||
import com.imyeyu.api.modules.common.mapper.FeedbackMapper;
|
||||
import com.imyeyu.api.modules.common.service.ArticleService;
|
||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.common.service.FeedbackService;
|
||||
import com.imyeyu.api.modules.system.entity.Logger;
|
||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import com.imyeyu.utils.Time;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/// 通用反馈服务实现
|
||||
///
|
||||
/// @author Codex
|
||||
/// @since 2026-08-19
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class FeedbackServiceImplement extends AbstractEntityService<Feedback, String> implements FeedbackService {
|
||||
|
||||
private static final long ANONYMOUS_ATTACHMENT_MAX_SIZE = 500L * 1024;
|
||||
|
||||
private final LoggerService loggerService;
|
||||
private final ArticleService articleService;
|
||||
private final UserLoginService userLoginService;
|
||||
private final AttachmentService attachmentService;
|
||||
|
||||
private final FeedbackMapper mapper;
|
||||
|
||||
@Override
|
||||
protected BaseMapper<Feedback, String> mapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void create(Feedback feedback) {
|
||||
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_FEEDBACK_CREATE");
|
||||
try {
|
||||
TimiException.required(feedback, "未找到反馈");
|
||||
articleService.create(feedback.getContent());
|
||||
feedback.setContentId(feedback.getContent().getId());
|
||||
feedback.setStatus(TimiJava.defaultIfNull(feedback.getStatus(), Feedback.Status.PENDING));
|
||||
super.create(feedback);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(feedback.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("create feedback error", e);
|
||||
throw new TimiException(TimiCode.ERROR, "create feedback error", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void update(Feedback feedback) {
|
||||
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_FEEDBACK_UPDATE");
|
||||
try {
|
||||
TimiException.required(feedback, "未找到反馈");
|
||||
TimiException.required(feedback.getId(), "未找到反馈 ID");
|
||||
Feedback dbFeedback = get(feedback.getId());
|
||||
TimiException.required(dbFeedback, "未找到反馈");
|
||||
|
||||
feedback.getContent().setId(dbFeedback.getContentId());
|
||||
articleService.update(feedback.getContent());
|
||||
|
||||
dbFeedback.setModule(TimiJava.defaultIfNull(feedback.getModule(), dbFeedback.getModule()));
|
||||
if (TimiJava.isNotEmpty(feedback.getResponse())) {
|
||||
if (TimiJava.isEmpty(feedback.getResponseId())) {
|
||||
articleService.create(feedback.getResponse());
|
||||
dbFeedback.setResponseId(feedback.getResponse().getId());
|
||||
dbFeedback.setRespondedAt(Time.now());
|
||||
} else {
|
||||
feedback.getResponse().setId(dbFeedback.getResponseId());
|
||||
articleService.update(feedback.getResponse());
|
||||
}
|
||||
dbFeedback.setStatus(Feedback.Status.REPLIED);
|
||||
dbFeedback.setRespondedBy(userLoginService.getRequireLoginUserId());
|
||||
}
|
||||
super.update(dbFeedback);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(feedback.getId());
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("修改反馈失败", e);
|
||||
throw new TimiException(TimiCode.ERROR, "修改反馈失败", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
Logger logger = new Logger(Logger.Module.COMMON, "COMMON_FEEDBACK_DELETE");
|
||||
try {
|
||||
Feedback feedback = get(id);
|
||||
articleService.delete(feedback.getContentId());
|
||||
if (TimiJava.isNotEmpty(feedback.getResponseId())) {
|
||||
articleService.delete(feedback.getResponseId());
|
||||
}
|
||||
super.delete(id);
|
||||
logger.setLevel(Logger.Level.INFO);
|
||||
logger.setResult(id);
|
||||
} catch (TimiException e) {
|
||||
logger.setLevel(Logger.Level.WARN);
|
||||
logger.setException(e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
logger.setLevel(Logger.Level.ERROR);
|
||||
logger.setException(TimiJava.serializeThrowable(e));
|
||||
log.error("delete feedback error", e);
|
||||
throw new TimiException(TimiCode.ERROR, "delete feedback error", e);
|
||||
} finally {
|
||||
loggerService.create(logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ public class GaoUserInviteCache {
|
||||
/// 发起邀请的用户 ID
|
||||
private String inviterUserId;
|
||||
|
||||
/// 门店 ID
|
||||
/// 门店 ID,GLOBAL_MANAGER 可为空
|
||||
private String storeId;
|
||||
|
||||
/// 角色 ID
|
||||
|
||||
@@ -62,7 +62,9 @@ public class GaoEventController {
|
||||
@RequireGaoPermission(GaoPermissionCode.EVENT_READ)
|
||||
@PostMapping("/detail")
|
||||
public GaoEvent detail(@RequestParam String id) {
|
||||
return service.get(id);
|
||||
GaoEvent event = service.get(id);
|
||||
event.setRoleCodeList(service.listRoleCode(event.getId()));
|
||||
return event;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
|
||||
@@ -21,6 +21,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 客户积分规则接口
|
||||
///
|
||||
/// @author Codex
|
||||
@@ -78,6 +80,19 @@ public class GaoPointRuleController {
|
||||
ruleService.update(rule);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_UPDATE)
|
||||
@PostMapping("/rule/sort")
|
||||
public void sort(@RequestBody List<String> idList) {
|
||||
if (idList != null) {
|
||||
for (GaoPointRule rule : ruleService.listByIdList(idList)) {
|
||||
checkStore(rule.getStoreId());
|
||||
}
|
||||
}
|
||||
ruleService.sort(idList);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.POINT_RULE_DELETE)
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
@@ -57,6 +58,15 @@ public class GaoStoreChartController {
|
||||
return service.eventRecordDailyStat(req);
|
||||
}
|
||||
|
||||
/// 查询登记事件每日数值合计
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.STAT_READ)
|
||||
@PostMapping("/event/record/number-value/daily")
|
||||
public List<GaoEventRecordNumberValueDailyStatView> eventRecordNumberValueDaily(@RequestBody GaoStoreChartReq req) {
|
||||
return service.eventRecordNumberValueDailyStat(req);
|
||||
}
|
||||
|
||||
/// 查询登记事件日历记录
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
|
||||
@@ -123,7 +123,9 @@ public class GaoUserController {
|
||||
{
|
||||
User user = userService.get(result.getUserId());
|
||||
user.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.USER, user.getId()));
|
||||
user.setRoleList(userRoleService.listAllRoleCodeByUserId(user.getId()));
|
||||
user.setRoleEntityList(userRoleService.listRoleByUserId(user.getId()));
|
||||
user.setPermissionList(userRoleService.listAllPermissionCodeByUserId(user.getId()));
|
||||
result.setUser(user);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -30,7 +30,11 @@ public class GaoCustomer extends UUIDEntity {
|
||||
/// @since 2026-07-27
|
||||
public enum AttachType {
|
||||
|
||||
PHOTO
|
||||
PHOTO,
|
||||
|
||||
POINT_CARD,
|
||||
|
||||
OTHER
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
@@ -17,7 +17,7 @@ public class GaoPointLedger extends UUIDEntity {
|
||||
/// 流水变化类型
|
||||
public enum ChangeType {
|
||||
|
||||
/// 登记事件获得积分
|
||||
/// 登记事件积分变化
|
||||
EARN,
|
||||
|
||||
/// 删除登记记录撤销积分
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.imyeyu.api.modules.gao.vo.GaoCustomerChartReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerEventRankView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordPage;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordRankPage;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
|
||||
@@ -88,6 +89,9 @@ public interface GaoEventRecordMapper extends BaseMapper<GaoEventRecord, String>
|
||||
/// @return 每日登记数
|
||||
List<GaoEventRecordDailyStatView> stateDailyByRange(GaoStoreChartReq req);
|
||||
|
||||
/// 按时间范围和事件统计每日登记数值合计
|
||||
List<GaoEventRecordNumberValueDailyStatView> stateNumberValueDailyByRange(GaoStoreChartReq req);
|
||||
|
||||
/// 按时间范围查询登记日历记录
|
||||
///
|
||||
/// @param req 门店报表查询请求
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.imyeyu.api.modules.gao.entity.GaoPointRule;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 客户积分规则 Mapper
|
||||
@@ -12,6 +13,8 @@ import java.util.List;
|
||||
/// @since 2026-08-11
|
||||
public interface GaoPointRuleMapper extends BaseMapper<GaoPointRule, String> {
|
||||
|
||||
List<GaoPointRule> selectByIdList(Collection<String> idList);
|
||||
|
||||
/// 查询当前时间可匹配的启用规则
|
||||
///
|
||||
/// @param storeId 门店 ID
|
||||
|
||||
@@ -19,6 +19,17 @@ public interface GaoPointRuleService extends BaseService<GaoPointRule, String> {
|
||||
/// @return 规则列表
|
||||
List<GaoPointRule> listActive(String storeId, String eventId, long now);
|
||||
|
||||
/// 查询规则 ID 列表
|
||||
///
|
||||
/// @param idList 规则 ID 列表
|
||||
/// @return 规则列表
|
||||
List<GaoPointRule> listByIdList(List<String> idList);
|
||||
|
||||
/// 按客户端提交的顺序更新启用规则优先级
|
||||
///
|
||||
/// @param idList 规则 ID 列表
|
||||
void sort(List<String> idList);
|
||||
|
||||
/// 创建积分规则
|
||||
///
|
||||
/// @param rule 积分规则
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStateView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
|
||||
|
||||
import java.util.List;
|
||||
@@ -23,6 +24,9 @@ public interface GaoStoreChartService {
|
||||
/// 查询登记事件每日统计
|
||||
List<GaoEventRecordDailyStatView> eventRecordDailyStat(GaoStoreChartReq req);
|
||||
|
||||
/// 查询登记事件每日数值合计
|
||||
List<GaoEventRecordNumberValueDailyStatView> eventRecordNumberValueDailyStat(GaoStoreChartReq req);
|
||||
|
||||
/// 查询登记事件日历记录
|
||||
List<GaoEventRecordCalendarView> eventRecordCalendar(GaoStoreChartReq req);
|
||||
}
|
||||
|
||||
+1
-1
@@ -377,7 +377,7 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
||||
}
|
||||
|
||||
private void changeInvitedCount(String customerId, long delta) {
|
||||
if (delta == 0) {
|
||||
if (TimiJava.isEmpty(customerId) || delta == 0) {
|
||||
return;
|
||||
}
|
||||
GaoCustomer customer = get(customerId);
|
||||
|
||||
+2
-2
@@ -10,9 +10,9 @@ import com.imyeyu.api.modules.gao.entity.GaoEvent;
|
||||
import com.imyeyu.api.modules.gao.entity.GaoEventRecord;
|
||||
import com.imyeyu.api.modules.gao.mapper.GaoEventRecordMapper;
|
||||
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoPointTriggerService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoEventRecordService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoEventService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoPointTriggerService;
|
||||
import com.imyeyu.api.modules.gao.service.GaoStoreBusinessDayService;
|
||||
import com.imyeyu.api.modules.gao.util.EventRecordXSSFBuilder;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerEventRankView;
|
||||
@@ -321,7 +321,7 @@ public class GaoEventRecordServiceImplement extends AbstractEntityService<GaoEve
|
||||
long today = Time.today(registeredAt);
|
||||
long noon = today + Time.D / 2;
|
||||
long beginAt = today, endAt;
|
||||
if (today + registeredAt < noon) {
|
||||
if (registeredAt < noon) {
|
||||
// 上半日
|
||||
endAt = noon;
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -221,7 +221,7 @@ public class GaoEventServiceImplement extends AbstractEntityService<GaoEvent, St
|
||||
TimiException.required(event.getValueUnit(), "NUMBER 事件必须配置数值单位");
|
||||
}
|
||||
if (TimiJava.isNotEmpty(event.getLimitType()) && event.getLimitType() != GaoEvent.LimitType.NONE) {
|
||||
TimiException.requiredTrue(event.getLimitType().getMin() < event.getLimitValue(), "约束值最低 %s".formatted(event.getLimitType().getMin()));
|
||||
TimiException.requiredTrue(event.getLimitType().getMin() <= event.getLimitValue(), "约束值最低 %s".formatted(event.getLimitType().getMin()));
|
||||
}
|
||||
if (event.getBeginAt() != null || event.getEndAt() != null) {
|
||||
TimiException.requiredTrue(event.getBeginAt() == null || event.getEndAt() == null || event.getBeginAt() <= event.getEndAt(), "invalid beginAt or endAt");
|
||||
|
||||
+2
-2
@@ -74,7 +74,7 @@ public class GaoPointLedgerServiceImplement extends AbstractEntityService<GaoPoi
|
||||
public GaoPointLedger earn(GaoEventRecord record, GaoPointRule rule, long pointDelta, JsonNode sourcePayload) {
|
||||
TimiException.required(record, "not found event record");
|
||||
TimiException.required(rule, "not found point rule");
|
||||
TimiException.requiredTrue(0 < pointDelta, "pointDelta invalid");
|
||||
TimiException.requiredTrue(pointDelta != 0, "pointDelta invalid");
|
||||
String idempotencyKey = "GAO_EVENT_RECORD:%s:RULE:%s:EARN".formatted(record.getId(), rule.getId());
|
||||
return apply(record.getStoreId(), record.getCustomerId(), GaoPointLedger.ChangeType.EARN, pointDelta, rule.getId(), record.getEventId(), record.getId(), sourcePayload, idempotencyKey, rule.getRemark(), record.getOperatorUserId(), record.getRegisteredAt());
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class GaoPointLedgerServiceImplement extends AbstractEntityService<GaoPoi
|
||||
public GaoPointLedger revoke(GaoPointLedger originLedger, GaoEventRecord record) {
|
||||
TimiException.required(originLedger, "not found origin ledger");
|
||||
TimiException.required(record, "not found event record");
|
||||
TimiException.requiredTrue(0 < originLedger.getPointDelta(), "origin ledger pointDelta invalid");
|
||||
TimiException.requiredTrue(originLedger.getPointDelta() != 0, "origin ledger pointDelta invalid");
|
||||
String idempotencyKey = "GAO_EVENT_RECORD:%s:LEDGER:%s:REVOKE".formatted(record.getId(), originLedger.getId());
|
||||
return apply(originLedger.getStoreId(), originLedger.getCustomerId(), GaoPointLedger.ChangeType.REVOKE, -originLedger.getPointDelta(), originLedger.getRuleId(), originLedger.getEventId(), originLedger.getEventRecordId(), originLedger.getSourcePayload(), idempotencyKey, "撤销登记记录积分", userLoginService.getRequireLoginUserId(), Time.now());
|
||||
}
|
||||
|
||||
+37
-4
@@ -16,6 +16,11 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/// GAO 客户积分规则服务实现
|
||||
///
|
||||
@@ -42,6 +47,32 @@ public class GaoPointRuleServiceImplement extends AbstractEntityService<GaoPoint
|
||||
return mapper.selectActiveByStoreIdAndEventId(storeId, eventId, now);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoPointRule> listByIdList(List<String> idList) {
|
||||
if (TimiJava.isEmpty(idList)) {
|
||||
return List.of();
|
||||
}
|
||||
return mapper.selectByIdList(new LinkedHashSet<>(idList));
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void sort(List<String> idList) {
|
||||
if (TimiJava.isEmpty(idList)) {
|
||||
return;
|
||||
}
|
||||
List<String> distinctIdList = new ArrayList<>(new LinkedHashSet<>(idList));
|
||||
Map<String, GaoPointRule> ruleMap = mapper.selectByIdList(new LinkedHashSet<>(distinctIdList)).stream()
|
||||
.collect(Collectors.toMap(GaoPointRule::getId, Function.identity()));
|
||||
TimiException.requiredTrue(ruleMap.size() == distinctIdList.size(), "积分规则列表包含不存在的规则");
|
||||
for (int i = 0; i < distinctIdList.size(); i++) {
|
||||
GaoPointRule rule = ruleMap.get(distinctIdList.get(i));
|
||||
TimiException.requiredTrue(rule.getStatus() == GaoPointRule.Status.ACTIVE, "只能调整启用规则排序");
|
||||
rule.setPriority(i);
|
||||
mapper.update(rule);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void create(GaoPointRule rule) {
|
||||
@@ -127,7 +158,7 @@ public class GaoPointRuleServiceImplement extends AbstractEntityService<GaoPoint
|
||||
|
||||
TimiException.requiredTrue(rule.getPointMode() == GaoPointRule.PointMode.FIXED, "固定触发规则必须使用 FIXED 积分值模式");
|
||||
TimiException.required(rule.getPointValue(), "not found rule.pointValue");
|
||||
TimiException.requiredTrue(0 < rule.getPointValue(), "rule.pointValue invalid");
|
||||
TimiException.requiredTrue(rule.getPointValue() != 0, "rule.pointValue invalid");
|
||||
if (rule.getTriggerType() == GaoPointRule.TriggerType.AFTER_COUNT_EVERY_TIME) {
|
||||
JsonNode condition = requireObjectCondition(rule.getConditionJson());
|
||||
JsonNode threshold = condition.get("threshold");
|
||||
@@ -149,6 +180,7 @@ public class GaoPointRuleServiceImplement extends AbstractEntityService<GaoPoint
|
||||
TimiException.required(sourceEvent, "TIER.sourceEventId 对应事件不存在");
|
||||
TimiException.requiredTrue(storeId.equals(sourceEvent.getStoreId()), "TIER 来源事件和规则不属于同一门店");
|
||||
TimiException.requiredTrue(sourceEvent.getValueType() == GaoEvent.ValueType.NUMBER, "TIER 来源事件必须配置为 NUMBER 类型");
|
||||
TimiException.required(sourceEvent.getValueUnit(), "TIER 来源事件必须配置数值单位");
|
||||
|
||||
JsonNode sourceValueField = condition.get("sourceValueField");
|
||||
TimiException.requiredTrue(sourceValueField != null && sourceValueField.isTextual() && "numberValue".equals(sourceValueField.asText()), "TIER.sourceValueField 目前只能是 numberValue");
|
||||
@@ -192,7 +224,7 @@ public class GaoPointRuleServiceImplement extends AbstractEntityService<GaoPoint
|
||||
TimiException.requiredTrue(max == null, "最后一档 TIER.max 必须为空");
|
||||
}
|
||||
JsonNode pointValue = tier.get("pointValue");
|
||||
TimiException.requiredTrue(pointValue != null && pointValue.isIntegralNumber() && 0 <= pointValue.longValue(), "TIER.tiers[%d].pointValue invalid".formatted(i));
|
||||
TimiException.requiredTrue(pointValue != null && pointValue.isIntegralNumber(), "TIER.tiers[%d].pointValue invalid".formatted(i));
|
||||
previousMax = max;
|
||||
}
|
||||
}
|
||||
@@ -203,9 +235,10 @@ public class GaoPointRuleServiceImplement extends AbstractEntityService<GaoPoint
|
||||
Long max = condition == null || condition.get("max") == null || condition.get("max").isNull() ? null : condition.get("max").isIntegralNumber() ? condition.get("max").longValue() : null;
|
||||
TimiException.requiredTrue(condition == null || min != null || condition.get("min") == null || condition.get("min").isNull(), "SOURCE_VALUE.min invalid");
|
||||
TimiException.requiredTrue(condition == null || max != null || condition.get("max") == null || condition.get("max").isNull(), "SOURCE_VALUE.max invalid");
|
||||
TimiException.requiredTrue(min == null || 0 < min, "SOURCE_VALUE.min invalid");
|
||||
TimiException.requiredTrue(max == null || 0 < max, "SOURCE_VALUE.max invalid");
|
||||
TimiException.requiredTrue(min == null || min != 0, "SOURCE_VALUE.min invalid");
|
||||
TimiException.requiredTrue(max == null || max != 0, "SOURCE_VALUE.max invalid");
|
||||
TimiException.requiredTrue(min == null || max == null || min <= max, "SOURCE_VALUE.min or SOURCE_VALUE.max invalid");
|
||||
TimiException.requiredTrue(min == null || max == null || (min < 0) == (max < 0), "SOURCE_VALUE.min or SOURCE_VALUE.max direction invalid");
|
||||
}
|
||||
|
||||
private JsonNode requireObjectCondition(JsonNode conditionJson) {
|
||||
|
||||
+6
-6
@@ -62,7 +62,7 @@ public class GaoPointTriggerServiceImplement implements GaoPointTriggerService {
|
||||
|
||||
List<GaoPointRule> ruleList = ruleService.listActive(record.getStoreId(), record.getEventId(), Time.now());
|
||||
Long count = null;
|
||||
long earnedPointValue = 0L;
|
||||
long pointDeltaTotal = 0L;
|
||||
for (GaoPointRule rule : ruleList) {
|
||||
RuleResolution resolution = resolveRule(record, rule, count);
|
||||
if (resolution == null) {
|
||||
@@ -72,16 +72,16 @@ public class GaoPointTriggerServiceImplement implements GaoPointTriggerService {
|
||||
count = count == null ? count(record) : count;
|
||||
}
|
||||
long pointDelta = resolution.pointDelta();
|
||||
if (0 < pointDelta) {
|
||||
if (pointDelta != 0) {
|
||||
ledgerService.earn(record, rule, pointDelta, resolution.sourcePayload());
|
||||
earnedPointValue = Math.addExact(earnedPointValue, pointDelta);
|
||||
pointDeltaTotal = Math.addExact(pointDeltaTotal, pointDelta);
|
||||
}
|
||||
if (Boolean.TRUE.equals(rule.getExclusive())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
record.setEarnedPointValue(earnedPointValue);
|
||||
eventRecordMapper.updateEarnedPointValue(record.getId(), earnedPointValue);
|
||||
record.setEarnedPointValue(pointDeltaTotal);
|
||||
eventRecordMapper.updateEarnedPointValue(record.getId(), pointDeltaTotal);
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@@ -140,7 +140,7 @@ public class GaoPointTriggerServiceImplement implements GaoPointTriggerService {
|
||||
}
|
||||
permissionChecker.checkAny(ModuleCode.GAO, GaoPermissionCode.POINT_SOURCE_VALUE.getValue());
|
||||
long pointValue = record.getPointValue();
|
||||
TimiException.requiredTrue(0 < pointValue, "pointValue invalid");
|
||||
TimiException.requiredTrue(pointValue != 0, "pointValue invalid");
|
||||
JsonNode condition = rule.getConditionJson();
|
||||
if (condition != null) {
|
||||
JsonNode min = condition.get("min");
|
||||
|
||||
+7
@@ -8,6 +8,7 @@ import com.imyeyu.api.modules.gao.vo.GaoCustomerGenderStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoCustomerTrendStateReq;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView;
|
||||
import com.imyeyu.api.modules.gao.vo.GaoStoreChartReq;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -48,6 +49,12 @@ public class GaoStoreChartServiceImplement implements GaoStoreChartService {
|
||||
return eventRecordMapper.stateDailyByRange(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoEventRecordNumberValueDailyStatView> eventRecordNumberValueDailyStat(GaoStoreChartReq req) {
|
||||
checkRangeReq(req);
|
||||
return eventRecordMapper.stateNumberValueDailyByRange(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GaoEventRecordCalendarView> eventRecordCalendar(GaoStoreChartReq req) {
|
||||
checkRangeReq(req);
|
||||
|
||||
+42
-18
@@ -1,5 +1,6 @@
|
||||
package com.imyeyu.api.modules.gao.service.implement;
|
||||
|
||||
import com.imyeyu.api.bean.CoreRoleCode;
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||
import com.imyeyu.api.modules.gao.bean.GaoUserInviteCache;
|
||||
@@ -96,30 +97,36 @@ public class GaoUserInviteServiceImplement implements GaoUserInviteService {
|
||||
String inviterUserId = userLoginService.getRequireLoginUserId();
|
||||
logger.setUserId(inviterUserId);
|
||||
permissionChecker.checkAny(ModuleCode.GAO, GaoPermissionCode.USER_CREATE.getValue());
|
||||
Role requestedRole = roleService.get(req.getRoleId());
|
||||
boolean adminInviteGlobalManager = roleChecker.hasAny(ModuleCode.CORE, CoreRoleCode.ADMIN.name())
|
||||
&& isGlobalManagerRole(requestedRole);
|
||||
boolean globalManager = authorizationScopeService.isSystemAdmin(inviterUserId)
|
||||
|| roleChecker.hasAny(ModuleCode.GAO, GaoRoleCode.GLOBAL_MANAGER.name());
|
||||
boolean storeManager = !globalManager;
|
||||
GaoStore loginStore = storeManager ? gaoStoreService.getByUserId(inviterUserId) : null;
|
||||
String storeId = storeManager ? loginStore == null ? null : loginStore.getId() : req.getStoreId();
|
||||
TimiException.required(storeId, "not found storeId");
|
||||
checkStoreScope(inviterUserId, storeId);
|
||||
|
||||
GaoStore store = requireActiveStore(storeId);
|
||||
String storeId = adminInviteGlobalManager ? null : storeManager ? loginStore == null ? null : loginStore.getId() : req.getStoreId();
|
||||
if (!adminInviteGlobalManager) {
|
||||
TimiException.required(storeId, "not found storeId");
|
||||
checkStoreScope(inviterUserId, storeId);
|
||||
}
|
||||
if (storeId != null) {
|
||||
requireActiveStore(storeId);
|
||||
}
|
||||
Role role = requireInvitableRole(inviterUserId, req.getRoleId(), storeId);
|
||||
long createdAt = Time.now();
|
||||
long expireAt = createdAt + INVITE_TTL;
|
||||
|
||||
GaoUserInviteCache cache = new GaoUserInviteCache();
|
||||
cache.setInviterUserId(inviterUserId);
|
||||
cache.setStoreId(store.getId());
|
||||
cache.setStoreId(storeId);
|
||||
cache.setRoleId(role.getId());
|
||||
cache.setScene(storeManager ? "STORE_MANAGER" : "STORE_MANAGEMENT");
|
||||
cache.setScene(adminInviteGlobalManager ? "CORE_ADMIN" : storeManager ? "STORE_MANAGER" : "STORE_MANAGEMENT");
|
||||
cache.setCreatedAt(createdAt);
|
||||
cache.setExpireAt(expireAt);
|
||||
String code = saveInvite(cache);
|
||||
|
||||
logger.setContent("storeId=%s;roleId=%s;scene=%s;createdAt=%d;expireAt=%d".formatted(
|
||||
store.getId(), role.getId(), cache.getScene(), createdAt, expireAt));
|
||||
storeId, role.getId(), cache.getScene(), createdAt, expireAt));
|
||||
logger.setResult("created");
|
||||
return new GaoUserInviteCreateResponse(code, expireAt);
|
||||
} catch (TimiException e) {
|
||||
@@ -141,8 +148,7 @@ public class GaoUserInviteServiceImplement implements GaoUserInviteService {
|
||||
TimiException.required(code, "not found code");
|
||||
checkCodeRateLimit(code);
|
||||
GaoUserInviteCache cache = requireValidInvite(code);
|
||||
requireActiveStore(cache.getStoreId());
|
||||
requireValidRole(cache.getRoleId(), cache.getStoreId());
|
||||
validateInviteTarget(cache);
|
||||
return new GaoUserInviteValidateResponse(true, cache.getExpireAt());
|
||||
}
|
||||
|
||||
@@ -163,8 +169,7 @@ public class GaoUserInviteServiceImplement implements GaoUserInviteService {
|
||||
try {
|
||||
cache = requireValidInvite(code);
|
||||
logger.setContent(buildLogContent(cache));
|
||||
requireActiveStore(cache.getStoreId());
|
||||
requireValidRole(cache.getRoleId(), cache.getStoreId());
|
||||
validateInviteTarget(cache);
|
||||
TimiException.requiredNull(userService.getByName(data.getName()), "existed user name");
|
||||
TimiException.requiredNull(userService.getByPhoneNo(data.getPhoneNo()), "existed phone number");
|
||||
if (!redisInvite.destroy(getInviteKey(code))) {
|
||||
@@ -176,10 +181,16 @@ public class GaoUserInviteServiceImplement implements GaoUserInviteService {
|
||||
user.setPhoneNo(data.getPhoneNo());
|
||||
user.setPassword(data.getPassword());
|
||||
|
||||
GaoUser gaoUser = new GaoUser();
|
||||
gaoUser.setStoreId(cache.getStoreId());
|
||||
gaoUser.setUser(user);
|
||||
gaoUserService.create(gaoUser);
|
||||
if (cache.getStoreId() == null) {
|
||||
// TODO 用更好的方式
|
||||
userService.create(user);
|
||||
userService.verifyPhoneNo(user.getId());
|
||||
} else {
|
||||
GaoUser gaoUser = new GaoUser();
|
||||
gaoUser.setStoreId(cache.getStoreId());
|
||||
gaoUser.setUser(user);
|
||||
gaoUserService.create(gaoUser);
|
||||
}
|
||||
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setId(UUID.randomUUID().toString());
|
||||
@@ -265,7 +276,7 @@ public class GaoUserInviteServiceImplement implements GaoUserInviteService {
|
||||
|
||||
private Role requireValidRole(String roleId, String storeId) {
|
||||
Role role = roleService.get(roleId);
|
||||
if (role == null || role.getModuleCode() != ModuleCode.GAO || !isRoleUsableForStore(role, storeId)) {
|
||||
if (role == null || role.getModuleCode() != ModuleCode.GAO || (storeId == null && !isGlobalManagerRole(role)) || !isRoleUsableForStore(role, storeId)) {
|
||||
throw invalidInvite();
|
||||
}
|
||||
return role;
|
||||
@@ -274,7 +285,20 @@ public class GaoUserInviteServiceImplement implements GaoUserInviteService {
|
||||
private boolean isRoleUsableForStore(Role role, String storeId) {
|
||||
return role.getOwnerType() == null
|
||||
|| role.getOwnerType() == AuthOwnerType.MODULE && (TimiJava.isEmpty(role.getOwnerId()) || ModuleCode.GAO.name().equals(role.getOwnerId()))
|
||||
|| role.getOwnerType() == AuthOwnerType.STORE && storeId.equals(role.getOwnerId());
|
||||
|| role.getOwnerType() == AuthOwnerType.STORE && storeId != null && storeId.equals(role.getOwnerId());
|
||||
}
|
||||
|
||||
private boolean isGlobalManagerRole(Role role) {
|
||||
return role != null
|
||||
&& role.getModuleCode() == ModuleCode.GAO
|
||||
&& GaoRoleCode.GLOBAL_MANAGER.name().equals(role.getCode());
|
||||
}
|
||||
|
||||
private void validateInviteTarget(GaoUserInviteCache cache) {
|
||||
if (cache.getStoreId() != null) {
|
||||
requireActiveStore(cache.getStoreId());
|
||||
}
|
||||
requireValidRole(cache.getRoleId(), cache.getStoreId());
|
||||
}
|
||||
|
||||
private void checkStoreScope(String userId, String storeId) {
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.imyeyu.api.modules.gao.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/// 登记事件数值每日统计视图
|
||||
@Data
|
||||
public class GaoEventRecordNumberValueDailyStatView {
|
||||
|
||||
/// 登记事件 ID
|
||||
private String eventId;
|
||||
|
||||
/// 日期值,格式为 yyyyMMdd
|
||||
private Integer dateValue;
|
||||
|
||||
/// 当日登记数值合计
|
||||
private Long dailyNumberValue;
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import lombok.Data;
|
||||
@Data
|
||||
public class GaoUserInviteCreateRequest {
|
||||
|
||||
/// 门店管理场景的目标门店 ID,店长场景不使用
|
||||
/// 门店管理场景的目标门店 ID,店长场景及 ADMIN 邀请 GLOBAL_MANAGER 时不使用
|
||||
private String storeId;
|
||||
|
||||
/// 目标角色 ID
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.imyeyu.api.modules.user.service;
|
||||
|
||||
import com.e2ins.ms.notify.vo.sms.CaptchaVerifyReq;
|
||||
import com.imyeyu.api.modules.user.entity.User;
|
||||
import com.imyeyu.api.modules.user.vo.LoginRequest;
|
||||
import com.imyeyu.api.modules.user.vo.LoginResponse;
|
||||
@@ -23,6 +24,8 @@ public interface UserLoginService {
|
||||
|
||||
LoginResponse login(String token, String userId);
|
||||
|
||||
LoginResponse loginBySms(CaptchaVerifyReq req);
|
||||
|
||||
/**
|
||||
* 根据令牌获取用户
|
||||
*
|
||||
|
||||
+24
-2
@@ -1,5 +1,8 @@
|
||||
package com.imyeyu.api.modules.user.service.implement;
|
||||
|
||||
import com.e2ins.ms.notify.SmsNotifyService;
|
||||
import com.e2ins.ms.notify.bean.NotifyDetail;
|
||||
import com.e2ins.ms.notify.vo.sms.CaptchaVerifyReq;
|
||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||
import com.imyeyu.api.modules.common.entity.Setting;
|
||||
@@ -7,13 +10,13 @@ import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||
import com.imyeyu.api.modules.common.service.SettingService;
|
||||
import com.imyeyu.api.modules.user.bean.BootstrapData;
|
||||
import com.imyeyu.api.modules.user.entity.User;
|
||||
import com.imyeyu.api.modules.user.service.RoleService;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.api.modules.user.service.UserRoleService;
|
||||
import com.imyeyu.api.modules.user.service.UserService;
|
||||
import com.imyeyu.api.modules.user.vo.LoginRequest;
|
||||
import com.imyeyu.api.modules.user.vo.LoginResponse;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.TimiSpring;
|
||||
import com.imyeyu.spring.util.Redis;
|
||||
@@ -27,6 +30,7 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@@ -44,9 +48,9 @@ public class UserLoginServiceImplement implements UserLoginService, TimiJava {
|
||||
private static final long PHONE_VERIFY_CODE_TTL = Time.M * 5;
|
||||
|
||||
private final UserService userService;
|
||||
private final RoleService roleService;
|
||||
private final SettingService settingService;
|
||||
private final UserRoleService userRoleService;
|
||||
private final SmsNotifyService smsNotifyService;
|
||||
private final AttachmentService attachmentService;
|
||||
|
||||
private final Redis<String, String> redisUserToken;
|
||||
@@ -98,6 +102,24 @@ public class UserLoginServiceImplement implements UserLoginService, TimiJava {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public LoginResponse loginBySms(CaptchaVerifyReq req) {
|
||||
try {
|
||||
NotifyDetail detail = smsNotifyService.captchaVerify(req);
|
||||
// 无报错即成功
|
||||
User user = userService.getByPhoneNo(detail.getSendTo());
|
||||
if (!user.isValidPhone()) {
|
||||
user.setPhoneNoVerifyAt(Time.now());
|
||||
userService.update(user);
|
||||
}
|
||||
return login(UUID.randomUUID().toString(), user.getId());
|
||||
} catch (IOException e) {
|
||||
log.error("login by sms error", e);
|
||||
throw new TimiException(TimiCode.ERROR, "验证短信失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getLoginUser(String token) {
|
||||
if (TimiJava.isEmpty(token)) {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
CREATE TABLE `feedback` (
|
||||
`id` CHAR(36) NOT NULL COMMENT '主键',
|
||||
`module` VARCHAR(32) NOT NULL COMMENT '所属模块',
|
||||
`user_id` CHAR(36) NULL COMMENT '提交用户 ID,匿名反馈为空',
|
||||
`content_id` VARCHAR(36) NOT NULL COMMENT '反馈内容文章 ID',
|
||||
`contact` VARCHAR(255) NULL COMMENT '联系方式',
|
||||
`ip` VARCHAR(64) NULL COMMENT '提交 IP',
|
||||
`status` VARCHAR(16) NOT NULL DEFAULT 'PENDING' COMMENT '处理状态',
|
||||
`response_id` VARCHAR(36) NULL COMMENT '管理员回复文章 ID',
|
||||
`responded_by` CHAR(36) NULL COMMENT '回复用户 ID',
|
||||
`responded_at` BIGINT NULL COMMENT '回复时间',
|
||||
`created_at` BIGINT NOT NULL COMMENT '创建时间',
|
||||
`updated_at` BIGINT NOT NULL COMMENT '更新时间',
|
||||
`deleted_at` BIGINT NULL COMMENT '删除时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_feedback_module_status_created` (`module`, `status`, `created_at`),
|
||||
KEY `idx_feedback_user_created` (`user_id`, `created_at`),
|
||||
KEY `idx_feedback_content_id` (`content_id`),
|
||||
KEY `idx_feedback_response_id` (`response_id`),
|
||||
KEY `idx_feedback_deleted_at` (`deleted_at`)
|
||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '通用反馈';
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.imyeyu.api.modules.common.mapper.AttachmentMapper">
|
||||
<select id="selectByBizIdList" resultType="com.imyeyu.api.modules.common.entity.Attachment">
|
||||
<select id="selectAllByBizIdList" resultType="com.imyeyu.api.modules.common.entity.Attachment">
|
||||
SELECT
|
||||
*
|
||||
FROM `attachment`
|
||||
|
||||
@@ -350,6 +350,22 @@
|
||||
r.`registered_date_value` ASC,
|
||||
r.`event_id` ASC
|
||||
</select>
|
||||
<select id="stateNumberValueDailyByRange" resultType="com.imyeyu.api.modules.gao.vo.GaoEventRecordNumberValueDailyStatView">
|
||||
SELECT
|
||||
r.`event_id` AS `eventId`,
|
||||
r.`registered_date_value` AS `dateValue`,
|
||||
SUM(r.`number_value`) AS `dailyNumberValue`
|
||||
FROM `gao_event_record` r
|
||||
WHERE
|
||||
<include refid="storeChartRangeWhere"/>
|
||||
AND r.`number_value` IS NOT NULL
|
||||
GROUP BY
|
||||
r.`event_id`,
|
||||
r.`registered_date_value`
|
||||
ORDER BY
|
||||
r.`registered_date_value` ASC,
|
||||
r.`event_id` ASC
|
||||
</select>
|
||||
<select id="selectCalendarByRange" resultType="com.imyeyu.api.modules.gao.vo.GaoEventRecordCalendarView">
|
||||
SELECT
|
||||
r.`id`,
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoPointRuleMapper">
|
||||
<select id="selectByIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRule">
|
||||
SELECT *
|
||||
FROM gao_point_rule
|
||||
WHERE deleted_at IS NULL
|
||||
AND id IN
|
||||
<foreach collection="idList" item="id" separator="," open="(" close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectActiveByStoreIdAndEventId" resultType="com.imyeyu.api.modules.gao.entity.GaoPointRule">
|
||||
SELECT *
|
||||
FROM `gao_point_rule`
|
||||
|
||||
Reference in New Issue
Block a user