Compare commits
25 Commits
aefcd2fdb0
...
cd767dce6f
| Author | SHA1 | Date | |
|---|---|---|---|
| cd767dce6f | |||
| bf95b85841 | |||
| 9e58bd9e7d | |||
| d0ec5c5c26 | |||
| ab8aa5ea5c | |||
|
|
34da437a26 | ||
|
|
f84935d0bd | ||
| 35edaa0f27 | |||
| f43099e19e | |||
| 8079877734 | |||
| ef686e38ac | |||
| 100019d2a4 | |||
|
|
12af237d76 | ||
|
|
44dbbb2a4b | ||
| 9f42e153a4 | |||
| 6cd42b799a | |||
| 6e1ed7f9b8 | |||
| b7be16738b | |||
| 6da5e91ec1 | |||
| a710fdd432 | |||
| d598f53d3c | |||
| 96170a9956 | |||
| 8205fb5290 | |||
| fcbe4762b3 | |||
| e750adcc94 |
@@ -6,6 +6,7 @@ import com.ai.da.common.context.UserContext;
|
|||||||
import com.ai.da.common.security.config.SecurityProperties;
|
import com.ai.da.common.security.config.SecurityProperties;
|
||||||
import com.ai.da.common.security.jwt.JWTTokenHelper;
|
import com.ai.da.common.security.jwt.JWTTokenHelper;
|
||||||
import com.ai.da.common.utils.LocalCacheUtils;
|
import com.ai.da.common.utils.LocalCacheUtils;
|
||||||
|
import com.ai.da.common.utils.RedisUtil;
|
||||||
import com.ai.da.common.utils.MultiReadHttpServletRequest;
|
import com.ai.da.common.utils.MultiReadHttpServletRequest;
|
||||||
import com.ai.da.common.utils.MultiReadHttpServletResponse;
|
import com.ai.da.common.utils.MultiReadHttpServletResponse;
|
||||||
import com.ai.da.common.utils.RequestInfoUtil;
|
import com.ai.da.common.utils.RequestInfoUtil;
|
||||||
@@ -40,6 +41,8 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
|||||||
private JWTTokenHelper jwtTokenHelper;
|
private JWTTokenHelper jwtTokenHelper;
|
||||||
@Resource
|
@Resource
|
||||||
private SecurityProperties properties;
|
private SecurityProperties properties;
|
||||||
|
@Resource
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
private static final List<String> FILTER_URL =
|
private static final List<String> FILTER_URL =
|
||||||
Arrays.asList("/favicon.ico", "/doc.html", "/swagger-ui.html",
|
Arrays.asList("/favicon.ico", "/doc.html", "/swagger-ui.html",
|
||||||
@@ -132,12 +135,19 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
|||||||
UserContext.delete();
|
UserContext.delete();
|
||||||
//存取用户信息到缓存
|
//存取用户信息到缓存
|
||||||
UserContext.setUserHolder(principal);
|
UserContext.setUserHolder(principal);
|
||||||
//校验token
|
// 校验 token:先查本地缓存,再查 Redis,保证服务重启后仍然有效
|
||||||
String cacheToken = LocalCacheUtils.getTokenCache(String.valueOf(principal.getId()));
|
String userIdStr = String.valueOf(principal.getId());
|
||||||
|
String cacheToken = LocalCacheUtils.getTokenCache(userIdStr);
|
||||||
|
|
||||||
if(StringUtils.isEmpty(cacheToken)){
|
if (StringUtils.isEmpty(cacheToken)) {
|
||||||
// throw new RuntimeException("TOKEN已过期,请重新登录!");
|
// 本地缓存为空时,尝试从 Redis 读取
|
||||||
throw new TokenMissingOrExpiredException("TOKEN已过期,请重新登录!(local cache empty)");
|
cacheToken = redisUtil.getLoginToken(principal.getId());
|
||||||
|
if (StringUtils.isEmpty(cacheToken)) {
|
||||||
|
// throw new RuntimeException("TOKEN已过期,请重新登录!");
|
||||||
|
throw new TokenMissingOrExpiredException("TOKEN已过期,请重新登录!(cache & redis empty)");
|
||||||
|
}
|
||||||
|
// 将 Redis 中的 token 回填到本地缓存,减少后续 Redis 访问
|
||||||
|
LocalCacheUtils.setTokenCache(userIdStr, cacheToken);
|
||||||
}
|
}
|
||||||
if(!cacheToken.equals(jwtToken) ){
|
if(!cacheToken.equals(jwtToken) ){
|
||||||
// throw new RuntimeException("TOKEN已过期,请重新登录!");
|
// throw new RuntimeException("TOKEN已过期,请重新登录!");
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class SubscriptionReminderTask {
|
|||||||
REMINDER_DAYS_CONFIG.put("year", 14);
|
REMINDER_DAYS_CONFIG.put("year", 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 9 * * ?")
|
// @Scheduled(cron = "0 0 9 * * ?")
|
||||||
public void subscriptionReminder() {
|
public void subscriptionReminder() {
|
||||||
// 获取所有需要通知的订阅
|
// 获取所有需要通知的订阅
|
||||||
List<SubscriptionInfo> subscriptionInfos = getDueSubscriptions();
|
List<SubscriptionInfo> subscriptionInfos = getDueSubscriptions();
|
||||||
@@ -97,7 +97,7 @@ public class SubscriptionReminderTask {
|
|||||||
return subscriptionInfoMapper.selectList(qw);
|
return subscriptionInfoMapper.selectList(qw);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 9 * * ?")
|
// @Scheduled(cron = "0 0 9 * * ?")
|
||||||
public void trialReminder() {
|
public void trialReminder() {
|
||||||
// 今天的 00:00:00 和 23:59:59
|
// 今天的 00:00:00 和 23:59:59
|
||||||
LocalDateTime startOfDay = LocalDateTime.now().toLocalDate().atStartOfDay();
|
LocalDateTime startOfDay = LocalDateTime.now().toLocalDate().atStartOfDay();
|
||||||
|
|||||||
@@ -34,6 +34,11 @@ public class RedisUtil {
|
|||||||
private RedisTemplate<String, String> redisTemplate;
|
private RedisTemplate<String, String> redisTemplate;
|
||||||
|
|
||||||
public final static String FLUX_POLLING_URL = "Flux:";
|
public final static String FLUX_POLLING_URL = "Flux:";
|
||||||
|
/**
|
||||||
|
* 登录 token 在 Redis 中的前缀:
|
||||||
|
* 最终 key 结构为 login:token:{userId}
|
||||||
|
*/
|
||||||
|
public final static String LOGIN_TOKEN_KEY = "login:token:";
|
||||||
|
|
||||||
public Boolean hasKey(String key){
|
public Boolean hasKey(String key){
|
||||||
return redisTemplate.hasKey(key);
|
return redisTemplate.hasKey(key);
|
||||||
@@ -186,6 +191,40 @@ public class RedisUtil {
|
|||||||
redisTemplate.delete(key);
|
redisTemplate.delete(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存登录 token
|
||||||
|
*
|
||||||
|
* @param userId 用户 ID
|
||||||
|
* @param token token 字符串
|
||||||
|
* @param expireMillis 过期时间(毫秒,通常与 JWT 保持一致)
|
||||||
|
*/
|
||||||
|
public void setLoginToken(Long userId, String token, long expireMillis) {
|
||||||
|
if (expireMillis <= 0) {
|
||||||
|
// 不设置过期时间,直到手动删除(不推荐)
|
||||||
|
addToString(LOGIN_TOKEN_KEY + userId, token);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long expireSeconds = expireMillis / 1000;
|
||||||
|
if (expireSeconds <= 0) {
|
||||||
|
expireSeconds = 1;
|
||||||
|
}
|
||||||
|
addToString(LOGIN_TOKEN_KEY + userId, token, expireSeconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取登录 token
|
||||||
|
*/
|
||||||
|
public String getLoginToken(Long userId) {
|
||||||
|
return getFromString(LOGIN_TOKEN_KEY + userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除登录 token
|
||||||
|
*/
|
||||||
|
public void deleteLoginToken(Long userId) {
|
||||||
|
removeFromString(LOGIN_TOKEN_KEY + userId);
|
||||||
|
}
|
||||||
|
|
||||||
public final static String PORTFOLIO_LIKE_KEY = "portfolio:like:";
|
public final static String PORTFOLIO_LIKE_KEY = "portfolio:like:";
|
||||||
|
|
||||||
public void likePost(Long portfolioId, Long userId) {
|
public void likePost(Long portfolioId, Long userId) {
|
||||||
|
|||||||
@@ -114,8 +114,8 @@ public class SendRequestUtil {
|
|||||||
|
|
||||||
public String sendFluxPost(String url, String requestBodyStr) {
|
public String sendFluxPost(String url, String requestBodyStr) {
|
||||||
// 尝试两个API key
|
// 尝试两个API key
|
||||||
String[] apiKeys = {"d447a0ac-2291-4f1c-9a36-f7614c385989",
|
String[] apiKeys = {"84e8f5d5-b0b3-49aa-b244-ab7ba27e7ae7",
|
||||||
"84e8f5d5-b0b3-49aa-b244-ab7ba27e7ae7"};
|
"d447a0ac-2291-4f1c-9a36-f7614c385989"};
|
||||||
boolean[] notified = {false, false}; // 记录是否已发送过不足提醒
|
boolean[] notified = {false, false}; // 记录是否已发送过不足提醒
|
||||||
|
|
||||||
for (int i = 0; i < apiKeys.length; i++) {
|
for (int i = 0; i < apiKeys.length; i++) {
|
||||||
@@ -140,22 +140,9 @@ public class SendRequestUtil {
|
|||||||
if (status == 402 || status == 403) {
|
if (status == 402 || status == 403) {
|
||||||
if (!notified[i]) {
|
if (!notified[i]) {
|
||||||
SendEmailUtil.commonExceptionReminder(
|
SendEmailUtil.commonExceptionReminder(
|
||||||
"Flux账户积分不足,flux生成任务失败",
|
"Flux账户积分不足,flux生成任务失败。(key:)" + apiKeys[i],
|
||||||
new String[]{"xupei3360@163.com"}
|
new String[]{"xupei3360@163.com", "fangjianliao@aidlab.hk", "investigation@aidlab.hk"}
|
||||||
);
|
);
|
||||||
log.info("发送给xupei3360@163.com");
|
|
||||||
|
|
||||||
SendEmailUtil.commonExceptionReminder(
|
|
||||||
"Flux账户积分不足,flux生成任务失败",
|
|
||||||
new String[]{"fangjianliao@aidlab.hk"}
|
|
||||||
);
|
|
||||||
log.info("发送给fangjianliao@aidlab.hk");
|
|
||||||
|
|
||||||
SendEmailUtil.commonExceptionReminder(
|
|
||||||
"Flux账户积分不足,flux生成任务失败",
|
|
||||||
new String[]{"investigation@aidlab.hk"}
|
|
||||||
);
|
|
||||||
log.info("发送给investigation@aidlab.hk");
|
|
||||||
notified[i] = true;
|
notified[i] = true;
|
||||||
}
|
}
|
||||||
continue; // 尝试下一个key
|
continue; // 尝试下一个key
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
|||||||
import com.ai.da.mapper.primary.entity.Notification;
|
import com.ai.da.mapper.primary.entity.Notification;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -20,5 +21,5 @@ public interface NotificationMapper extends CommonMapper<Notification> {
|
|||||||
|
|
||||||
void setPersonalNotificationAllRead(String type, Long receiverId, LocalDateTime time);
|
void setPersonalNotificationAllRead(String type, Long receiverId, LocalDateTime time);
|
||||||
|
|
||||||
List<Long> getUnreadSysNotification(Long accountId);
|
List<Long> getUnreadSysNotification(Long accountId, Date createTime);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,6 +132,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
@Resource
|
@Resource
|
||||||
private RedisUtil redisUtil;
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private com.ai.da.common.security.config.SecurityProperties securityProperties;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private UserFollowService userFollowService;
|
private UserFollowService userFollowService;
|
||||||
|
|
||||||
@@ -344,7 +347,11 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
principal.setLanguage(account.getLanguage());
|
principal.setLanguage(account.getLanguage());
|
||||||
principal.setCountry(account.getCountry());
|
principal.setCountry(account.getCountry());
|
||||||
String token2 = jwtTokenHelper.createToken(principal);
|
String token2 = jwtTokenHelper.createToken(principal);
|
||||||
|
// 本地 JVM 缓存(适配旧逻辑)
|
||||||
LocalCacheUtils.setTokenCache(String.valueOf(account.getId()), token2);
|
LocalCacheUtils.setTokenCache(String.valueOf(account.getId()), token2);
|
||||||
|
// 同步写入 Redis,重启后仍然可用
|
||||||
|
long jwtExpiration = securityProperties.getJwtExpiration();
|
||||||
|
redisUtil.setLoginToken(account.getId(), token2, jwtExpiration);
|
||||||
return token2;
|
return token2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,21 +607,25 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean logout(AccountLogoutDTO accountLogoutDTO) {
|
public Boolean logout(AccountLogoutDTO accountLogoutDTO) {
|
||||||
//jwt本身失效比较难做 统一用缓存实现 删除缓存就失效
|
// jwt 本身失效比较难做,统一用缓存实现:删除缓存即失效
|
||||||
String token = LocalCacheUtils.getTokenCache(String.valueOf(accountLogoutDTO.getUserId()));
|
String userIdStr = String.valueOf(accountLogoutDTO.getUserId());
|
||||||
if (StringUtils.isNotBlank(token)) {
|
LocalCacheUtils.delTokenCache(userIdStr);
|
||||||
LocalCacheUtils.delTokenCache(String.valueOf(accountLogoutDTO.getUserId()));
|
// 同时删除 Redis 中的 token,防止服务重启后仍然有效
|
||||||
}
|
redisUtil.deleteLoginToken(accountLogoutDTO.getUserId());
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean isLogin(AccountLogoutDTO accountLogoutDTO) {
|
public Boolean isLogin(AccountLogoutDTO accountLogoutDTO) {
|
||||||
String token = LocalCacheUtils.getTokenCache(String.valueOf(accountLogoutDTO.getUserId()));
|
String userIdStr = String.valueOf(accountLogoutDTO.getUserId());
|
||||||
|
// 先查本地缓存
|
||||||
|
String token = LocalCacheUtils.getTokenCache(userIdStr);
|
||||||
if (StringUtils.isNotBlank(token)) {
|
if (StringUtils.isNotBlank(token)) {
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
return Boolean.FALSE;
|
// 本地没有时,再查 Redis,保证服务重启后也能判断登录状态
|
||||||
|
String redisToken = redisUtil.getLoginToken(accountLogoutDTO.getUserId());
|
||||||
|
return StringUtils.isNotBlank(redisToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -812,6 +823,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
if (StringUtils.isNotBlank(token)) {
|
if (StringUtils.isNotBlank(token)) {
|
||||||
LocalCacheUtils.delTokenCache(String.valueOf(accountDelete.getId()));
|
LocalCacheUtils.delTokenCache(String.valueOf(accountDelete.getId()));
|
||||||
}
|
}
|
||||||
|
// 删除 Redis 中对应的登录 token
|
||||||
|
redisUtil.deleteLoginToken(accountDelete.getId());
|
||||||
if (!userName.equals(userToBeUpdate.getUserName())) {
|
if (!userName.equals(userToBeUpdate.getUserName())) {
|
||||||
// accountMapper.deleteById(accountDelete);
|
// accountMapper.deleteById(accountDelete);
|
||||||
log.info("排查用户被删除原因:deleteNoLoginRequired,true, 删除用户(改为降为游客)");
|
log.info("排查用户被删除原因:deleteNoLoginRequired,true, 删除用户(改为降为游客)");
|
||||||
@@ -1065,6 +1078,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
if (StringUtils.isNotBlank(token)) {
|
if (StringUtils.isNotBlank(token)) {
|
||||||
LocalCacheUtils.delTokenCache(String.valueOf(account.getId()));
|
LocalCacheUtils.delTokenCache(String.valueOf(account.getId()));
|
||||||
}
|
}
|
||||||
|
// 删除 Redis 中对应的登录 token
|
||||||
|
redisUtil.deleteLoginToken(account.getId());
|
||||||
// accountMapper.deleteById(account.getId());
|
// accountMapper.deleteById(account.getId());
|
||||||
log.info("排查用户被删除原因:deleteNoLoginRequiredNew,删除用户(改为降为游客)");
|
log.info("排查用户被删除原因:deleteNoLoginRequiredNew,删除用户(改为降为游客)");
|
||||||
accountMapper.toVisitor(account.getId());
|
accountMapper.toVisitor(account.getId());
|
||||||
|
|||||||
@@ -1203,6 +1203,9 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
* @param modelName advanced high normal
|
* @param modelName advanced high normal
|
||||||
*/
|
*/
|
||||||
private HashMap<String, String> chooseModelAndPrompt(GenerateThroughImageTextDTO generateDTO, String modelName) {
|
private HashMap<String, String> chooseModelAndPrompt(GenerateThroughImageTextDTO generateDTO, String modelName) {
|
||||||
|
if (StringUtil.isNullOrEmpty(modelName)){
|
||||||
|
throw new BusinessException("system error");
|
||||||
|
}
|
||||||
HashMap<String, String> modelAndPromptMap = new HashMap<>();
|
HashMap<String, String> modelAndPromptMap = new HashMap<>();
|
||||||
boolean isUseImage;
|
boolean isUseImage;
|
||||||
if (Objects.isNull(generateDTO.getCollectionElementId())
|
if (Objects.isNull(generateDTO.getCollectionElementId())
|
||||||
@@ -1218,7 +1221,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
String style = generateDTO.getText().substring(0, firstCommaIndex).trim();
|
String style = generateDTO.getText().substring(0, firstCommaIndex).trim();
|
||||||
|
|
||||||
String prompt = generateDTO.getText().substring(firstCommaIndex + 1).trim();
|
String prompt = generateDTO.getText().substring(firstCommaIndex + 1).trim();
|
||||||
prompt = getPrintboardPrompt(style, prompt);
|
prompt = getPrintboardPrompt(style, prompt,modelName);
|
||||||
modelAndPromptMap.put(ModelConstants.PROMPT, prompt);
|
modelAndPromptMap.put(ModelConstants.PROMPT, prompt);
|
||||||
|
|
||||||
|
|
||||||
@@ -1239,7 +1242,14 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (ModelConstants.MOODBOARD.equals(generateDTO.getLevel1Type())) {
|
} else if (ModelConstants.MOODBOARD.equals(generateDTO.getLevel1Type())) {
|
||||||
String prompt = generateDTO.getText() + "high-resolution, ultra-detailed, realistic textures, perfect anatomy, cinematic lighting, 8k render, editorial photography style";
|
String userInput = generateDTO.getText();
|
||||||
|
String systemPrompt = "high-resolution, ultra-detailed, realistic textures, cinematic lighting, 8k render, editorial photography style";
|
||||||
|
String prompt;
|
||||||
|
if (userInput == null || userInput.trim().isEmpty()) {
|
||||||
|
throw new BusinessException("prompt null");
|
||||||
|
} else {
|
||||||
|
prompt = "Theme: " + userInput.trim() + "\nRequirement: " + systemPrompt;
|
||||||
|
}
|
||||||
modelAndPromptMap.put(ModelConstants.PROMPT, prompt);
|
modelAndPromptMap.put(ModelConstants.PROMPT, prompt);
|
||||||
|
|
||||||
if (ModelConstants.ADVANCED.equals(modelName)) {
|
if (ModelConstants.ADVANCED.equals(modelName)) {
|
||||||
@@ -1560,19 +1570,40 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getPrintboardPrompt(String style, String prompt) {
|
private String getPrintboardPrompt(String style, String userInput, String modelName) {
|
||||||
|
String systemPrompt = null;
|
||||||
|
String prompt;
|
||||||
|
|
||||||
if ("Painting Style".equals(style)) {
|
if ("Painting Style".equals(style)) {
|
||||||
prompt = "1.Requirements: Create a seamless, tiling fashion printboard pattern for apparel. The output must be stylish, contemporary, and suitable for real garment printing. Design pattern, seamless, highly detailed, elegant composition, visually balanced, professional textile print\n" +
|
if (ModelConstants.ADVANCED.equals(modelName)) {
|
||||||
"2.Core Theme: " + prompt + "\n" +
|
systemPrompt = "Tileable seamless pattern, elegant composition, visually balanced, Light watercolor, Giplie Studio (style) pattern with even color field background, high-quality digital print, zero perspective depth, harmonious visual balance, consistent color tone.";
|
||||||
"3.Style: painting_style-The painting style refers to the overall approach, techniques, and artistic philosophy used in the artwork. For fashion designs that will be applied to printboards, it is important to define the unique stylistic elements that would translate well into wearable patterns.";
|
} else if (ModelConstants.HIGH.equals(modelName)) {
|
||||||
|
systemPrompt = "Design pattern, seamless, highly detailed, elegant composition, visually balanced. \n" +
|
||||||
|
"Painting style: traditional painting, hand-painted, brush strokes.";
|
||||||
|
}
|
||||||
} else if ("Illustration Style".equals(style)) {
|
} else if ("Illustration Style".equals(style)) {
|
||||||
prompt = "1.Requirements: Create a seamless, tiling fashion printboard pattern for apparel. The output must be stylish, contemporary, and suitable for real garment printing. Design pattern, seamless, highly detailed, elegant composition, visually balanced, professional textile print\n" +
|
if (ModelConstants.ADVANCED.equals(modelName)) {
|
||||||
"2.Core Theme: " + prompt + "\n" +
|
systemPrompt = "Tileable seamless pattern, elegant composition, visually balanced, flat graphic, clean lines pattern with even color field background, high-quality digital print, zero perspective depth, harmonious visual balance, consistent color tone. ";
|
||||||
"3.Style: illustration_style-Illustration style focuses on the visual storytellingaspect, often used to depict narratives, characters, or thematic concepts. Forfashion, this style can introduce vivid and artistic interpretations, often aligned with specific themes.";
|
} else if (ModelConstants.HIGH.equals(modelName)) {
|
||||||
|
systemPrompt = "Design pattern, seamless, highly detailed, elegant composition, visually balanced. \n" +
|
||||||
|
"Illustration Style: flat graphic, clean lines.";
|
||||||
|
}
|
||||||
} else if ("Real Style".equals(style)) {
|
} else if ("Real Style".equals(style)) {
|
||||||
prompt = "1.Requirements: Create a seamless, tiling fashion printboard pattern for apparel. The output must be stylish, contemporary, and suitable for real garment printing. Design pattern, seamless, highly detailed, elegant composition, visually balanced, professional textile print\n" +
|
if (ModelConstants.ADVANCED.equals(modelName)) {
|
||||||
"2.Core Theme: " + prompt + "\n" +
|
systemPrompt = "Tileable seamless pattern, even color field background, photorealistic style pattern, high-quality digital print, zero perspective depth, harmonious visual balance, consistent color tone. ";
|
||||||
"3.Style: real_style-Real style in fashion is all about authenticity. It featuresnatural fabrics, simple cuts that mirror real life silhouettes, and colors inspired bythe everyday world, exuding a down-to-earth and genuine charm.";
|
} else if (ModelConstants.HIGH.equals(modelName)) {
|
||||||
|
systemPrompt = "Design pattern, seamless, highly detailed, elegant composition, visually balanced. \n" +
|
||||||
|
"Flat textile pattern printed directly on fabric surface, no three-dimensional objects, no items placed on cloth. \n" +
|
||||||
|
"Real style: fabric print, realistic woven/printed pattern, detailed surface pattern only";
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
throw new BusinessException("style error:"+ style);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userInput == null || userInput.trim().isEmpty()) {
|
||||||
|
throw new BusinessException("prompt null");
|
||||||
|
} else {
|
||||||
|
prompt = "Theme: " + userInput.trim() + "\nRequirement: " + systemPrompt;
|
||||||
}
|
}
|
||||||
return prompt;
|
return prompt;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
|||||||
throw new BusinessException("type.cannot.be.empty");
|
throw new BusinessException("type.cannot.be.empty");
|
||||||
}
|
}
|
||||||
Long accountId = UserContext.getUserHolder().getId();
|
Long accountId = UserContext.getUserHolder().getId();
|
||||||
|
Account account = accountService.getById(accountId);
|
||||||
// 查动态
|
// 查动态
|
||||||
if (!StringUtils.isNullOrEmpty(getNotificationDTO.getType()) && getNotificationDTO.getType().equals("newPosted")) {
|
if (!StringUtils.isNullOrEmpty(getNotificationDTO.getType()) && getNotificationDTO.getType().equals("newPosted")) {
|
||||||
return getNewPosted(accountId, getNotificationDTO.getPage(), getNotificationDTO.getSize());
|
return getNewPosted(accountId, getNotificationDTO.getPage(), getNotificationDTO.getSize());
|
||||||
@@ -92,6 +93,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
|||||||
|
|
||||||
if (getNotificationDTO.getType().equals("system")) {
|
if (getNotificationDTO.getType().equals("system")) {
|
||||||
queryWrapper.lambda().eq(Notification::getType, "system")
|
queryWrapper.lambda().eq(Notification::getType, "system")
|
||||||
|
.gt(Notification::getCreateTime, account.getCreateDate())
|
||||||
.and(wrapper -> wrapper
|
.and(wrapper -> wrapper
|
||||||
.isNull(Notification::getReceiverId)
|
.isNull(Notification::getReceiverId)
|
||||||
.or()
|
.or()
|
||||||
@@ -103,7 +105,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
|||||||
|
|
||||||
Page<Notification> notificationPage = baseMapper.selectPage(new Page<>(getNotificationDTO.getPage(), getNotificationDTO.getSize()), queryWrapper);
|
Page<Notification> notificationPage = baseMapper.selectPage(new Page<>(getNotificationDTO.getPage(), getNotificationDTO.getSize()), queryWrapper);
|
||||||
|
|
||||||
List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId);
|
List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId, account.getCreateDate());
|
||||||
IPage<NotificationVO> convert = notificationPage.convert(o -> {
|
IPage<NotificationVO> convert = notificationPage.convert(o -> {
|
||||||
NotificationVO notificationVO = CopyUtil.copyObject(o, NotificationVO.class);
|
NotificationVO notificationVO = CopyUtil.copyObject(o, NotificationVO.class);
|
||||||
Account senderAccount = accountService.getById(notificationVO.getSenderId());
|
Account senderAccount = accountService.getById(notificationVO.getSenderId());
|
||||||
@@ -247,9 +249,11 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
|||||||
|
|
||||||
private Long getUnreadSystemNotification(Long receiverId) {
|
private Long getUnreadSystemNotification(Long receiverId) {
|
||||||
// Long accountId = UserContext.getUserHolder().getId();
|
// Long accountId = UserContext.getUserHolder().getId();
|
||||||
|
Account account = accountService.getById(receiverId);
|
||||||
// 计算总的系统通知数量
|
// 计算总的系统通知数量
|
||||||
QueryWrapper<Notification> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Notification> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.lambda().eq(Notification::getType, "system")
|
queryWrapper.lambda().eq(Notification::getType, "system")
|
||||||
|
.gt(Notification::getCreateTime, account.getCreateDate())
|
||||||
.and(wrapper -> wrapper
|
.and(wrapper -> wrapper
|
||||||
.isNull(Notification::getReceiverId)
|
.isNull(Notification::getReceiverId)
|
||||||
.or()
|
.or()
|
||||||
@@ -302,6 +306,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
|||||||
// 一键已读
|
// 一键已读
|
||||||
public void setReadAll(String type) {
|
public void setReadAll(String type) {
|
||||||
Long accountId = UserContext.getUserHolder().getId();
|
Long accountId = UserContext.getUserHolder().getId();
|
||||||
|
Account account = accountService.getById(accountId);
|
||||||
// 指定某个用户的某种类型的数据,将未读数据全部已读
|
// 指定某个用户的某种类型的数据,将未读数据全部已读
|
||||||
if (!type.equals("system")) {
|
if (!type.equals("system")) {
|
||||||
// 个人消息已读
|
// 个人消息已读
|
||||||
@@ -309,7 +314,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
|||||||
} else {
|
} else {
|
||||||
// 系统消息已读
|
// 系统消息已读
|
||||||
// 1、先确定当前用户未读的系统消息有哪些
|
// 1、先确定当前用户未读的系统消息有哪些
|
||||||
List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId);
|
List<Long> unreadSysNotificationIds = baseMapper.getUnreadSysNotification(accountId, account.getCreateDate());
|
||||||
// 2、将未读的设为已读
|
// 2、将未读的设为已读
|
||||||
if (!unreadSysNotificationIds.isEmpty()) setReadStatusSystem(unreadSysNotificationIds);
|
if (!unreadSysNotificationIds.isEmpty()) setReadStatusSystem(unreadSysNotificationIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ spring.security.jwtExpiration=604800000
|
|||||||
spring.security.ignorePaths=/,/favicon.ico,/doc.html,/webjars/**,/swagger-resources,/v2/api-docs,\
|
spring.security.ignorePaths=/,/favicon.ico,/doc.html,/webjars/**,/swagger-resources,/v2/api-docs,\
|
||||||
/api/account/**,/api/element/**,/api/python/**,/api/design/**,/api/history/**,/api/library/**,/api/third/party/**,/api/generate/**,/api/workspace/**,/api/classification/**,\
|
/api/account/**,/api/element/**,/api/python/**,/api/design/**,/api/history/**,/api/library/**,/api/third/party/**,/api/generate/**,/api/workspace/**,/api/classification/**,\
|
||||||
/api/product/**,/api/ali-pay/**,/api/order-info/**,/api/paypal/**,/api/credits/**,/api/inquiry/**,/api/tasks/**,/api/python/prepareForSR,/api/alipay-hk/**,/api/portfolio/**,\
|
/api/product/**,/api/ali-pay/**,/api/order-info/**,/api/paypal/**,/api/credits/**,/api/inquiry/**,/api/tasks/**,/api/python/prepareForSR,/api/alipay-hk/**,/api/portfolio/**,\
|
||||||
/api/stripe/**,/api/message/**,/api/tags/**,/notification/**,/api/affiliate/**,/api/project/**,/api/llm/**
|
/api/stripe/**,/api/message/**,/api/tags/**,/notification/**,/api/affiliate/**,/api/project/**,/api/llm/**, /api/subscription_plan/**
|
||||||
spring.security.authApi=/auth/login
|
spring.security.authApi=/auth/login
|
||||||
|
|
||||||
|
|
||||||
@@ -71,15 +71,15 @@ spring.rabbitmq.username=rabbit
|
|||||||
spring.rabbitmq.password=123456
|
spring.rabbitmq.password=123456
|
||||||
spring.rabbitmq.virtual-host=/
|
spring.rabbitmq.virtual-host=/
|
||||||
|
|
||||||
spring.redis.host=172.31.11.32
|
spring.data.redis.host=172.31.11.32
|
||||||
#spring.redis.host=18.167.251.121
|
#spring.data.redis.host=18.167.251.121
|
||||||
spring.redis.port=6379
|
spring.data.redis.port=6379
|
||||||
spring.redis.database=2
|
spring.data.redis.database=2
|
||||||
spring.redis.password=Aidlab
|
spring.data.redis.password=Aidlab
|
||||||
spring.redis.lettuce.pool.max-active=8
|
spring.data.redis.lettuce.pool.max-active=8
|
||||||
spring.redis.lettuce.pool.max-idle=8
|
spring.data.redis.lettuce.pool.max-idle=8
|
||||||
spring.redis.lettuce.pool.min-idle=0
|
spring.data.redis.lettuce.pool.min-idle=0
|
||||||
spring.redis.lettuce.pool.max-wait=5
|
spring.data.redis.lettuce.pool.max-wait=5
|
||||||
|
|
||||||
redis.key.orderForGenerate=OrderForGenerate
|
redis.key.orderForGenerate=OrderForGenerate
|
||||||
redis.key.generateCancelSet=GenerateCancelSet
|
redis.key.generateCancelSet=GenerateCancelSet
|
||||||
|
|||||||
@@ -60,7 +60,8 @@
|
|||||||
SELECT system_notification_id
|
SELECT system_notification_id
|
||||||
FROM `t_sys_notification_read_status`
|
FROM `t_sys_notification_read_status`
|
||||||
WHERE account_id = #{accountId}
|
WHERE account_id = #{accountId}
|
||||||
)
|
)
|
||||||
|
AND create_time > #{createTime}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user