|
|
@@ -0,0 +1,221 @@
|
|
|
+/*
|
|
|
+ * Copyright [2022] [https://www.xiaonuo.vip]
|
|
|
+ *
|
|
|
+ * Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
|
|
+ *
|
|
|
+ * 1.请不要删除和修改根目录下的LICENSE文件。
|
|
|
+ * 2.请不要删除和修改Snowy源码头部的版权声明。
|
|
|
+ * 3.本项目代码可免费商业使用,商业使用请保留源码和相关描述文件的项目出处,作者声明等。
|
|
|
+ * 4.分发源码时候,请注明软件出处 https://www.xiaonuo.vip
|
|
|
+ * 5.不可二次分发开源参与同类竞品,如有想法可联系团队xiaonuobase@qq.com商议合作。
|
|
|
+ * 6.若您的项目无法满足以上几点,需要更多功能代码,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip
|
|
|
+ */
|
|
|
+package vip.xiaonuo.disk.controller;
|
|
|
+
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiSupport;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import vip.xiaonuo.common.annotation.CommonLog;
|
|
|
+import vip.xiaonuo.common.pojo.CommonResult;
|
|
|
+import vip.xiaonuo.common.pojo.CommonValidList;
|
|
|
+import vip.xiaonuo.disk.domain.Semester;
|
|
|
+import vip.xiaonuo.disk.dto.semester.SemesterAddParam;
|
|
|
+import vip.xiaonuo.disk.dto.semester.SemesterEditParam;
|
|
|
+import vip.xiaonuo.disk.dto.semester.SemesterIdParam;
|
|
|
+import vip.xiaonuo.disk.dto.semester.SemesterPageParam;
|
|
|
+import vip.xiaonuo.disk.service.SemesterService;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.NotEmpty;
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 学期表控制器
|
|
|
+ *
|
|
|
+ * @author honorfire
|
|
|
+ * @date 2025/07/11 14:42
|
|
|
+ */
|
|
|
+@Api(tags = "学期表控制器")
|
|
|
+@ApiSupport(author = "SNOWY_TEAM", order = 1)
|
|
|
+@RestController
|
|
|
+@Validated
|
|
|
+public class SemesterController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SemesterService semesterService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 学期表-分页列表
|
|
|
+ *
|
|
|
+ * @author honorfire
|
|
|
+ * @date 2025/07/11 14:42
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation("学期表-分页列表")
|
|
|
+ @SaCheckPermission("/disk/semester/page")
|
|
|
+ @GetMapping("/disk/semester/page")
|
|
|
+ public CommonResult<Page<Map<String,Object>>> page(SemesterPageParam semesterPageParam, HttpServletRequest req) {
|
|
|
+ Map param =new HashMap();
|
|
|
+ param.put("name", req.getParameter("name"));
|
|
|
+ param.put("multiyear", req.getParameter("multiyear"));
|
|
|
+ param.put("quater", req.getParameter("quater"));
|
|
|
+
|
|
|
+ Page<Map<String,Object>> list=semesterService.queryList(param);
|
|
|
+ return CommonResult.data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 学期表-下拉列表
|
|
|
+ *
|
|
|
+ * @author honorfire
|
|
|
+ * @date 2025/07/11 14:42
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperation("学期表-下拉列表")
|
|
|
+ @SaCheckPermission("/disk/semester/downList")
|
|
|
+ @GetMapping("/disk/semester/downList")
|
|
|
+ public CommonResult<List<Map<String,Object>>> downList(SemesterPageParam semesterPageParam, HttpServletRequest req) {
|
|
|
+ Map param =new HashMap();
|
|
|
+ //是查年份下拉还是季度下拉,默认是0年度
|
|
|
+ String type="0";
|
|
|
+ if(StringUtils.isNotEmpty(req.getParameter("type")))type=req.getParameter("type");
|
|
|
+ param.put("type",type );
|
|
|
+
|
|
|
+ List<Map<String,Object>> list=semesterService.downList(param);
|
|
|
+ return CommonResult.data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加学期表
|
|
|
+ *
|
|
|
+ * @author honorfire
|
|
|
+ * @date 2025/07/11 14:42
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation("添加学期表")
|
|
|
+ @CommonLog("添加学期表")
|
|
|
+ @SaCheckPermission("/disk/semester/add")
|
|
|
+ @PostMapping("/disk/semester/add")
|
|
|
+ public CommonResult<String> add(@RequestBody @Valid SemesterAddParam semesterAddParam) {
|
|
|
+ Semester semester = BeanUtil.toBean(semesterAddParam, Semester.class);
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (semester.getStartTime() != null) {
|
|
|
+ SimpleDateFormat sdt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(sdt.parse(semester.getStartTime()));
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
+ // 从startTime字段中提取年份并存入multiyear字段
|
|
|
+ semester.setMultiyear(String.valueOf(year));
|
|
|
+ // 从startTime字段中提取月份判断并存入quarter字段
|
|
|
+ int month = calendar.get(Calendar.MONTH) + 1; // 月份是0-11,需要+1
|
|
|
+ String quarter;
|
|
|
+ if (month >= 1 && month <= 3) {
|
|
|
+ quarter = "1";
|
|
|
+ } else if (month >= 4 && month <= 6) {
|
|
|
+ quarter = "2";
|
|
|
+ } else if (month >= 7 && month <= 9) {
|
|
|
+ quarter = "3";
|
|
|
+ } else {
|
|
|
+ quarter = "4";
|
|
|
+ }
|
|
|
+ semester.setQuater(quarter);
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ semesterService.addOne(semester);
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑学期表
|
|
|
+ *
|
|
|
+ * @author honorfire
|
|
|
+ * @date 2025/07/11 14:42
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
+ @ApiOperation("编辑学期表")
|
|
|
+ @CommonLog("编辑学期表")
|
|
|
+ @SaCheckPermission("/disk/semester/edit")
|
|
|
+ @PostMapping("/disk/semester/edit")
|
|
|
+ public CommonResult<String> edit(@RequestBody @Valid SemesterEditParam semesterEditParam) {
|
|
|
+ Semester semester = BeanUtil.toBean(semesterEditParam, Semester.class);
|
|
|
+ try {
|
|
|
+ if (semester.getStartTime() != null) {
|
|
|
+ SimpleDateFormat sdt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(sdt.parse(semester.getStartTime()));
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
+ // 从startTime字段中提取年份并存入multiyear字段
|
|
|
+ semester.setMultiyear(String.valueOf(year));
|
|
|
+ // 从startTime字段中提取月份判断并存入quarter字段
|
|
|
+ int month = calendar.get(Calendar.MONTH) + 1; // 月份是0-11,需要+1
|
|
|
+ String quarter;
|
|
|
+ if (month >= 1 && month <= 3) {
|
|
|
+ quarter = "1";
|
|
|
+ } else if (month >= 4 && month <= 6) {
|
|
|
+ quarter = "2";
|
|
|
+ } else if (month >= 7 && month <= 9) {
|
|
|
+ quarter = "3";
|
|
|
+ } else {
|
|
|
+ quarter = "4";
|
|
|
+ }
|
|
|
+ semester.setQuater(quarter);
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ semesterService.editOne(semester);
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除学期表
|
|
|
+ *
|
|
|
+ * @author honorfire
|
|
|
+ * @date 2025/07/11 14:42
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @ApiOperation("删除学期表")
|
|
|
+ @CommonLog("删除学期表")
|
|
|
+ @SaCheckPermission("/disk/semester/delete")
|
|
|
+ @PostMapping("/disk/semester/delete")
|
|
|
+ public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
|
|
|
+ CommonValidList<SemesterIdParam> semesterIdParamList) {
|
|
|
+ semesterService.delete(semesterIdParamList);
|
|
|
+ return CommonResult.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取学期表详情
|
|
|
+ *
|
|
|
+ * @author honorfire
|
|
|
+ * @date 2025/07/11 14:42
|
|
|
+ */
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
+ @ApiOperation("获取学期表详情")
|
|
|
+ @SaCheckPermission("/disk/semester/detail")
|
|
|
+ @GetMapping("/disk/semester/detail")
|
|
|
+ public CommonResult<Map<String,Object>> detail(@Valid SemesterIdParam semesterIdParam, HttpServletRequest req) {
|
|
|
+ Map param =new HashMap();
|
|
|
+ param.put("id", req.getParameter("id"));
|
|
|
+ Map<String,Object> result=semesterService.queryInfo(param);
|
|
|
+ return CommonResult.data(result);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|