|
@@ -104,10 +104,12 @@ public class NewsService implements INewsService {
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
// --- 情况 B:前端传了具体的用户ID列表 ---
|
|
// --- 情况 B:前端传了具体的用户ID列表 ---
|
|
|
|
|
+ boolean insertFlag = false;
|
|
|
// 遍历列表,为每个用户插入一条记录
|
|
// 遍历列表,为每个用户插入一条记录
|
|
|
for (String targetUserId : scopeUserIds) {
|
|
for (String targetUserId : scopeUserIds) {
|
|
|
String insertSql= "";
|
|
String insertSql= "";
|
|
|
if(targetUserId.length()>0){
|
|
if(targetUserId.length()>0){
|
|
|
|
|
+ insertFlag = true;
|
|
|
insertSql = "INSERT INTO t_ggfwb (id_, create_by_, create_time_, gong_gao_id_, gong_gao_lei_xing, gong_gao_mu_biao_) " +
|
|
insertSql = "INSERT INTO t_ggfwb (id_, create_by_, create_time_, gong_gao_id_, gong_gao_lei_xing, gong_gao_mu_biao_) " +
|
|
|
"VALUES ('%s', '%s', NOW(), '%s', '%s', '%s')";
|
|
"VALUES ('%s', '%s', NOW(), '%s', '%s', '%s')";
|
|
|
} else {
|
|
} else {
|
|
@@ -120,7 +122,24 @@ public class NewsService implements INewsService {
|
|
|
insertSql = String.format(insertSql, id, currentUserId, newsId, newsType, targetUserId);
|
|
insertSql = String.format(insertSql, id, currentUserId, newsId, newsType, targetUserId);
|
|
|
commonDao.execute(insertSql);
|
|
commonDao.execute(insertSql);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ // 传具体范围增加当前用户
|
|
|
|
|
+ if(insertFlag){
|
|
|
|
|
+ // 如果当前用户不在列表中,则手动插入一条记录
|
|
|
|
|
+ boolean currentUserExists = false;
|
|
|
|
|
+ for (String uid : scopeUserIds) {
|
|
|
|
|
+ if (currentUserId.equals(uid)) {
|
|
|
|
|
+ currentUserExists = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!currentUserExists) {
|
|
|
|
|
+ String creatorInsertSql = "INSERT INTO t_ggfwb (id_, create_by_, create_time_, gong_gao_id_, gong_gao_lei_xing, gong_gao_mu_biao_) " +
|
|
|
|
|
+ "VALUES ('%s', '%s', NOW(), '%s', '%s', '%s')";
|
|
|
|
|
+ String creatorId = UniqueIdUtil.getId();
|
|
|
|
|
+ creatorInsertSql = String.format(creatorInsertSql, creatorId, currentUserId, newsId, newsType, currentUserId);
|
|
|
|
|
+ commonDao.execute(creatorInsertSql);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
} catch (Exception e){
|
|
} catch (Exception e){
|