教代会意见:
撰写建议-> 建议人根据讨论组代表团来筛选
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)) {
|
||||
|
||||
@@ -37,11 +37,13 @@ const BASIC_FORM = {
|
||||
ref="suggestUserSelectRef"
|
||||
v-model="formData.suggestUserId"
|
||||
style="width: 100%"
|
||||
api="/platform/teacherCongress/discussionGroup/recorderOptions"
|
||||
api="/platform/opinion/write/suggestUserOptions"
|
||||
:api_params="{ sessionId: formData.sessionId, discussionGroupId: formData.delegationId }"
|
||||
api_input_key_name="keyword"
|
||||
:option_list="suggestUserOptions"
|
||||
option_value="id"
|
||||
:option_label_func="(item)=> item.username + ' - ' + item.loginname"
|
||||
:disabled="!formData.delegationId"
|
||||
@change="suggestUserChange"
|
||||
></user-select>
|
||||
</el-form-item>
|
||||
@@ -422,11 +424,20 @@ const BASIC_FORM = {
|
||||
this.formData.createUserLoginName = ""
|
||||
},
|
||||
clearSuggestDelegation() {
|
||||
this.formData.suggestUserId = ""
|
||||
this.formData.suggestUserName = ""
|
||||
this.formData.suggestUserLoginName = ""
|
||||
this.formData.suggestUserDelegationId = ""
|
||||
this.formData.suggestUserDelegationName = ""
|
||||
this.formData.delegationName = ""
|
||||
this.formData.mobile = ""
|
||||
this.formData.unitName = ""
|
||||
this.suggestUserOptions = []
|
||||
},
|
||||
discussionGroupChange(groupId) {
|
||||
discussionGroupChange(groupId, preserveSuggestUser) {
|
||||
if (!preserveSuggestUser) {
|
||||
this.clearSuggestDelegation()
|
||||
}
|
||||
if (!groupId) {
|
||||
this.fillCurrentRecorder()
|
||||
this.formData.discussionGroupName = ""
|
||||
@@ -529,7 +540,7 @@ const BASIC_FORM = {
|
||||
}
|
||||
}
|
||||
if (this.formData.delegationId) {
|
||||
await this.discussionGroupChange(this.formData.delegationId)
|
||||
await this.discussionGroupChange(this.formData.delegationId, true)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user