教代会意见:
撰写建议-> 建议人根据讨论组代表团来筛选
This commit is contained in:
+106
@@ -32,11 +32,13 @@ import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -209,6 +211,84 @@ public class OpinionWriteController {
|
||||
return Result.success(sql.getObject(Record.class));
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("opinion.write")
|
||||
public Result suggestUserOptions(@Valid String sessionId, @Valid String discussionGroupId, String keyword) {
|
||||
Teacher_congress_discussion_group discussionGroup = dao.fetch(Teacher_congress_discussion_group.class,
|
||||
Cnd.where("id", "=", discussionGroupId).and("delFlag", "=", false));
|
||||
if (discussionGroup == null) {
|
||||
return Result.success(new ArrayList<>());
|
||||
}
|
||||
List<String> delegationCodes = parseJsonArray(discussionGroup.getDelegationCodes());
|
||||
if (delegationCodes.isEmpty()) {
|
||||
return Result.success(new ArrayList<>());
|
||||
}
|
||||
// Discussion groups store delegation codes, so convert them to delegation ids under the current session before filtering delegates.
|
||||
Sql delegationSql = Sqls.create("""
|
||||
SELECT
|
||||
id
|
||||
FROM teacher_congress_delegation
|
||||
$condition
|
||||
""");
|
||||
Cnd delegationCnd = Cnd.NEW();
|
||||
delegationCnd.and("sessionId", "=", sessionId);
|
||||
delegationCnd.and("code", "in", delegationCodes);
|
||||
delegationCnd.and("delFlag", "=", false);
|
||||
delegationSql.setCondition(delegationCnd);
|
||||
delegationSql.setCallback(Sqls.callback.records());
|
||||
dao.execute(delegationSql);
|
||||
List<Record> delegationRecords = delegationSql.getList(Record.class);
|
||||
List<String> delegationIds = new ArrayList<>();
|
||||
for (Record delegationRecord : delegationRecords) {
|
||||
if (StrUtil.isNotBlank(delegationRecord.getString("id"))) {
|
||||
delegationIds.add(delegationRecord.getString("id"));
|
||||
}
|
||||
}
|
||||
if (delegationIds.isEmpty()) {
|
||||
return Result.success(new ArrayList<>());
|
||||
}
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT DISTINCT
|
||||
tcd.userId AS id,
|
||||
tcd.userId,
|
||||
tcd.userName AS username,
|
||||
tcd.loginName AS loginname,
|
||||
tcd.mobile,
|
||||
tcd.unitId,
|
||||
tcd.unitName,
|
||||
tcd.delegationId
|
||||
FROM teacher_congress_delegate tcd
|
||||
$condition
|
||||
ORDER BY tcd.loginName ASC, tcd.userName ASC
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("tcd.sessionId", "=", sessionId);
|
||||
cnd.and("tcd.delegationId", "in", delegationIds);
|
||||
cnd.and("tcd.delFlag", "=", false);
|
||||
if (StrUtil.isNotBlank(keyword)) {
|
||||
cnd.and(Cnd.exps("tcd.userName", "like", "%" + keyword + "%")
|
||||
.or("tcd.loginName", "like", "%" + keyword + "%"));
|
||||
}
|
||||
cnd.limit(1, 50);
|
||||
sql.setCondition(cnd);
|
||||
sql.setCallback(Sqls.callback.records());
|
||||
dao.execute(sql);
|
||||
List<Record> records = sql.getList(Record.class);
|
||||
List<NutMap> result = new ArrayList<>();
|
||||
for (Record record : records) {
|
||||
result.add(NutMap.NEW()
|
||||
.addv("id", record.getString("id"))
|
||||
.addv("userId", record.getString("userId"))
|
||||
.addv("username", record.getString("username"))
|
||||
.addv("loginname", record.getString("loginname"))
|
||||
.addv("mobile", record.getString("mobile"))
|
||||
.addv("unitId", record.getString("unitId"))
|
||||
.addv("unitName", record.getString("unitName"))
|
||||
.addv("delegationId", record.getString("delegationId")));
|
||||
}
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("opinion.write")
|
||||
@ApiOperation("查询代表所属代表团")
|
||||
@@ -222,4 +302,30 @@ public class OpinionWriteController {
|
||||
);
|
||||
return Result.success().addData(delegate != null ? delegate.getDelegationId() : null);
|
||||
}
|
||||
|
||||
private List<String> parseJsonArray(String json) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if (StrUtil.isBlank(json)) {
|
||||
return result;
|
||||
}
|
||||
String content = StrUtil.trim(json);
|
||||
if (content.startsWith("[")) {
|
||||
content = content.substring(1);
|
||||
}
|
||||
if (content.endsWith("]")) {
|
||||
content = content.substring(0, content.length() - 1);
|
||||
}
|
||||
if (StrUtil.isBlank(content)) {
|
||||
return result;
|
||||
}
|
||||
for (String item : content.split(",")) {
|
||||
String value = StrUtil.trim(item);
|
||||
value = StrUtil.removePrefix(value, "\"");
|
||||
value = StrUtil.removeSuffix(value, "\"");
|
||||
if (StrUtil.isNotBlank(value)) {
|
||||
result.add(value);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
-1
@@ -125,7 +125,6 @@ public class TeacherCongressDiscussionGroupController {
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("tc.discussion.group")
|
||||
public Result recorderOptions(String keyword) {
|
||||
Cnd cnd = Cnd.NEW();
|
||||
if (StrUtil.isNotBlank(keyword)) {
|
||||
|
||||
Reference in New Issue
Block a user