diff --git a/ruoyi-core/src/main/java/com/ruoyi/system/controller/EventController.java b/ruoyi-core/src/main/java/com/ruoyi/system/controller/EventController.java new file mode 100644 index 0000000..e8fa9a5 --- /dev/null +++ b/ruoyi-core/src/main/java/com/ruoyi/system/controller/EventController.java @@ -0,0 +1,103 @@ +package com.ruoyi.system.controller; + +import java.util.List; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.system.domain.Event; +import com.ruoyi.system.service.IEventService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 活动管理Controller + * + * @author ruoyi + * @date 2024-11-12 + */ +@RestController +@RequestMapping("/system/event") +public class EventController extends BaseController +{ + @Autowired + private IEventService eventService; + + /** + * 查询活动管理列表 + */ + @GetMapping("/list") + public TableDataInfo list(Event event) + { + startPage(); + List list = eventService.selectEventList(event); + return getDataTable(list); + } + + /** + * 导出活动管理列表 + */ + @PreAuthorize("@ss.hasPermi('system:event:export')") + @Log(title = "活动管理", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, Event event) + { + List list = eventService.selectEventList(event); + ExcelUtil util = new ExcelUtil(Event.class); + util.exportExcel(response, list, "活动管理数据"); + } + + /** + * 获取活动管理详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:event:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(eventService.selectEventById(id)); + } + + /** + * 新增活动管理 + */ + @PreAuthorize("@ss.hasPermi('system:event:add')") + @Log(title = "活动管理", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Event event) + { + return toAjax(eventService.insertEvent(event)); + } + + /** + * 修改活动管理 + */ + @PreAuthorize("@ss.hasPermi('system:event:edit')") + @Log(title = "活动管理", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Event event) + { + return toAjax(eventService.updateEvent(event)); + } + + /** + * 删除活动管理 + */ + @PreAuthorize("@ss.hasPermi('system:event:remove')") + @Log(title = "活动管理", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(eventService.deleteEventByIds(ids)); + } +} diff --git a/ruoyi-core/src/main/java/com/ruoyi/system/domain/Event.java b/ruoyi-core/src/main/java/com/ruoyi/system/domain/Event.java new file mode 100644 index 0000000..dfe08b7 --- /dev/null +++ b/ruoyi-core/src/main/java/com/ruoyi/system/domain/Event.java @@ -0,0 +1,97 @@ +package com.ruoyi.system.domain; + +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 活动管理对象 db_event + * + * @author ruoyi + * @date 2024-11-12 + */ +public class Event extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 活动ID */ + private Long id; + + /** 活动标题 */ + @Excel(name = "活动标题") + private String title; + + /** 活动地点 */ + @Excel(name = "活动地点") + private String location; + + /** 开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date startTime; + + /** 结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date endTime; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setTitle(String title) + { + this.title = title; + } + + public String getTitle() + { + return title; + } + public void setLocation(String location) + { + this.location = location; + } + + public String getLocation() + { + return location; + } + public void setStartTime(Date startTime) + { + this.startTime = startTime; + } + + public Date getStartTime() + { + return startTime; + } + public void setEndTime(Date endTime) + { + this.endTime = endTime; + } + + public Date getEndTime() + { + return endTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("title", getTitle()) + .append("location", getLocation()) + .append("startTime", getStartTime()) + .append("endTime", getEndTime()) + .toString(); + } +} diff --git a/ruoyi-core/src/main/java/com/ruoyi/system/mapper/EventMapper.java b/ruoyi-core/src/main/java/com/ruoyi/system/mapper/EventMapper.java new file mode 100644 index 0000000..5c8ef21 --- /dev/null +++ b/ruoyi-core/src/main/java/com/ruoyi/system/mapper/EventMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.Event; + +/** + * 活动管理Mapper接口 + * + * @author ruoyi + * @date 2024-11-12 + */ +public interface EventMapper +{ + /** + * 查询活动管理 + * + * @param id 活动管理主键 + * @return 活动管理 + */ + public Event selectEventById(Long id); + + /** + * 查询活动管理列表 + * + * @param event 活动管理 + * @return 活动管理集合 + */ + public List selectEventList(Event event); + + /** + * 新增活动管理 + * + * @param event 活动管理 + * @return 结果 + */ + public int insertEvent(Event event); + + /** + * 修改活动管理 + * + * @param event 活动管理 + * @return 结果 + */ + public int updateEvent(Event event); + + /** + * 删除活动管理 + * + * @param id 活动管理主键 + * @return 结果 + */ + public int deleteEventById(Long id); + + /** + * 批量删除活动管理 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteEventByIds(Long[] ids); +} diff --git a/ruoyi-core/src/main/java/com/ruoyi/system/service/IEventService.java b/ruoyi-core/src/main/java/com/ruoyi/system/service/IEventService.java new file mode 100644 index 0000000..568319e --- /dev/null +++ b/ruoyi-core/src/main/java/com/ruoyi/system/service/IEventService.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.Event; + +/** + * 活动管理Service接口 + * + * @author ruoyi + * @date 2024-11-12 + */ +public interface IEventService +{ + /** + * 查询活动管理 + * + * @param id 活动管理主键 + * @return 活动管理 + */ + public Event selectEventById(Long id); + + /** + * 查询活动管理列表 + * + * @param event 活动管理 + * @return 活动管理集合 + */ + public List selectEventList(Event event); + + /** + * 新增活动管理 + * + * @param event 活动管理 + * @return 结果 + */ + public int insertEvent(Event event); + + /** + * 修改活动管理 + * + * @param event 活动管理 + * @return 结果 + */ + public int updateEvent(Event event); + + /** + * 批量删除活动管理 + * + * @param ids 需要删除的活动管理主键集合 + * @return 结果 + */ + public int deleteEventByIds(Long[] ids); + + /** + * 删除活动管理信息 + * + * @param id 活动管理主键 + * @return 结果 + */ + public int deleteEventById(Long id); +} diff --git a/ruoyi-core/src/main/java/com/ruoyi/system/service/impl/EventServiceImpl.java b/ruoyi-core/src/main/java/com/ruoyi/system/service/impl/EventServiceImpl.java new file mode 100644 index 0000000..1d7a1ee --- /dev/null +++ b/ruoyi-core/src/main/java/com/ruoyi/system/service/impl/EventServiceImpl.java @@ -0,0 +1,93 @@ +package com.ruoyi.system.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.EventMapper; +import com.ruoyi.system.domain.Event; +import com.ruoyi.system.service.IEventService; + +/** + * 活动管理Service业务层处理 + * + * @author ruoyi + * @date 2024-11-12 + */ +@Service +public class EventServiceImpl implements IEventService +{ + @Autowired + private EventMapper eventMapper; + + /** + * 查询活动管理 + * + * @param id 活动管理主键 + * @return 活动管理 + */ + @Override + public Event selectEventById(Long id) + { + return eventMapper.selectEventById(id); + } + + /** + * 查询活动管理列表 + * + * @param event 活动管理 + * @return 活动管理 + */ + @Override + public List selectEventList(Event event) + { + return eventMapper.selectEventList(event); + } + + /** + * 新增活动管理 + * + * @param event 活动管理 + * @return 结果 + */ + @Override + public int insertEvent(Event event) + { + return eventMapper.insertEvent(event); + } + + /** + * 修改活动管理 + * + * @param event 活动管理 + * @return 结果 + */ + @Override + public int updateEvent(Event event) + { + return eventMapper.updateEvent(event); + } + + /** + * 批量删除活动管理 + * + * @param ids 需要删除的活动管理主键 + * @return 结果 + */ + @Override + public int deleteEventByIds(Long[] ids) + { + return eventMapper.deleteEventByIds(ids); + } + + /** + * 删除活动管理信息 + * + * @param id 活动管理主键 + * @return 结果 + */ + @Override + public int deleteEventById(Long id) + { + return eventMapper.deleteEventById(id); + } +} diff --git a/ruoyi-core/src/main/resources/mapper/system/EventMapper.xml b/ruoyi-core/src/main/resources/mapper/system/EventMapper.xml new file mode 100644 index 0000000..f58a9e1 --- /dev/null +++ b/ruoyi-core/src/main/resources/mapper/system/EventMapper.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + select id, title, location, start_time, end_time from db_event + + + + + + + + insert into db_event + + title, + location, + start_time, + end_time, + + + #{title}, + #{location}, + #{startTime}, + #{endTime}, + + + + + update db_event + + title = #{title}, + location = #{location}, + start_time = #{startTime}, + end_time = #{endTime}, + + where id = #{id} + + + + delete from db_event where id = #{id} + + + + delete from db_event where id in + + #{id} + + + \ No newline at end of file diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java index 6fb3de4..47309b1 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java @@ -115,7 +115,7 @@ public class SecurityConfig .requestMatchers("/login", "/register", "/captchaImage").permitAll() .requestMatchers(HttpMethod.GET, "/", "/*.html", "/**.html", "/**.css", "/**.js", "/profile/**").permitAll() .requestMatchers("/swagger-ui.html", "/v3/api-docs/**", "/swagger-ui/**", "/druid/**").permitAll() - .requestMatchers("/system/course/**", "/system/teacher/**", "/system/advice/**").permitAll() + .requestMatchers("/system/course/**", "/system/teacher/**", "/system/advice/**", "/system/event/**").permitAll() .anyRequest().authenticated(); }) // 添加Logout filter