Browse Source

Merge branch 'master' of http://39.108.133.138:3000/Web/WebProject

KawsFa 1 year ago
parent
commit
cd997c1314

+ 10 - 10
.idea/mybatisx/templates.xml

@@ -5,8 +5,8 @@
       <TemplateContext>
         <option name="generateConfig">
           <GenerateConfig>
-            <option name="annotationType" value="NONE" />
-            <option name="basePackage" value="user" />
+            <option name="annotationType" value="MYBATIS_PLUS3" />
+            <option name="basePackage" value="calendar" />
             <option name="basePath" value="src/main/java/boot/modules" />
             <option name="classNameStrategy" value="camel" />
             <option name="encoding" value="UTF-8" />
@@ -16,7 +16,7 @@
             <option name="ignoreTablePrefix" value="" />
             <option name="ignoreTableSuffix" value="" />
             <option name="moduleName" value="java" />
-            <option name="modulePath" value="$PROJECT_DIR$/java/" />
+            <option name="modulePath" value="$PROJECT_DIR$/java" />
             <option name="moduleUIInfoList">
               <list>
                 <ModuleInfoGo>
@@ -26,7 +26,7 @@
                   <option name="encoding" value="${domain.encoding}" />
                   <option name="fileName" value="${domain.fileName}ServiceImpl" />
                   <option name="fileNameWithSuffix" value="${domain.fileName}ServiceImpl.java" />
-                  <option name="modulePath" value="$PROJECT_DIR$/java/" />
+                  <option name="modulePath" value="$PROJECT_DIR$/java" />
                   <option name="packageName" value="${domain.basePackage}.service.impl" />
                 </ModuleInfoGo>
                 <ModuleInfoGo>
@@ -36,7 +36,7 @@
                   <option name="encoding" value="${domain.encoding}" />
                   <option name="fileName" value="${domain.fileName}Mapper" />
                   <option name="fileNameWithSuffix" value="${domain.fileName}Mapper.java" />
-                  <option name="modulePath" value="$PROJECT_DIR$/java/" />
+                  <option name="modulePath" value="$PROJECT_DIR$/java" />
                   <option name="packageName" value="${domain.basePackage}.mapper" />
                 </ModuleInfoGo>
                 <ModuleInfoGo>
@@ -46,17 +46,17 @@
                   <option name="encoding" value="${domain.encoding}" />
                   <option name="fileName" value="${domain.fileName}Service" />
                   <option name="fileNameWithSuffix" value="${domain.fileName}Service.java" />
-                  <option name="modulePath" value="$PROJECT_DIR$/java/" />
+                  <option name="modulePath" value="$PROJECT_DIR$/java" />
                   <option name="packageName" value="${domain.basePackage}.service" />
                 </ModuleInfoGo>
                 <ModuleInfoGo>
-                  <option name="basePath" value="src/main/resources" />
+                  <option name="basePath" value="src/main/resources/boot/modules/calendar" />
                   <option name="configFileName" value="mapperXml.ftl" />
                   <option name="configName" value="mapperXml" />
                   <option name="encoding" value="${domain.encoding}" />
                   <option name="fileName" value="${domain.fileName}Mapper" />
                   <option name="fileNameWithSuffix" value="${domain.fileName}Mapper.xml" />
-                  <option name="modulePath" value="$PROJECT_DIR$/java/" />
+                  <option name="modulePath" value="$PROJECT_DIR$/java" />
                   <option name="packageName" value="mapper" />
                 </ModuleInfoGo>
               </list>
@@ -69,8 +69,8 @@
             <option name="tableUIInfoList">
               <list>
                 <TableUIInfo>
-                  <option name="className" value="User" />
-                  <option name="tableName" value="user" />
+                  <option name="className" value="Calendar" />
+                  <option name="tableName" value="calendar" />
                 </TableUIInfo>
               </list>
             </option>

+ 99 - 1
java/src/main/java/boot/modules/calendar/controller/CalendarController.java

@@ -1,13 +1,111 @@
 package boot.modules.calendar.controller;
 
+import boot.common.respond.ApiCode;
+import boot.common.respond.ApiResult;
+import boot.modules.calendar.param.CalendarParam;
+import boot.modules.calendar.pojo.Calendar;
+import boot.modules.calendar.respond.CalendarDTO;
+import boot.modules.calendar.service.CalendarService;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.ListUtil;
+import cn.hutool.core.util.ObjUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
 
 @RestController
 @RequiredArgsConstructor(onConstructor = @__(@Autowired))
 @Api(value = "日历模块", tags = "日历")
+@RequestMapping("/calendar")
 public class CalendarController {
 
+    private final CalendarService calendarService;
+
+    @GetMapping("/getCalendars")
+    @ApiOperation(value = "获取所有日历事件",notes = "查询")
+    public ApiResult<List<CalendarDTO>> getAllCalendars() {
+        //查询所有事件
+        List<Calendar> list = calendarService.list();
+
+        List<CalendarDTO> calendars = new ArrayList<>();
+        //转换类型
+        List<Calendar> collect = list.stream()
+                .peek((item) -> {
+                    CalendarDTO calendarDTO = BeanUtil.copyProperties(item, CalendarDTO.class);
+                    calendars.add(calendarDTO);
+                }).collect(Collectors.toList());
+
+        return ApiResult.ok(calendars);
+    }
+
+    @PostMapping("/addCalendar")
+    @ApiOperation(value = "添加单个日历事件",notes = "添加")
+    public ApiResult<Object> addCalendar(@RequestBody CalendarParam param){
+
+        if (ObjUtil.isEmpty(param)){
+            //请求是否为空
+            return ApiResult.fail(ApiCode.FAIL,"不能为空!");
+        }
+
+        //构造SQL条件
+        LambdaQueryWrapper<Calendar> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(Calendar::getTitle,param.getTitle());
+
+        Calendar one = calendarService.getOne(wrapper);
+
+        if (ObjUtil.isNotEmpty(one)){
+            //没查到数据 = 这个事件不存在可以添加
+            return ApiResult.fail(ApiCode.FAIL,"该事件已存在!请勿重新添加!");
+        }
+
+        //添加事件
+        boolean save = calendarService.save(BeanUtil.copyProperties(param, Calendar.class));
+
+        return ApiResult.ok(save);
+    }
+
+    @DeleteMapping("/delById/{id}")
+    @ApiOperation(value = "根据id删除事件",notes = "删除")
+    public ApiResult<Object> delById(@PathVariable Long id){
+
+        if (ObjUtil.isEmpty(id)){
+            return ApiResult.fail(ApiCode.FAIL,"id不能为空!!");
+        }
+
+        //逻辑删除
+        boolean b = calendarService.removeById(id);
+
+        return ApiResult.ok(b);
+    }
+
+    @PutMapping("/editCalendar")
+    @ApiOperation(value = "根据id修改校历事件",notes = "修改")
+    public ApiResult<Object> editById(@RequestBody CalendarParam param){
+
+        if (ObjUtil.isEmpty(param.getId())){
+            //判断id是否为空
+            return ApiResult.fail(ApiCode.FAIL,"id不能为空!!");
+        }
+        //构建SQL条件
+        LambdaQueryWrapper<Calendar> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(Calendar::getId,param.getId());
+
+        Calendar calendar = BeanUtil.copyProperties(param, Calendar.class);
+        boolean update = calendarService.update(calendar, wrapper);
+
+        if (update){
+            return ApiResult.ok(update);
+        }else {
+            return ApiResult.fail(ApiCode.FAIL,"修改出错了啦!请联系管理员!");
+        }
+    }
 }

+ 21 - 0
java/src/main/java/boot/modules/calendar/mapper/CalendarMapper.java

@@ -0,0 +1,21 @@
+package boot.modules.calendar.mapper;
+
+
+import boot.modules.calendar.pojo.Calendar;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+* @author Lin
+* @description 针对表【calendar】的数据库操作Mapper
+* @createDate 2024-06-06 08:34:10
+* @Entity calendar.pojo.Calendar
+*/
+@Mapper
+public interface CalendarMapper extends BaseMapper<Calendar> {
+
+}
+
+
+
+

+ 64 - 0
java/src/main/java/boot/modules/calendar/param/CalendarParam.java

@@ -0,0 +1,64 @@
+package boot.modules.calendar.param;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+import java.util.Date;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@ToString
+public class CalendarParam {
+    /**
+     * 日历表格id
+     */
+    private Long id;
+    /**
+     * 活动 事件
+     */
+    private String title;
+
+    /**
+     * 详情
+     */
+    private String detail;
+
+    /**
+     * 活动 事件开始时间   2024-06-12T10:30:00为点状  2024-06-12为条状
+     */
+    private Date start;
+
+    /**
+     * 活动 事件结束时间   2024-06-12T10:30:00为点状  2024-06-12为条状
+     */
+    private Date end;
+
+    /**
+     * 该事件是否可以与其他事件并存
+     */
+    private Integer overlap;
+
+    /**
+     * 该事件是否允许拖动缩放
+     */
+    private Integer editable;
+
+    /**
+     * 背景颜色
+     */
+    private String color;
+
+    /**
+     * 文件
+     */
+    private String file;
+
+    /**
+     * 文件类型
+     */
+    private String fileType;
+
+}

+ 140 - 0
java/src/main/java/boot/modules/calendar/pojo/Calendar.java

@@ -0,0 +1,140 @@
+package boot.modules.calendar.pojo;
+
+import com.baomidou.mybatisplus.annotation.*;
+
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * 
+ * @TableName calendar
+ */
+@TableName(value ="calendar")
+@Data
+public class Calendar implements Serializable {
+    /**
+     * 日历表格id
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 活动 事件
+     */
+    private String title;
+
+    /**
+     * 详情
+     */
+    private String detail;
+
+    /**
+     * 活动 事件开始时间   2024-06-12T10:30:00为点状  2024-06-12为条状
+     */
+    private Date start;
+
+    /**
+     * 活动 事件结束时间   2024-06-12T10:30:00为点状  2024-06-12为条状
+     */
+    private Date end;
+
+    /**
+     * 该事件是否可以与其他事件并存
+     */
+    private Integer overlap;
+
+    /**
+     * 该事件是否允许拖动缩放
+     */
+    private Integer editable;
+
+    /**
+     * 背景颜色
+     */
+    private String color;
+
+    /**
+     * 文件
+     */
+    private String file;
+
+    /**
+     * 文件类型
+     */
+    private String fileType;
+
+    /**
+     * 这条数据是否被删除 0未删除 1已删除
+     */
+    @TableLogic
+    private Integer isDel;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        Calendar other = (Calendar) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+            && (this.getTitle() == null ? other.getTitle() == null : this.getTitle().equals(other.getTitle()))
+            && (this.getDetail() == null ? other.getDetail() == null : this.getDetail().equals(other.getDetail()))
+            && (this.getStart() == null ? other.getStart() == null : this.getStart().equals(other.getStart()))
+            && (this.getEnd() == null ? other.getEnd() == null : this.getEnd().equals(other.getEnd()))
+            && (this.getOverlap() == null ? other.getOverlap() == null : this.getOverlap().equals(other.getOverlap()))
+            && (this.getEditable() == null ? other.getEditable() == null : this.getEditable().equals(other.getEditable()))
+            && (this.getColor() == null ? other.getColor() == null : this.getColor().equals(other.getColor()))
+            && (this.getFile() == null ? other.getFile() == null : this.getFile().equals(other.getFile()))
+            && (this.getFileType() == null ? other.getFileType() == null : this.getFileType().equals(other.getFileType()))
+            && (this.getIsDel() == null ? other.getIsDel() == null : this.getIsDel().equals(other.getIsDel()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getTitle() == null) ? 0 : getTitle().hashCode());
+        result = prime * result + ((getDetail() == null) ? 0 : getDetail().hashCode());
+        result = prime * result + ((getStart() == null) ? 0 : getStart().hashCode());
+        result = prime * result + ((getEnd() == null) ? 0 : getEnd().hashCode());
+        result = prime * result + ((getOverlap() == null) ? 0 : getOverlap().hashCode());
+        result = prime * result + ((getEditable() == null) ? 0 : getEditable().hashCode());
+        result = prime * result + ((getColor() == null) ? 0 : getColor().hashCode());
+        result = prime * result + ((getFile() == null) ? 0 : getFile().hashCode());
+        result = prime * result + ((getFileType() == null) ? 0 : getFileType().hashCode());
+        result = prime * result + ((getIsDel() == null) ? 0 : getIsDel().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", title=").append(title);
+        sb.append(", detail=").append(detail);
+        sb.append(", start=").append(start);
+        sb.append(", end=").append(end);
+        sb.append(", overlap=").append(overlap);
+        sb.append(", editable=").append(editable);
+        sb.append(", color=").append(color);
+        sb.append(", file=").append(file);
+        sb.append(", fileType=").append(fileType);
+        sb.append(", isDel=").append(isDel);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 65 - 0
java/src/main/java/boot/modules/calendar/respond/CalendarDTO.java

@@ -0,0 +1,65 @@
+package boot.modules.calendar.respond;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+import java.util.Date;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@ToString
+public class CalendarDTO {
+    /**
+     * 日历表格id
+     */
+    private Long id;
+
+    /**
+     * 活动 事件
+     */
+    private String title;
+
+    /**
+     * 详情
+     */
+    private String detail;
+
+    /**
+     * 活动 事件开始时间   2024-06-12T10:30:00为点状  2024-06-12为条状
+     */
+    private Date start;
+
+    /**
+     * 活动 事件结束时间   2024-06-12T10:30:00为点状  2024-06-12为条状
+     */
+    private Date end;
+
+    /**
+     * 该事件是否可以与其他事件并存
+     */
+    private Integer overlap;
+
+    /**
+     * 该事件是否允许拖动缩放
+     */
+    private Integer editable;
+
+    /**
+     * 背景颜色
+     */
+    private String color;
+
+    /**
+     * 文件
+     */
+    private String file;
+
+    /**
+     * 文件类型
+     */
+    private String fileType;
+
+}

+ 16 - 0
java/src/main/java/boot/modules/calendar/service/CalendarService.java

@@ -0,0 +1,16 @@
+package boot.modules.calendar.service;
+
+
+import boot.modules.calendar.pojo.Calendar;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.springframework.stereotype.Service;
+
+/**
+* @author Lin
+* @description 针对表【calendar】的数据库操作Service
+* @createDate 2024-06-06 08:34:10
+*/
+@Service
+public interface CalendarService extends IService<Calendar> {
+
+}

+ 24 - 0
java/src/main/java/boot/modules/calendar/service/impl/CalendarServiceImpl.java

@@ -0,0 +1,24 @@
+package boot.modules.calendar.service.impl;
+
+import boot.modules.calendar.mapper.CalendarMapper;
+import boot.modules.calendar.pojo.Calendar;
+import boot.modules.calendar.service.CalendarService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+
+import org.springframework.stereotype.Service;
+
+/**
+* @author Lin
+* @description 针对表【calendar】的数据库操作Service实现
+* @createDate 2024-06-06 08:34:10
+*/
+@Service
+public class CalendarServiceImpl extends ServiceImpl<CalendarMapper, Calendar>
+    implements CalendarService {
+
+}
+
+
+
+

+ 1 - 1
java/src/main/java/boot/modules/user/controller/UserActionController.java

@@ -40,7 +40,7 @@ public class UserActionController {
         //利用工具类转换对象的类型,并复制属性值
         UserDTO userDTO = BeanUtil.copyProperties(user, UserDTO.class);
 
-        return ApiResult.ok(userDTO); 
+        return ApiResult.ok(userDTO);
     }
 
     @AuthCheck

+ 27 - 0
java/src/main/resources/boot/modules/calendar/mapper/CalendarMapper.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="boot.modules.calendar.mapper.CalendarMapper">
+
+    <resultMap id="BaseResultMap" type="boot.modules.calendar.pojo.Calendar">
+            <id property="id" column="id" jdbcType="BIGINT"/>
+            <result property="title" column="title" jdbcType="VARCHAR"/>
+            <result property="detail" column="detail" jdbcType="VARCHAR"/>
+            <result property="start" column="start" jdbcType="DATE"/>
+            <result property="end" column="end" jdbcType="DATE"/>
+            <result property="overlap" column="overlap" jdbcType="TINYINT"/>
+            <result property="editable" column="editable" jdbcType="TINYINT"/>
+            <result property="color" column="color" jdbcType="VARCHAR"/>
+            <result property="file" column="file" jdbcType="VARCHAR"/>
+            <result property="fileType" column="file_type" jdbcType="VARCHAR"/>
+            <result property="isDel" column="is_del" jdbcType="TINYINT"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,title,detail,
+        start,end,overlap,
+        editable,color,file,
+        file_type,is_del
+    </sql>
+</mapper>

BIN
java/target/classes/boot/modules/calendar/mapper/CalendarMapper.class


+ 27 - 0
java/target/classes/boot/modules/calendar/mapper/CalendarMapper.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="boot.modules.calendar.mapper.CalendarMapper">
+
+    <resultMap id="BaseResultMap" type="boot.modules.calendar.pojo.Calendar">
+            <id property="id" column="id" jdbcType="BIGINT"/>
+            <result property="title" column="title" jdbcType="VARCHAR"/>
+            <result property="detail" column="detail" jdbcType="VARCHAR"/>
+            <result property="start" column="start" jdbcType="DATE"/>
+            <result property="end" column="end" jdbcType="DATE"/>
+            <result property="overlap" column="overlap" jdbcType="TINYINT"/>
+            <result property="editable" column="editable" jdbcType="TINYINT"/>
+            <result property="color" column="color" jdbcType="VARCHAR"/>
+            <result property="file" column="file" jdbcType="VARCHAR"/>
+            <result property="fileType" column="file_type" jdbcType="VARCHAR"/>
+            <result property="isDel" column="is_del" jdbcType="TINYINT"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,title,detail,
+        start,end,overlap,
+        editable,color,file,
+        file_type,is_del
+    </sql>
+</mapper>

BIN
java/target/classes/boot/modules/calendar/param/CalendarParam.class


BIN
java/target/classes/boot/modules/calendar/pojo/Calendar.class


BIN
java/target/classes/boot/modules/calendar/respond/CalendarDTO.class


BIN
java/target/classes/boot/modules/calendar/service/CalendarService.class


BIN
java/target/classes/boot/modules/calendar/service/impl/CalendarServiceImpl.class