通知
build / build-push (push) Failing after 1m18s

This commit is contained in:
wanghu
2026-09-10 15:39:41 +08:00
parent 2c8125a549
commit 3016a97f1b
86 changed files with 3427 additions and 1669 deletions
@@ -0,0 +1,122 @@
package com.yunhai.campusnotice.controller.api;
import com.yunhai.campusnotice.config.Config;
import com.yunhai.campusnotice.model.bsch.SchTreeNodeDto;
import com.yunhai.campusnotice.model.notice.UpFileResultVo;
import com.yunhai.campusnotice.service.IClassService;
import com.yunhai.campusnotice.service.IFileService;
import com.yunhai.campusnotice.service.IUserCenterService;
import com.yunhai.platform.auth.LoginUser;
import com.yunhai.platform.auth.UserContextHolder;
import com.yunhai.platform.utils.model.BoaUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import java.util.Map;
/**
* 平台代理域接口(base/)。
* <p>路径前缀:{@code Config.API_PATH + "/base/"}(原硬编码已修正)。
* 承载平台代理接口:GetUserInfo / GetUserMod / GetSchoolAll / GetGroupUser / Logout,
* 业务逻辑已下沉 {@link IUserCenterService},本控制器仅做"取参 → 调 Service → 返回"。
* 返回裸对象,由 ApiResponseAdvice 自动包装为 {code, msg, data}。</p>
*/
@RestController
@RequestMapping(value = Config.API_PATH + "/base/")
public class BaseApiController {
private static final Logger log = LoggerFactory.getLogger(BaseApiController.class);
@Autowired
private IUserCenterService userCenterService;
@Autowired
private IClassService classService;
@Autowired
private IFileService fileService;
// ============================ FileUpload ============================
/**
* 附件上传(单文件)。
* 前端: POST base/FileUpload (form-data: file)
* 返回: { fileid, host, fileurl, name, type, size }
*/
@PostMapping("FileUpload")
public UpFileResultVo fileUpload(@RequestParam("file") MultipartFile file) {
return fileService.uploadToResult(file, "notice");
}
// ============================ GetUserInfo ============================
/**
* 获取当前登录用户信息(CAS 会话注入)。
*/
@GetMapping("GetUserInfo")
public BoaUser getUserInfo(BoaUser authUserWithDept) {
return authUserWithDept;
}
// ============================ GetUserMod ============================
/**
* 获取当前用户已授权的模块列表(左侧菜单树)。
* 模块树组装已下沉 IUserCenterService。
*/
@GetMapping("GetUserMod")
public List<Map<String, Object>> getUserMod(BoaUser authUserWithDept) {
Integer schId = authUserWithDept.getCurrentRole() != null
? authUserWithDept.getCurrentRole().getSchId() : null;
return userCenterService.getUserModuleTree(authUserWithDept.getId(), schId);
}
// ============================ GetSchoolAll ============================
/**
* 获取当前用户学校学生树及学生
* 组树组装/教师挂组/递归建树逻辑已下沉 IUserCenterService。
*/
@GetMapping("getStuTree")
public List<SchTreeNodeDto> getStuTree(BoaUser authUserWithDept) {
Integer schId = authUserWithDept.getCurrentRole() != null
? authUserWithDept.getCurrentRole().getSchId() : null;
return classService.getStuTree(schId);
}
@GetMapping("GetSchoolAll")
public List<Map<String, Object>> getSchoolAll(BoaUser authUserWithDept) {
Integer schId = authUserWithDept.getCurrentRole() != null
? authUserWithDept.getCurrentRole().getSchId() : null;
return userCenterService.getSchoolAllTree(schId);
}
// ============================ GetGroupUser ============================
/**
* 获取指定组内用户(教师 + 管理员)。
* 空桩已改为显式报错(避免前端误以为组内无用户),由 IUserCenterService 统一处理。
*/
@GetMapping("GetGroupUser")
public List<Map<String, Object>> getGroupUser(
@RequestParam("gid") Integer gid,
@RequestParam(value = "role", defaultValue = "2") Integer role) {
return userCenterService.getGroupUser(gid, role);
}
// ============================ Logout ============================
/**
* 退出登录。
* 认证由平台网关处理,此处仅返回成功。
*/
@PostMapping("Logout")
public void logout() {
LoginUser user = UserContextHolder.get();
log.info("[logout] 用户退出登录: {}", user == null ? null : user.getLoginName());
}
}
@@ -0,0 +1,99 @@
package com.yunhai.campusnotice.controller.api;
import com.yunhai.campusnotice.config.Config;
import com.yunhai.campusnotice.service.IContactsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
/**
* 联系组接口(contacts/)。
* <p>路径前缀:{@code Config.API_PATH + "/contacts/"}(原硬编码已修正为 Config 拼接)。
* 方法名已为 PascalCase 且写操作已是 POST,保持不动。
* 返回裸对象,由 ApiResponseAdvice 自动包装为 {code, msg, data}。</p>
*/
@RestController
@RequestMapping(value = Config.API_PATH + "/contacts/")
public class ContactsController {
@Autowired
private IContactsService contactsService;
/**
* 添加联系组。
*/
@PostMapping("AddGroup")
public void addGroup(
@RequestParam("name") String name,
@RequestParam(value = "type", required = false, defaultValue = "1") String type) {
contactsService.addGroup(name, Integer.parseInt(type));
}
/**
* 获取联系组列表。
*/
@GetMapping("GetGroup")
public Map<String, Object> getGroup(
@RequestParam(value = "page", defaultValue = "0") Integer page,
@RequestParam(value = "count", defaultValue = "0") Integer count,
@RequestParam(value = "type", defaultValue = "1") Integer type) {
return contactsService.getGroup(page, count, type);
}
/**
* 编辑联系组。
*/
@PostMapping("EditGroup")
public void editGroup(
@RequestParam("name") String name,
@RequestParam("id") String id,
@RequestParam(value = "type", required = false, defaultValue = "1") String type) {
contactsService.editGroup(Integer.parseInt(id), name, Integer.parseInt(type));
}
/**
* 删除联系组(支持批量)。
*/
@PostMapping("DelGroup")
public void delGroup(@RequestParam("ids") String ids) {
contactsService.delGroup(ids);
}
/**
* 设置联系组教师。
*/
@PostMapping("SetContactsTea")
public void setContactsTea(
@RequestParam("gid") String gid,
@RequestParam(value = "ids", required = false) String ids) {
contactsService.setContactsTea(Integer.parseInt(gid), ids);
}
/**
* 获取联系组教师列表。
*/
@GetMapping("GetContactsTea")
public Map<String, Object> getContactsTea(
@RequestParam("gid") String gid,
@RequestParam(value = "page", defaultValue = "0") Integer page,
@RequestParam(value = "count", defaultValue = "0") Integer count) {
return contactsService.getContactsTea(gid, page, count);
}
/**
* 获取联系组树。
*/
@GetMapping("GetGroupTree")
public List<Map<String, Object>> getGroupTree(@RequestParam("type") Integer type) {
return contactsService.getGroupTree(type);
}
/**
* 获取部门角色组树。
*/
@GetMapping("GetDeptRoleGroupTree")
public List<Map<String, Object>> getDeptRoleGroupTree() {
return contactsService.getDeptRoleGroupTree();
}
}
@@ -0,0 +1,73 @@
package com.yunhai.campusnotice.controller.api;
import com.yunhai.campusnotice.config.Config;
import com.yunhai.campusnotice.service.IDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 系统字典接口(发文部门域)。
* <p>路径前缀:{@code Config.API_PATH + "/dict/"}(原 base/ 前缀已修正)。
* 写操作一律 POST(原 DelDept/OrdbyDicIds 为 GET 写操作,已 POST 化)。
*/
@RestController
@RequestMapping(value = Config.API_PATH + "/dict/")
public class DictController {
@Autowired
private IDictService dictService;
/**
* 获取系统字典(下拉框用)。
*/
@GetMapping("List")
public List<Map<String, Object>> list(@RequestParam(value = "type", defaultValue = "0") Integer type) {
return dictService.getSysDic(type);
}
/**
* 获取系统字典管理列表。
*/
@GetMapping("ManageList")
public List<Map<String, Object>> manageList(@RequestParam(value = "type", defaultValue = "dept") String type) {
return dictService.getDictMangeList(type);
}
/**
* 添加发文单位。
*/
@PostMapping("Add")
public void add(@RequestParam("name") String name) {
dictService.addDeptDic(name);
}
/**
* 更新发文单位。
*/
@PostMapping("Update")
public void update(
@RequestParam("SerID") Integer serID,
@RequestParam("Name") String name,
@RequestParam(value = "Enable", required = false, defaultValue = "1") Integer enable) {
dictService.updateDeptDic(serID, name, enable);
}
/**
* 删除发文单位(原 GET DelDept,已 POST 化)。
*/
@PostMapping("Delete")
public void delete(@RequestParam("serid") Integer serID) {
dictService.delDept(serID);
}
/**
* 发文单位排序(原 GET OrdbyDicIds,已 POST 化)。
*/
@PostMapping("Sort")
public void sort(@RequestParam("ids") String ids) {
dictService.ordbyDicIds(ids);
}
}
@@ -0,0 +1,88 @@
package com.yunhai.campusnotice.controller.api;
import com.yunhai.campusnotice.config.Config;
import com.yunhai.campusnotice.model.notice.UpFileResultVo;
import com.yunhai.campusnotice.model.notice.UpFileVo;
import com.yunhai.campusnotice.service.IFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 附件域接口(file/)。
* <p>路径前缀:{@code Config.API_PATH + "/file/"}(原 base/ 前缀已修正为独立文件域)。
* 方法名统一 PascalCase;写操作一律 POST。
* 返回裸对象,由 ApiResponseAdvice 自动包装为 {code, msg, data}。</p>
*/
@RestController
@RequestMapping(value = Config.API_PATH + "/file/")
public class FileController {
@Autowired
private IFileService fileService;
/**
* 附件上传(单文件)。
* 前端: POST file/Upload (form-data)
* 返回: { fileid, host, fileurl, name, type, size }
*/
@PostMapping("Upload")
public UpFileResultVo upload(@RequestParam("file") MultipartFile file) {
return fileService.uploadToResult(file, "notice");
}
/**
* 图片上传(多文件,返回数组)。
* 前端: POST file/UploadImage (form-data, accept=image/*)
*/
@PostMapping("UploadImage")
public List<UpFileVo> uploadImage(@RequestParam("file") MultipartFile[] files) {
return fileService.uploadImages(files, "notice");
}
/**
* 文件下载(浏览器直接 location.href 跳转)。
*/
@GetMapping("Down")
public void down(@RequestParam("id") Integer id, HttpServletResponse response) {
fileService.download(id, response);
}
/**
* 文件在线预览(inline 输出,前端取 Blob 交给 open-file-viewer 渲染)。
*/
@GetMapping("Preview")
public void preview(@RequestParam("id") Integer id,
@RequestParam(value = "type", required = false) Integer type,
HttpServletResponse response) {
fileService.preview(id, response);
}
/**
* 删除文件。
*/
@PostMapping("Delete")
public void delete(@RequestParam("fileId") Integer fileId) {
fileService.delete(fileId);
}
/**
* 查询某通知下的附件列表。
*/
@GetMapping("List")
public List<UpFileVo> list(@RequestParam("topicId") Integer topicId) {
return fileService.listByTopic("notice", topicId);
}
/**
* 批量绑定附件到通知。
*/
@PostMapping("Bind")
public void bind(@RequestParam("fileIds") List<Integer> fileIds,
@RequestParam("topicId") Integer topicId) {
fileService.bindToTopic(fileIds, topicId);
}
}
@@ -0,0 +1,391 @@
package com.yunhai.campusnotice.controller.api;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yunhai.campusnotice.config.Config;
import com.yunhai.campusnotice.common.validation.ValidationGroups;
import com.yunhai.campusnotice.model.BasePageResult;
import com.yunhai.campusnotice.model.notice.*;
import com.yunhai.campusnotice.service.INoticeService;
import com.yunhai.campusnotice.utils.PageUtils;
import com.yunhai.platform.apistd.BizException;
import com.yunhai.platform.utils.exception.ErrorCode;
import com.yunhai.platform.utils.model.BoaUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 通知公告接口(合并 NoticeApiController + 旧 NoticeController)。
* <p>路径前缀:{@code Config.API_PATH + "/notice/"}(platform = api / manage / mobiapi)。
* 方法动词式 PascalCase(对齐 UserBase);写操作一律 POST。
* 返回裸对象,由 ApiResponseAdvice 自动包装为 {code, msg, data}。
*/
@RestController
@RequestMapping(value = Config.API_PATH + "/notice/")
public class NoticeController {
@Autowired
private INoticeService noticeService;
// ============================ 收件箱列表 ============================
/**
* 已收通知列表(用户端)。
*/
@GetMapping("List")
public NoticePageResult<NoticeVo> list(NoticeQuery query,
@SortDefault(sort = {"topmost", "createTime"},
direction = Sort.Direction.DESC) Sort sort) {
return noticeService.userList(query, PageUtils.toPageable(query, sort));
}
// ============================ 已发/全部通知列表 ============================
/**
* 已发/全部通知列表(管理端)。type=user 只看自己。
*/
@GetMapping("SendList")
public BasePageResult<NoticeVo> sendList(NoticeQuery query,
@SortDefault(sort = "createTime",
direction = Sort.Direction.DESC) Sort sort) {
return noticeService.adminList(query, PageUtils.toPageable(query, sort));
}
// ============================ 查看详情(标读) ============================
/**
* 查看通知详情(type=1 普通查看标记已读, type=0 编辑模式不标记已读)。
*/
@GetMapping("Detail")
public NoticeDetailVo detail(@RequestParam("serid") Integer serid,
@RequestParam(value = "type", defaultValue = "1") Integer type) {
return noticeService.detailMap(serid, type);
}
// ============================ 编辑回显(不标读) ============================
/**
* 获取通知详情(编辑/转发用,不标记已读)。
*/
@GetMapping("GetDetail")
public NoticeDetailVo getDetail(@RequestParam("serid") Integer serid) {
return noticeService.getDetailMap(serid);
}
// ============================ 新建 ============================
/**
* 新建通知(JSON body)。fileIds 为附件ID逗号串,smsFlag 为短信标记。
*/
@PostMapping("Create")
public Integer create(@RequestBody @Validated(ValidationGroups.Create.class) NoticeRequest request) {
return noticeService.publish(request);
}
// ============================ 编辑 ============================
/**
* 编辑通知(JSON body,含 id)。
*/
@PostMapping("Edit")
public void edit(@RequestBody @Validated(ValidationGroups.Update.class) NoticeRequest request) {
noticeService.edit(request.getSourceId() != null ? request.getSourceId() : 0, request);
}
// ============================ 批量删除 ============================
/**
* 批量删除通知(ids 数组)。
*/
@PostMapping("Delete")
public void delete(@RequestBody List<Integer> ids) {
noticeService.deleteBatch(ids);
}
// ============================ 撤回 ============================
/**
* 撤回通知。
*/
@PostMapping("UserPull")
public void userPull(@RequestParam("serid") Integer serid) {
noticeService.pull(serid);
}
// ============================ 置顶 ============================
/**
* 置顶/取消置顶。
*/
@PostMapping("SetTopmost")
public void setTopmost(@RequestParam("serid") Integer serid,
@RequestParam(value = "topmost", defaultValue = "1") Integer topmost) {
noticeService.setTopmost(serid, topmost);
}
// ============================ 追加接收人 ============================
/**
* 追加接收人。
*/
@PostMapping("ReceiveUsers")
public void receiveUsers(@RequestParam("serid") Integer serid,
@RequestParam("users") String users) {
noticeService.receiveUsers(serid, users);
}
// ============================ 催收 ============================
/**
* 催收未读。
*/
@PostMapping("Expedite")
public void expedite(@RequestParam("serid") Integer serid) {
noticeService.expedite(serid);
}
// ============================ 一键已读 ============================
/**
* 一键全部已读(POST 化,原为 GET 写操作)。
*/
@PostMapping("InitializeRed")
public InitializeRedVo initializeRed() {
return noticeService.initializeRedResult();
}
// ============================ 阅读情况 ============================
/**
* 阅读情况(按已读/未读分组)。
*/
@GetMapping("ReadDetail")
public List<Map<String, Object>> readDetail(@RequestParam("serid") Integer serid) {
return noticeService.getReadDetailGrouped(serid);
}
// ============================ 上一篇/下一篇 ============================
/**
* 上一篇/下一篇通知ID。
*/
@GetMapping("GetNextPrev")
public Map<String, Object> getNextPrev(@RequestParam("serid") Integer serid,
@RequestParam("type") String type) {
return noticeService.getNextPrev(serid, type);
}
// ============================ 附件打包下载 ============================
/**
* 批量下载通知全部附件(打包 zip)。
*/
@GetMapping("AllFileDown")
public void allFileDown(@RequestParam("dataid") Integer dataid,
HttpServletResponse response) {
noticeService.downloadAllFiles(dataid, response);
}
// ============================ 统计 ============================
/**
* 通知统计。
*/
@GetMapping("Statis")
public NoticeStatisticsVo statis(
@RequestParam(value = "starttime", required = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime start,
@RequestParam(value = "endtime", required = false)
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime end) {
return noticeService.statistics(new NoticeQuery(), start, end);
}
// ============================ 转发(合并旧 REST 壳 forward) ============================
/**
* 转发通知(基于源通知创建新通知)。sourceId 在 request body 中传递。
*/
@PostMapping("Forward")
public Integer forward(@RequestBody @Validated(ValidationGroups.Create.class) NoticeRequest request) {
return noticeService.forward(request.getSourceId(), request);
}
// ============================ 推送范围树(新版发布表单,改造方案 3.1) ============================
/**
* 当前学校学员推送范围树:全校根 + 学段→年级→班级(数据源 bschclass),
* 供表单「推送范围」胶囊按钮渲染。节点结构:{scopeType, scopeId, name, children}。
*/
@GetMapping("ScopeTree")
public List<Map<String, Object>> scopeTree() {
return noticeService.scopeTree();
}
// ============================ 推送范围预估 ============================
/**
* 按已选范围预估接收人数(学员 = 范围展开去重账号数 + 教师 = receiveList 定向名单数)。
* scopes 为 JSON 数组:[{"scopeType":3,"scopeId":5,"scopeName":"初一"}]
*/
@GetMapping("ScopePreview")
public ScopePreviewVo scopePreview(@RequestParam(value = "scopes", required = false) String scopes,
@RequestParam(value = "receiveList", required = false) String receiveList) {
return noticeService.scopePreview(parseScopes(scopes), receiveList);
}
// ============================ 存为草稿 ============================
/**
* 存为草稿(status=0):不圈人、不发短信、不落接收人,仅存内容 + 范围快照 + 附件。
*/
@PostMapping("SaveDraft")
public Integer saveDraft(@RequestBody NoticeRequest request) {
return noticeService.saveDraft(request);
}
// ============================ 草稿箱列表 ============================
/**
* 草稿箱列表(status=0 本人草稿):重要程度 type/typeDesc、定时标注与 timingSendTime。
*/
@GetMapping("DraftList")
public BasePageResult<NoticeVo> draftList(NoticeQuery query,
@SortDefault(sort = "updateTime",
direction = Sort.Direction.DESC) Sort sort) {
return noticeService.draftList(query, PageUtils.toPageable(query, sort));
}
// ============================ 已发送阅读回执 ============================
/**
* 已发送通知阅读回执:按 年级→班级→学生 分组返回(身份快照),
* 学生带已读/未读状态与阅读时间(前端着色),教师接收行归「教师」组。
*/
@GetMapping("ReadReceipt")
public ReadReceiptVo readReceipt(@RequestParam("serid") Integer serid) {
return noticeService.readReceipt(serid);
}
// ============================ 审批人记忆回显 ============================
/**
* 审批人记忆回显:当前发布人最近一次所选审批人组合(无记忆返回空)。
*/
@GetMapping("ApproverSuggest")
public ApproverSuggestVo approverSuggest() {
return noticeService.approverSuggest();
}
// ============================ 审批人解析(教师树ID↔账号) ============================
/**
* 审批人解析:教师树(base/GetSchoolAll 叶子 id=教师用户ID)与登录账号互转。
* ids=1,2,3 解析账号(选人提交前);accounts=a,b 解析回ID(编辑回显勾树)。
* 两参数至少传其一;解析失败的项保留原值、缺目标字段,由前端提示。
*/
@GetMapping("ApproverResolve")
public List<ApproverResolveVo> approverResolve(
@RequestParam(value = "ids", required = false) String ids,
@RequestParam(value = "accounts", required = false) String accounts) {
if ((ids == null || ids.trim().isEmpty()) && (accounts == null || accounts.trim().isEmpty())) {
throw new BizException(ErrorCode.PARAM_ERROR, "ids 与 accounts 至少传其一");
}
return noticeService.approverResolve(
parseCsvInts(ids), parseCsvStrings(accounts));
}
/** 逗号串 → Integer 列表(忽略空段与非数字) */
private List<Integer> parseCsvInts(String csv) {
if (csv == null || csv.trim().isEmpty()) {
return null;
}
List<Integer> result = new ArrayList<>();
for (String s : csv.split(",")) {
try {
result.add(Integer.valueOf(s.trim()));
} catch (NumberFormatException ignore) {
}
}
return result;
}
/** 逗号串 → 字符串列表(忽略空段,兼容中文逗号/分号) */
private List<String> parseCsvStrings(String csv) {
if (csv == null || csv.trim().isEmpty()) {
return null;
}
return new ArrayList<>(java.util.Arrays.asList(csv.split("[,,;;]")));
}
// ============================ 提交审批 ============================
/**
* 提交审批(status: 0/3→2):发布人选定审批人(可多选,或签),
* 写 notice_approval 提交行并 upsert 审批人记忆表。
*/
@PostMapping("Submit")
public void submit(@RequestBody SubmitRequest request) {
noticeService.submit(request.getSerid(), request.getApproverAccounts(), request.getOpinion());
}
// ============================ 审批通过 ============================
/**
* 审批通过(或签):任一审批人通过即 status→1 并触发真实发布;
* 被他人先审时返回带实际处理人/时间的冲突提示。
*/
@PostMapping("Approve")
public void approve(@RequestParam("serid") Integer serid,
@RequestParam(value = "opinion", required = false) String opinion) {
noticeService.approve(serid, opinion);
}
// ============================ 审批驳回 ============================
/**
* 审批驳回(或签):任一审批人驳回即 status→3,意见必填;发布人可改后重新提交。
*/
@PostMapping("Reject")
public void reject(@RequestParam("serid") Integer serid,
@RequestParam("opinion") String opinion) {
noticeService.reject(serid, opinion);
}
// ============================ 审批列表(待审/已审合一) ============================
/**
* 审批列表:按审批人快照含当前账号过滤(schId 隔离)。
* auditState=pending(默认) 待审 / reviewed 已审(含或签下他人已处理,带实际处理人)。
*/
@GetMapping("ApprovalList")
public BasePageResult<ApprovalListVo> approvalList(
@RequestParam(value = "auditState", defaultValue = "pending") String auditState,
NoticeQuery query,
@SortDefault(sort = "updateTime", direction = Sort.Direction.DESC) Sort sort) {
return noticeService.approvalList(auditState, query, PageUtils.toPageable(query, sort));
}
/** 解析 scopes JSON 参数为范围列表(空/非法返回 null = 无范围) */
private List<PushScopeItem> parseScopes(String scopes) {
if (scopes == null || scopes.trim().isEmpty()) {
return null;
}
try {
return new ObjectMapper().readValue(scopes, new TypeReference<List<PushScopeItem>>() {
});
} catch (IOException e) {
throw new BizException(ErrorCode.PARAM_ERROR, "scopes 参数格式错误,应为 JSON 数组:[{\"scopeType\":3,\"scopeId\":5}]");
}
}
}
@@ -0,0 +1,88 @@
package com.yunhai.campusnotice.controller.api;
import com.yunhai.campusnotice.config.Config;
import com.yunhai.campusnotice.service.ISmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 短信设置接口(短信域)。
* <p>路径前缀:{@code Config.API_PATH + "/sms/"}(原 schsms/ 已修正)。
* 方法名 PascalCase(原全小写已修正);写操作一律 POST(原 setschallsms/setschmodulesms 为 GET 写操作,已 POST 化)。
*/
@RestController
@RequestMapping(value = Config.API_PATH + "/sms/")
public class SmsController {
@Autowired
private ISmsService smsService;
/**
* 获取短信模块列表。
*/
@GetMapping("GetModule")
public List<Map<String, Object>> getModule() {
return smsService.getModuleList();
}
/**
* 获取学校父类组列表。
*/
@GetMapping("GetGroup")
public List<Map<String, Object>> getGroup() {
return smsService.getSchParentGroup();
}
/**
* 分页获取学校短信开关列表。
*/
@GetMapping("GetSchoolSms")
public Map<String, Object> getSchoolSms(
@RequestParam(value = "schpid", required = false) String schpid,
@RequestParam("PageSize") Integer pageSize,
@RequestParam("PageIndex") Integer pageIndex,
@RequestParam(value = "SchName", required = false, defaultValue = "") String schName) {
return smsService.getSchIsSmsList(pageSize, pageIndex, schName);
}
/**
* 获取学校列表。
*/
@GetMapping("GetSchool")
public List<Map<String, Object>> getSchool() {
return smsService.getSchList();
}
/**
* 设置单校单模块短信开关。
*/
@PostMapping("SetSchoolSms")
public void setSchoolSms(@RequestParam("itemsModu") String itemsModuJson) {
smsService.setSchSmsFromJson(itemsModuJson);
}
/**
* 设置某校全部模块短信开关(原 GET setschallsms,已 POST 化)。
*/
@PostMapping("SetAllSchoolSms")
public void setAllSchoolSms(
@RequestParam("SchSerID") Integer schSerID,
@RequestParam("IsSms") Boolean isSms) {
smsService.setSchSmsAll(schSerID, isSms);
}
/**
* 批量设置多校多模块短信开关(原 GET setschmodulesms,已 POST 化)。
*/
@PostMapping("SetSchoolModuleSms")
public void setSchoolModuleSms(
@RequestParam("SchSerID") String schSerID,
@RequestParam("Module") String module,
@RequestParam("IsSms") Boolean isSms) {
smsService.setSchModuleSms(schSerID, module, isSms);
}
}
@@ -0,0 +1,88 @@
package com.yunhai.campusnotice.controller.api;
import com.yunhai.campusnotice.config.Config;
import com.yunhai.campusnotice.service.ITemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* 通知模板接口(模板域)。
* <p>路径前缀:{@code Config.API_PATH + "/template/"}(原 notice/Template/ 三级路径已修正)。
* 写操作一律 POST(原 EditType/DelTemplate 为 GET 写操作,已 POST 化)。
*/
@RestController
@RequestMapping(value = Config.API_PATH + "/template/")
public class TemplateController {
@Autowired
private ITemplateService templateService;
/**
* 获取模板类型列表。
*/
@GetMapping("Typelist")
public List<Map<String, Object>> getTypelist() {
return templateService.getTypelist();
}
/**
* 新增/编辑模板类型(原 GET EditType,已 POST 化)。
*/
@PostMapping("TypeEdit")
public void typeEdit(
@RequestParam("typeid") Integer typeid,
@RequestParam("TypeName") String typeName) {
templateService.editType(typeid, typeName);
}
/**
* 删除模板类型(原 GET DelType,已 POST 化)。
*/
@PostMapping("TypeDelete")
public void typeDelete(@RequestParam("typeid") Integer typeid) {
templateService.delType(typeid);
}
/**
* 分页获取模板列表。
*/
@GetMapping("List")
public Map<String, Object> list(
@RequestParam("PageSize") Integer pageSize,
@RequestParam("PageIndex") Integer pageIndex,
@RequestParam(value = "typeid", defaultValue = "0") Integer typeid) {
return templateService.getTemplatelist(pageSize, pageIndex, typeid);
}
/**
* 新增/编辑模板。
*/
@PostMapping("TemplateEdit")
public void templateEdit(
@RequestParam(value = "SerID", required = false) Integer serID,
@RequestParam("Title") String title,
@RequestParam("Contents") String contents,
@RequestParam(value = "Type", required = false) Integer type,
@RequestParam(value = "Cover", required = false) Integer cover) {
templateService.editTemplate(serID, title, contents, type, cover);
}
/**
* 删除模板(原 GET DelTemplate,已 POST 化)。
*/
@PostMapping("TemplateDelete")
public void templateDelete(@RequestParam("SerID") Integer serid) {
templateService.delTemplate(serid);
}
/**
* 获取单个模板详情。
*/
@GetMapping("TemplateFirst")
public Map<String, Object> templateFirst(@RequestParam("serid") Integer serid) {
return templateService.getTemplateFist(serid);
}
}