feat:浦发项目模块迁移-职代会h5端初始化
This commit is contained in:
+373
@@ -0,0 +1,373 @@
|
||||
package com.budwk.app.zhgh.democratic.congress.h5controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckLogin;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.result.Result;
|
||||
import com.budwk.app.web.commons.auth.utils.SecurityUtil;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.random.R;
|
||||
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 java.util.Date;
|
||||
|
||||
@IocBean
|
||||
@At("/platform/h5/congress")
|
||||
@Ok("json:full")
|
||||
public class CongressH5Controller {
|
||||
|
||||
@Inject
|
||||
private Dao dao;
|
||||
|
||||
@At("")
|
||||
@Ok("beetl:/platform/zhghh5/democratic/congress/index.html")
|
||||
@SaCheckLogin
|
||||
public void index() {
|
||||
}
|
||||
|
||||
@At("/materials/list")
|
||||
@Ok("beetl:/platform/zhghh5/democratic/congress/materials/list.html")
|
||||
@SaCheckLogin
|
||||
public void materialsListPage() {
|
||||
}
|
||||
|
||||
@At("/meeting/list")
|
||||
@Ok("beetl:/platform/zhghh5/democratic/congress/meeting/list.html")
|
||||
@SaCheckLogin
|
||||
public void meetingListPage() {
|
||||
}
|
||||
|
||||
@At("/pdf")
|
||||
@Ok("beetl:/platform/zhghh5/democratic/congress/pdf.html")
|
||||
@SaCheckLogin
|
||||
public void pdfPage() {
|
||||
}
|
||||
|
||||
@At("/vote")
|
||||
@Ok("beetl:/platform/zhghh5/democratic/congress/vote.html")
|
||||
@SaCheckLogin
|
||||
public void votePage() {
|
||||
}
|
||||
|
||||
@At("/voted")
|
||||
@Ok("beetl:/platform/zhghh5/democratic/congress/voted.html")
|
||||
@SaCheckLogin
|
||||
public void votedPage() {
|
||||
}
|
||||
|
||||
@At("/repTimes")
|
||||
@SaCheckLogin
|
||||
public Result repTimes(@Param("emplid") String emplid) {
|
||||
String loginName = StrUtil.blankToDefault(emplid, SecurityUtil.getUserLoginname());
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
t.id,
|
||||
t.id AS timeId,
|
||||
t.name,
|
||||
t.year,
|
||||
t.session_id AS sessionId,
|
||||
t.session_name AS sessionName,
|
||||
s.type,
|
||||
r.id AS repId,
|
||||
r.delegation_id AS delegationId,
|
||||
r.delegation_name AS delegationName
|
||||
FROM congress_times t
|
||||
INNER JOIN (
|
||||
SELECT id, time_id, delegation_id, delegation_name
|
||||
FROM congress_rep
|
||||
WHERE emplid = @emplid
|
||||
AND status = 2
|
||||
AND IFNULL(deleted, 0) = 0
|
||||
GROUP BY id, time_id, delegation_id, delegation_name
|
||||
) r ON t.id = r.time_id
|
||||
INNER JOIN congress_sessions s ON t.session_id = s.id
|
||||
WHERE IFNULL(t.deleted, 0) = 0
|
||||
AND IFNULL(s.deleted, 0) = 0
|
||||
ORDER BY t.create_time DESC, t.id DESC
|
||||
""");
|
||||
sql.setParam("emplid", loginName);
|
||||
sql.setCallback(Sqls.callback.maps());
|
||||
dao.execute(sql);
|
||||
return Result.success(sql.getList(NutMap.class));
|
||||
}
|
||||
|
||||
@At("/materialsTypeList")
|
||||
@SaCheckLogin
|
||||
public Result materialsTypeList() {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
SUBSTRING_INDEX(
|
||||
GROUP_CONCAT(
|
||||
id
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN id IN (
|
||||
'congress_type_file_notice',
|
||||
'congress_type_evaluation_vote',
|
||||
'congress_type_issue_vote',
|
||||
'congress_type_vote_notice',
|
||||
'congress_type_prepare_material'
|
||||
) THEN 0
|
||||
ELSE 1
|
||||
END,
|
||||
sort_no ASC,
|
||||
create_time ASC
|
||||
),
|
||||
',',
|
||||
1
|
||||
) AS id,
|
||||
MIN(sort_no) AS sortNo,
|
||||
name,
|
||||
MAX(is_vote) AS isVote
|
||||
FROM congress_materials_type
|
||||
WHERE IFNULL(deleted, 0) = 0
|
||||
GROUP BY name
|
||||
ORDER BY sortNo ASC, name ASC
|
||||
""");
|
||||
sql.setCallback(Sqls.callback.maps());
|
||||
dao.execute(sql);
|
||||
return Result.success(sql.getList(NutMap.class));
|
||||
}
|
||||
|
||||
@At("/materialsList")
|
||||
@SaCheckLogin
|
||||
public Result materialsList(@Param("typeId") String typeId, @Param("timeId") String timeId, @Param("emplid") String emplid) {
|
||||
String loginName = StrUtil.blankToDefault(emplid, SecurityUtil.getUserLoginname());
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
cm.id,
|
||||
cm.session_id AS sessionId,
|
||||
cm.time_id AS timeId,
|
||||
cm.type_id AS typeId,
|
||||
cm.sort_no AS sortNo,
|
||||
cm.name,
|
||||
cm.file_name AS fileName,
|
||||
cm.file_url AS fileUrl,
|
||||
cm.file_type AS fileType,
|
||||
cm.file_size AS fileSize,
|
||||
cm.create_time AS uploadTime,
|
||||
CASE
|
||||
WHEN cvi.id IS NULL THEN NULL
|
||||
WHEN cvr.id IS NOT NULL THEN true
|
||||
ELSE false
|
||||
END AS hasVoted,
|
||||
CASE WHEN cvr.id IS NOT NULL THEN true ELSE false END AS voted
|
||||
FROM congress_materials cm
|
||||
INNER JOIN congress_materials_type cmt ON cm.type_id = cmt.id AND IFNULL(cmt.deleted, 0) = 0
|
||||
LEFT JOIN congress_voting_issue cvi ON cm.id = cvi.materials_id
|
||||
AND IFNULL(cvi.deleted, 0) = 0
|
||||
AND cmt.is_vote = true
|
||||
LEFT JOIN congress_voting_record cvr ON cvi.id = cvr.issue_id
|
||||
AND cvr.emplid = @emplid
|
||||
AND IFNULL(cvr.deleted, 0) = 0
|
||||
WHERE IFNULL(cm.deleted, 0) = 0
|
||||
AND cm.type_id = @typeId
|
||||
AND cm.time_id = @timeId
|
||||
ORDER BY cm.sort_no ASC, cm.create_time DESC
|
||||
""");
|
||||
sql.setParam("typeId", typeId);
|
||||
sql.setParam("timeId", timeId);
|
||||
sql.setParam("emplid", loginName);
|
||||
sql.setCallback(Sqls.callback.maps());
|
||||
dao.execute(sql);
|
||||
return Result.success(sql.getList(NutMap.class));
|
||||
}
|
||||
|
||||
@At("/user/meetingList")
|
||||
@SaCheckLogin
|
||||
public Result userMeetingList(@Param("timeId") String timeId, @Param("emplid") String emplid) {
|
||||
String loginName = StrUtil.blankToDefault(emplid, SecurityUtil.getUserLoginname());
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
m.id,
|
||||
m.meeting_name AS meetingName,
|
||||
m.sign_in_start_time AS signInStartTime,
|
||||
m.sign_in_end_time AS signInEndTime,
|
||||
m.session_id AS sessionId,
|
||||
m.time_id AS timeId,
|
||||
m.remark,
|
||||
(
|
||||
SELECT COUNT(1)
|
||||
FROM congress_sign_in s
|
||||
WHERE s.meeting_id = m.id
|
||||
AND IFNULL(s.deleted, 0) = 0
|
||||
) AS signInCount,
|
||||
si.id AS signInId,
|
||||
si.create_time AS userSignInTime,
|
||||
r.id AS repId
|
||||
FROM congress_sign_in_meeting m
|
||||
LEFT JOIN congress_sign_in si ON m.id = si.meeting_id
|
||||
AND IFNULL(si.deleted, 0) = 0
|
||||
AND si.emplid = @emplid
|
||||
LEFT JOIN congress_rep r ON r.time_id = m.time_id
|
||||
AND r.emplid = @emplid
|
||||
AND IFNULL(r.deleted, 0) = 0
|
||||
WHERE IFNULL(m.deleted, 0) = 0
|
||||
AND m.time_id = @timeId
|
||||
ORDER BY m.sign_in_start_time DESC, m.create_time DESC
|
||||
""");
|
||||
sql.setParam("timeId", timeId);
|
||||
sql.setParam("emplid", loginName);
|
||||
sql.setCallback(Sqls.callback.maps());
|
||||
dao.execute(sql);
|
||||
return Result.success(sql.getList(NutMap.class));
|
||||
}
|
||||
|
||||
@At("/signin")
|
||||
@SaCheckLogin
|
||||
public Result signin(@Param("repId") String repId,
|
||||
@Param("sessionId") String sessionId,
|
||||
@Param("timeId") String timeId,
|
||||
@Param("meetingId") String meetingId) {
|
||||
if (StrUtil.hasBlank(repId, sessionId, timeId, meetingId)) {
|
||||
return Result.error("签到参数不完整");
|
||||
}
|
||||
int count = countBySql("""
|
||||
SELECT COUNT(1)
|
||||
FROM congress_sign_in
|
||||
WHERE rep_id = @repId
|
||||
AND meeting_id = @meetingId
|
||||
AND IFNULL(deleted, 0) = 0
|
||||
""", NutMap.NEW().addv("repId", repId).addv("meetingId", meetingId));
|
||||
if (count > 0) {
|
||||
return Result.success(true);
|
||||
}
|
||||
|
||||
Sql repSql = Sqls.create("""
|
||||
SELECT id, emplid, name, delegation_id AS delegationId
|
||||
FROM congress_rep
|
||||
WHERE id = @repId
|
||||
AND IFNULL(deleted, 0) = 0
|
||||
LIMIT 1
|
||||
""");
|
||||
repSql.setParam("repId", repId);
|
||||
repSql.setCallback(Sqls.callback.map());
|
||||
dao.execute(repSql);
|
||||
NutMap rep = repSql.getObject(NutMap.class);
|
||||
if (rep == null) {
|
||||
return Result.error("未找到代表信息");
|
||||
}
|
||||
|
||||
dao.insert("congress_sign_in", Chain.make("id", R.UU32())
|
||||
.add("session_id", sessionId)
|
||||
.add("time_id", timeId)
|
||||
.add("meeting_id", meetingId)
|
||||
.add("delegation_id", rep.getString("delegationId"))
|
||||
.add("rep_id", repId)
|
||||
.add("emplid", rep.getString("emplid"))
|
||||
.add("name", rep.getString("name"))
|
||||
.add("create_time", new Date())
|
||||
.add("update_time", new Date())
|
||||
.add("deleted", false));
|
||||
return Result.success(true);
|
||||
}
|
||||
|
||||
@At("/votingIssue")
|
||||
@SaCheckLogin
|
||||
public Result votingIssue(@Param("materialsId") String materialsId, @Param("repId") String repId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
i.id,
|
||||
i.session_id AS sessionId,
|
||||
i.session_name AS sessionName,
|
||||
i.time_id AS timeId,
|
||||
i.time_name AS timeName,
|
||||
i.name,
|
||||
i.description,
|
||||
i.content,
|
||||
i.voting_type AS votingType,
|
||||
i.voting_start_time AS votingStartTime,
|
||||
i.voting_end_time AS votingEndTime,
|
||||
i.voting_content AS votingContent,
|
||||
i.voting_content_item_header AS votingContentItemHeader,
|
||||
i.voting_content_option_header AS votingContentOptionHeader,
|
||||
i.materials_id AS materialsId,
|
||||
i.type_id AS typeId,
|
||||
i.delegation_id AS delegationId,
|
||||
mt.name AS typeName,
|
||||
CASE WHEN vr.id IS NULL THEN false ELSE true END AS voted,
|
||||
vr.vote_result AS voteResult
|
||||
FROM congress_voting_issue i
|
||||
LEFT JOIN congress_materials_type mt ON mt.id = i.type_id AND IFNULL(mt.deleted, 0) = 0
|
||||
LEFT JOIN congress_voting_record vr ON vr.issue_id = i.id
|
||||
AND vr.rep_id = @repId
|
||||
AND IFNULL(vr.deleted, 0) = 0
|
||||
WHERE i.materials_id = @materialsId
|
||||
AND IFNULL(i.deleted, 0) = 0
|
||||
LIMIT 1
|
||||
""");
|
||||
sql.setParam("materialsId", materialsId);
|
||||
sql.setParam("repId", repId);
|
||||
sql.setCallback(Sqls.callback.map());
|
||||
dao.execute(sql);
|
||||
return Result.success(sql.getObject(NutMap.class));
|
||||
}
|
||||
|
||||
@At("/api/vote")
|
||||
@SaCheckLogin
|
||||
public Result voteSubmit(@Param("issueId") String issueId,
|
||||
@Param("repId") String repId,
|
||||
@Param("sessionId") String sessionId,
|
||||
@Param("timeId") String timeId,
|
||||
@Param("delegationId") String delegationId,
|
||||
@Param("voteResult") String voteResult) {
|
||||
if (StrUtil.hasBlank(issueId, repId, sessionId, timeId, voteResult)) {
|
||||
return Result.error("投票参数不完整");
|
||||
}
|
||||
int count = countBySql("""
|
||||
SELECT COUNT(1)
|
||||
FROM congress_voting_record
|
||||
WHERE issue_id = @issueId
|
||||
AND rep_id = @repId
|
||||
AND IFNULL(deleted, 0) = 0
|
||||
""", NutMap.NEW().addv("issueId", issueId).addv("repId", repId));
|
||||
if (count > 0) {
|
||||
return Result.error("您已投票,请勿重复提交");
|
||||
}
|
||||
|
||||
Sql repSql = Sqls.create("""
|
||||
SELECT user_id AS userId, emplid, name
|
||||
FROM congress_rep
|
||||
WHERE id = @repId
|
||||
AND IFNULL(deleted, 0) = 0
|
||||
LIMIT 1
|
||||
""");
|
||||
repSql.setParam("repId", repId);
|
||||
repSql.setCallback(Sqls.callback.map());
|
||||
dao.execute(repSql);
|
||||
NutMap rep = repSql.getObject(NutMap.class);
|
||||
if (rep == null) {
|
||||
return Result.error("未找到代表信息");
|
||||
}
|
||||
|
||||
dao.insert("congress_voting_record", Chain.make("id", R.UU32())
|
||||
.add("issue_id", issueId)
|
||||
.add("rep_id", repId)
|
||||
.add("emplid", rep.getString("emplid"))
|
||||
.add("name", rep.getString("name"))
|
||||
.add("session_id", sessionId)
|
||||
.add("time_id", timeId)
|
||||
.add("delegation_id", delegationId)
|
||||
.add("vote_result", voteResult)
|
||||
.add("user_id", rep.getString("userId"))
|
||||
.add("create_time", new Date())
|
||||
.add("update_time", new Date())
|
||||
.add("deleted", false));
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
private int countBySql(String sqlText, NutMap params) {
|
||||
Sql sql = Sqls.create(sqlText);
|
||||
params.forEach(sql::setParam);
|
||||
sql.setCallback(Sqls.callback.integer());
|
||||
dao.execute(sql);
|
||||
return sql.getInt();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user