ソースを参照

新增投票记录

tjf 7 ヶ月 前
コミット
069342b7a6

+ 99 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/vote/VoteResultController.java

@@ -0,0 +1,99 @@
+package com.ruoyi.web.controller.vote;
+
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.system.domain.VoteResult;
+import com.ruoyi.system.service.IVoteResultService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 投票结果Controller
+ *
+ * @author boman
+ * @date 2024-11-15
+ */
+@RestController
+@RequestMapping("/voteResult")
+public class VoteResultController extends BaseController {
+    @Autowired
+    private IVoteResultService voteResultService;
+
+    /**
+     * 查询投票结果列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:result:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(VoteResult voteResult) {
+        List<VoteResult> list = voteResultService.selectVoteResultList(voteResult);
+        return getDataTable(list);
+    }
+
+    /**
+     * 前端查询投票结果前端
+     */
+    @PreAuthorize("@ss.hasPermi('system:result:statistics')")
+    @PostMapping("/statistics")
+    public AjaxResult statistics(@RequestBody VoteResult voteResult) {
+        return voteResultService.statistics(voteResult);
+    }
+
+    /**
+     * 导出投票结果列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:result:export')")
+    @Log(title = "投票结果", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, VoteResult voteResult) {
+        List<VoteResult> list = voteResultService.selectVoteResultList(voteResult);
+        ExcelUtil<VoteResult> util = new ExcelUtil<VoteResult>(VoteResult.class);
+        util.exportExcel(response, list, "投票结果数据");
+    }
+
+    /**
+     * 获取投票结果详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:result:query')")
+    @GetMapping(value = "/{voteResultId}")
+    public AjaxResult getInfo(@PathVariable("voteResultId") Long voteResultId) {
+        return success(voteResultService.selectVoteResultByVoteResultId(voteResultId));
+    }
+
+    /**
+     * 新增投票结果
+     */
+    @PreAuthorize("@ss.hasPermi('system:result:add')")
+    @Log(title = "投票结果", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody VoteResult voteResult) {
+        return toAjax(voteResultService.insertVoteResult(voteResult));
+    }
+
+    /**
+     * 修改投票结果
+     */
+    @PreAuthorize("@ss.hasPermi('system:result:edit')")
+    @Log(title = "投票结果", businessType = BusinessType.UPDATE)
+    @PostMapping("/put")
+    public AjaxResult edit(@RequestBody VoteResult voteResult) {
+        return toAjax(voteResultService.updateVoteResult(voteResult));
+    }
+
+    /**
+     * 删除投票结果
+     */
+    @PreAuthorize("@ss.hasPermi('system:result:remove')")
+    @Log(title = "投票结果", businessType = BusinessType.DELETE)
+    @GetMapping("/delete/{voteResultIds}")
+    public AjaxResult remove(@PathVariable Long[] voteResultIds) {
+        return toAjax(voteResultService.deleteVoteResultByVoteResultIds(voteResultIds));
+    }
+}

+ 91 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/vote/VoteThemeController.java

@@ -0,0 +1,91 @@
+package com.ruoyi.web.controller.vote;
+
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.system.domain.VoteTheme;
+import com.ruoyi.system.service.IVoteThemeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * 投票主题Controller
+ *
+ * @author boman
+ * @date 2024-11-15
+ */
+@RestController
+@RequestMapping("/theme")
+public class VoteThemeController extends BaseController {
+    @Autowired
+    private IVoteThemeService voteThemeService;
+
+    /**
+     * 查询投票主题列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:theme:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(VoteTheme voteTheme) {
+        startPage();
+        List<VoteTheme> list = voteThemeService.selectVoteThemeList(voteTheme);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出投票主题列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:theme:export')")
+    @Log(title = "投票主题", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, VoteTheme voteTheme) {
+        List<VoteTheme> list = voteThemeService.selectVoteThemeList(voteTheme);
+        ExcelUtil<VoteTheme> util = new ExcelUtil<VoteTheme>(VoteTheme.class);
+        util.exportExcel(response, list, "投票主题数据");
+    }
+
+    /**
+     * 获取投票主题详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:theme:query')")
+    @GetMapping(value = "/{themeId}")
+    public AjaxResult getInfo(@PathVariable("themeId") Long themeId) {
+        return success(voteThemeService.selectVoteThemeByThemeId(themeId));
+    }
+
+    /**
+     * 新增投票主题
+     */
+    @PreAuthorize("@ss.hasPermi('system:theme:add')")
+    @Log(title = "投票主题", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody VoteTheme voteTheme) {
+        return voteThemeService.insertVoteTheme(voteTheme);
+    }
+
+    /**
+     * 修改投票主题
+     */
+    @PreAuthorize("@ss.hasPermi('system:theme:edit')")
+    @Log(title = "投票主题", businessType = BusinessType.UPDATE)
+    @PostMapping("/put")
+    public AjaxResult edit(@RequestBody VoteTheme voteTheme) {
+        return toAjax(voteThemeService.updateVoteTheme(voteTheme));
+    }
+
+    /**
+     * 删除投票主题
+     */
+    @PreAuthorize("@ss.hasPermi('system:theme:remove')")
+    @Log(title = "投票主题", businessType = BusinessType.DELETE)
+    @GetMapping("/delete/{themeIds}")
+    public AjaxResult remove(@PathVariable Long[] themeIds) {
+        return toAjax(voteThemeService.deleteVoteThemeByThemeIds(themeIds));
+    }
+}

+ 64 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/VoteOption.java

@@ -0,0 +1,64 @@
+package com.ruoyi.system.domain;
+
+import com.ruoyi.common.annotation.Excel;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 投票选项对象 vote_option
+ * 
+ * @author boman
+ * @date 2024-11-15
+ */
+public class VoteOption
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 选项ID,主键 */
+    private Long optionId;
+
+    /** 选项名称 */
+    @Excel(name = "选项名称")
+    private String optionName;
+
+    /** 所属主题ID */
+    @Excel(name = "所属主题ID")
+    private Long themeId;
+
+    public void setOptionId(Long optionId) 
+    {
+        this.optionId = optionId;
+    }
+
+    public Long getOptionId() 
+    {
+        return optionId;
+    }
+    public void setOptionName(String optionName) 
+    {
+        this.optionName = optionName;
+    }
+
+    public String getOptionName() 
+    {
+        return optionName;
+    }
+    public void setThemeId(Long themeId) 
+    {
+        this.themeId = themeId;
+    }
+
+    public Long getThemeId() 
+    {
+        return themeId;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("optionId", getOptionId())
+            .append("optionName", getOptionName())
+            .append("themeId", getThemeId())
+            .toString();
+    }
+}

+ 151 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/VoteResult.java

@@ -0,0 +1,151 @@
+package com.ruoyi.system.domain;
+
+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;
+
+/**
+ * 投票结果对象 vote_result
+ * 
+ * @author boman
+ * @date 2024-11-15
+ */
+public class VoteResult extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 投票结果ID */
+    private Long voteResultId;
+
+    /** 所属主题ID */
+    @Excel(name = "所属主题ID")
+    private Long themeId;
+
+    /** 投票标题 */
+    @Excel(name = "投票标题")
+    private String themeContent;
+
+    /** 选项ID */
+    @Excel(name = "选项ID")
+    private Long optionId;
+
+    /** 选项名称 */
+    @Excel(name = "选项名称")
+    private String optionName;
+
+    /** 会议id(关联会议预约表) */
+    @Excel(name = "会议id(关联会议预约表)")
+    private Long conferenceRoomOrderId;
+
+    /** 投票人ID */
+    @Excel(name = "投票人ID")
+    private Long userId;
+
+    /** 投票人头像地址 */
+    @Excel(name = "投票人头像地址")
+    private String avatar;
+
+    /** 投票人昵称 */
+    @Excel(name = "投票人昵称")
+    private String nickName;
+
+    public Long getConferenceRoomOrderId() {
+        return conferenceRoomOrderId;
+    }
+
+    public void setConferenceRoomOrderId(Long conferenceRoomOrderId) {
+        this.conferenceRoomOrderId = conferenceRoomOrderId;
+    }
+
+    public void setVoteResultId(Long voteResultId)
+    {
+        this.voteResultId = voteResultId;
+    }
+
+    public Long getVoteResultId() 
+    {
+        return voteResultId;
+    }
+    public void setThemeId(Long themeId) 
+    {
+        this.themeId = themeId;
+    }
+
+    public Long getThemeId() 
+    {
+        return themeId;
+    }
+    public void setThemeContent(String themeContent) 
+    {
+        this.themeContent = themeContent;
+    }
+
+    public String getThemeContent() 
+    {
+        return themeContent;
+    }
+    public void setOptionId(Long optionId) 
+    {
+        this.optionId = optionId;
+    }
+
+    public Long getOptionId() 
+    {
+        return optionId;
+    }
+    public void setOptionName(String optionName) 
+    {
+        this.optionName = optionName;
+    }
+
+    public String getOptionName() 
+    {
+        return optionName;
+    }
+    public void setUserId(Long userId) 
+    {
+        this.userId = userId;
+    }
+
+    public Long getUserId() 
+    {
+        return userId;
+    }
+    public void setAvatar(String avatar) 
+    {
+        this.avatar = avatar;
+    }
+
+    public String getAvatar() 
+    {
+        return avatar;
+    }
+    public void setNickName(String nickName) 
+    {
+        this.nickName = nickName;
+    }
+
+    public String getNickName() 
+    {
+        return nickName;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("voteResultId", getVoteResultId())
+            .append("themeId", getThemeId())
+            .append("themeContent", getThemeContent())
+            .append("optionId", getOptionId())
+            .append("optionName", getOptionName())
+            .append("userId", getUserId())
+            .append("avatar", getAvatar())
+            .append("nickName", getNickName())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .append("remark", getRemark())
+            .toString();
+    }
+}

+ 79 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/VoteTheme.java

@@ -0,0 +1,79 @@
+package com.ruoyi.system.domain;
+
+import com.ruoyi.common.annotation.Excel;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import java.util.List;
+
+/**
+ * 投票主题对象 vote_theme
+ * 
+ * @author boman
+ * @date 2024-11-15
+ */
+public class VoteTheme
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 投票主题ID,主键 */
+    private Long themeId;
+
+    /** 投票标题 */
+    @Excel(name = "投票标题")
+    private String themeContent;
+
+    /** 所属会议ID */
+    @Excel(name = "所属会议ID")
+    private Long conferenceRoomOrderId;
+
+    /** 投票选项信息 */
+    private List<VoteOption> voteOptionList;
+
+    public void setThemeId(Long themeId) 
+    {
+        this.themeId = themeId;
+    }
+
+    public Long getThemeId() 
+    {
+        return themeId;
+    }
+    public void setThemeContent(String themeContent) 
+    {
+        this.themeContent = themeContent;
+    }
+
+    public String getThemeContent() 
+    {
+        return themeContent;
+    }
+
+    public Long getConferenceRoomOrderId() {
+        return conferenceRoomOrderId;
+    }
+
+    public void setConferenceRoomOrderId(Long conferenceRoomOrderId) {
+        this.conferenceRoomOrderId = conferenceRoomOrderId;
+    }
+
+    public List<VoteOption> getVoteOptionList()
+    {
+        return voteOptionList;
+    }
+
+    public void setVoteOptionList(List<VoteOption> voteOptionList)
+    {
+        this.voteOptionList = voteOptionList;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("themeId", getThemeId())
+            .append("themeContent", getThemeContent())
+            .append("conferenceRoomOrderId", getConferenceRoomOrderId())
+            .append("voteOptionList", getVoteOptionList())
+            .toString();
+    }
+}

+ 62 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/VoteResultMapper.java

@@ -0,0 +1,62 @@
+package com.ruoyi.system.mapper;
+
+import com.ruoyi.system.domain.VoteResult;
+
+import java.util.List;
+
+/**
+ * 投票结果Mapper接口
+ * 
+ * @author boman
+ * @date 2024-11-15
+ */
+public interface VoteResultMapper 
+{
+    /**
+     * 查询投票结果
+     * 
+     * @param voteResultId 投票结果主键
+     * @return 投票结果
+     */
+    public VoteResult selectVoteResultByVoteResultId(Long voteResultId);
+
+    /**
+     * 查询投票结果列表
+     * 
+     * @param voteResult 投票结果
+     * @return 投票结果集合
+     */
+    public List<VoteResult> selectVoteResultList(VoteResult voteResult);
+
+    /**
+     * 新增投票结果
+     * 
+     * @param voteResult 投票结果
+     * @return 结果
+     */
+    public int insertVoteResult(VoteResult voteResult);
+
+    /**
+     * 修改投票结果
+     * 
+     * @param voteResult 投票结果
+     * @return 结果
+     */
+    public int updateVoteResult(VoteResult voteResult);
+
+    /**
+     * 删除投票结果
+     * 
+     * @param voteResultId 投票结果主键
+     * @return 结果
+     */
+    public int deleteVoteResultByVoteResultId(Long voteResultId);
+
+    /**
+     * 批量删除投票结果
+     * 
+     * @param voteResultIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteVoteResultByVoteResultIds(Long[] voteResultIds);
+}

+ 89 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/VoteThemeMapper.java

@@ -0,0 +1,89 @@
+package com.ruoyi.system.mapper;
+
+import com.ruoyi.system.domain.VoteOption;
+import com.ruoyi.system.domain.VoteTheme;
+
+import java.util.List;
+
+/**
+ * 投票主题Mapper接口
+ * 
+ * @author boman
+ * @date 2024-11-15
+ */
+public interface VoteThemeMapper 
+{
+    /**
+     * 查询投票主题
+     * 
+     * @param themeId 投票主题主键
+     * @return 投票主题
+     */
+    public VoteTheme selectVoteThemeByThemeId(Long themeId);
+    public List<VoteTheme> selectVoteThemeByConferenceRoomOrderId(Long conferenceRoomOrderId);
+
+    /**
+     * 查询投票主题列表
+     * 
+     * @param voteTheme 投票主题
+     * @return 投票主题集合
+     */
+    public List<VoteTheme> selectVoteThemeList(VoteTheme voteTheme);
+
+    /**
+     * 新增投票主题
+     * 
+     * @param voteTheme 投票主题
+     * @return 结果
+     */
+    public int insertVoteTheme(VoteTheme voteTheme);
+
+    /**
+     * 修改投票主题
+     * 
+     * @param voteTheme 投票主题
+     * @return 结果
+     */
+    public int updateVoteTheme(VoteTheme voteTheme);
+
+    /**
+     * 删除投票主题
+     * 
+     * @param themeId 投票主题主键
+     * @return 结果
+     */
+    public int deleteVoteThemeByThemeId(Long themeId);
+
+    /**
+     * 批量删除投票主题
+     * 
+     * @param themeIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteVoteThemeByThemeIds(Long[] themeIds);
+
+    /**
+     * 批量删除投票选项
+     * 
+     * @param themeIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteVoteOptionByThemeIds(Long[] themeIds);
+    
+    /**
+     * 批量新增投票选项
+     * 
+     * @param voteOptionList 投票选项列表
+     * @return 结果
+     */
+    public int batchVoteOption(List<VoteOption> voteOptionList);
+    
+
+    /**
+     * 通过投票主题主键删除投票选项信息
+     * 
+     * @param themeId 投票主题ID
+     * @return 结果
+     */
+    public int deleteVoteOptionByThemeId(Long themeId);
+}

+ 70 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IVoteResultService.java

@@ -0,0 +1,70 @@
+package com.ruoyi.system.service;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.system.domain.VoteResult;
+
+import java.util.List;
+
+/**
+ * 投票结果Service接口
+ * 
+ * @author boman
+ * @date 2024-11-15
+ */
+public interface IVoteResultService 
+{
+    /**
+     * 查询投票结果
+     * 
+     * @param voteResultId 投票结果主键
+     * @return 投票结果
+     */
+    public VoteResult selectVoteResultByVoteResultId(Long voteResultId);
+
+    /**
+     * 查询投票结果列表
+     * 
+     * @param voteResult 投票结果
+     * @return 投票结果集合
+     */
+    public List<VoteResult> selectVoteResultList(VoteResult voteResult);
+
+    /**
+     * 前端查询投票结果前端
+     * @param voteResult
+     * @return
+     */
+    public AjaxResult statistics(VoteResult voteResult);
+
+    /**
+     * 新增投票结果
+     * 
+     * @param voteResult 投票结果
+     * @return 结果
+     */
+    public int insertVoteResult(VoteResult voteResult);
+
+    /**
+     * 修改投票结果
+     * 
+     * @param voteResult 投票结果
+     * @return 结果
+     */
+    public int updateVoteResult(VoteResult voteResult);
+
+    /**
+     * 批量删除投票结果
+     * 
+     * @param voteResultIds 需要删除的投票结果主键集合
+     * @return 结果
+     */
+    public int deleteVoteResultByVoteResultIds(Long[] voteResultIds);
+
+    /**
+     * 删除投票结果信息
+     * 
+     * @param voteResultId 投票结果主键
+     * @return 结果
+     */
+    public int deleteVoteResultByVoteResultId(Long voteResultId);
+}

+ 62 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IVoteThemeService.java

@@ -0,0 +1,62 @@
+package com.ruoyi.system.service;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.system.domain.VoteTheme;
+import java.util.List;
+
+/**
+ * 投票主题Service接口
+ * 
+ * @author boman
+ * @date 2024-11-15
+ */
+public interface IVoteThemeService 
+{
+    /**
+     * 查询投票主题
+     * 
+     * @param themeId 投票主题主键
+     * @return 投票主题
+     */
+    public VoteTheme selectVoteThemeByThemeId(Long themeId);
+
+    /**
+     * 查询投票主题列表
+     * 
+     * @param voteTheme 投票主题
+     * @return 投票主题集合
+     */
+    public List<VoteTheme> selectVoteThemeList(VoteTheme voteTheme);
+
+    /**
+     * 新增投票主题
+     * 
+     * @param voteTheme 投票主题
+     * @return 结果
+     */
+    public AjaxResult insertVoteTheme(VoteTheme voteTheme);
+
+    /**
+     * 修改投票主题
+     * 
+     * @param voteTheme 投票主题
+     * @return 结果
+     */
+    public int updateVoteTheme(VoteTheme voteTheme);
+
+    /**
+     * 批量删除投票主题
+     * 
+     * @param themeIds 需要删除的投票主题主键集合
+     * @return 结果
+     */
+    public int deleteVoteThemeByThemeIds(Long[] themeIds);
+
+    /**
+     * 删除投票主题信息
+     * 
+     * @param themeId 投票主题主键
+     * @return 结果
+     */
+    public int deleteVoteThemeByThemeId(Long themeId);
+}

+ 158 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/VoteResultServiceImpl.java

@@ -0,0 +1,158 @@
+package com.ruoyi.system.service.impl;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.system.domain.VoteOption;
+import com.ruoyi.system.domain.VoteResult;
+import com.ruoyi.system.domain.VoteTheme;
+import com.ruoyi.system.mapper.VoteResultMapper;
+import com.ruoyi.system.mapper.VoteThemeMapper;
+import com.ruoyi.system.service.IVoteResultService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * 投票结果Service业务层处理
+ * 
+ * @author boman
+ * @date 2024-11-15
+ */
+@Service
+public class VoteResultServiceImpl implements IVoteResultService 
+{
+    @Autowired
+    private VoteResultMapper voteResultMapper;
+    @Autowired
+    private VoteThemeMapper voteThemeMapper;
+
+    /**
+     * 查询投票结果
+     * 
+     * @param voteResultId 投票结果主键
+     * @return 投票结果
+     */
+    @Override
+    public VoteResult selectVoteResultByVoteResultId(Long voteResultId)
+    {
+        return voteResultMapper.selectVoteResultByVoteResultId(voteResultId);
+    }
+
+    /**
+     * 查询投票结果列表
+     * 
+     * @param voteResult 投票结果
+     * @return 投票结果
+     */
+    @Override
+    public List<VoteResult> selectVoteResultList(VoteResult voteResult)
+    {
+        return voteResultMapper.selectVoteResultList(voteResult);
+    }
+
+    /**
+     * 前端查询投票结果前端
+     * @param voteResult
+     * @return
+     */
+    @Override
+    public AjaxResult statistics(VoteResult voteResult) {
+        List<VoteTheme> voteThemes = voteThemeMapper.selectVoteThemeByConferenceRoomOrderId(voteResult.getConferenceRoomOrderId());
+        if (voteThemes.size() > 0){
+            //根据会议预约id conferenceRoomOrderId 查询所有投票记录
+            List<VoteResult> voteResults = voteResultMapper.selectVoteResultList(voteResult);
+            List<Map<String,Object>> list = new ArrayList<>();
+            for (VoteTheme voteTheme : voteThemes) {
+                Map<String,Object> themeMap = new HashMap<>();
+                List<Map<String,Object>> optionList = new ArrayList<>();
+                //标题id
+                themeMap.put("themeId",voteTheme.getThemeId());
+                //标题
+                themeMap.put("themeContent",voteTheme.getThemeContent());
+                //总人数
+                themeMap.put("total",0);
+                //选项
+                themeMap.put("voteOptionList",optionList);
+                if (voteResults.size() > 0){
+                    Map<Long, List<VoteResult>> voteResultList = voteResults.stream().collect(Collectors.groupingBy(VoteResult::getThemeId));
+                    if (voteResultList.get(voteTheme.getThemeId()) != null && voteResultList.get(voteTheme.getThemeId()).size() >0){
+                        themeMap.put("total",voteResultList.get(voteTheme.getThemeId()).size());
+                    }
+                }
+                List<VoteOption> voteOptionList = voteTheme.getVoteOptionList();
+                for (VoteOption voteOption : voteOptionList) {
+                    Map<String,Object> optionMap = new HashMap<>(3);
+                    optionMap.put("optionId",voteOption.getOptionId());
+                    optionMap.put("optionName",voteOption.getOptionName());
+                    optionMap.put("total",0);
+                    //投票记录根据投票选项进行分组
+                    Map<Long, List<VoteResult>> voteResultsOptionIdValue = voteResults.stream().collect(Collectors.groupingBy(VoteResult::getOptionId));
+                    if (voteResultsOptionIdValue.size() > 0){
+                        if (voteResultsOptionIdValue.get(voteOption.getOptionId()) != null && voteResultsOptionIdValue.get(voteOption.getOptionId()).size() > 0){
+                            optionMap.put("total",voteResultsOptionIdValue.get(voteOption.getOptionId()).size());
+                        }
+                    }
+                    optionList.add(optionMap);
+                }
+                list.add(themeMap);
+            }
+            return AjaxResult.success(list);
+        }
+        return AjaxResult.error();
+    }
+
+    /**
+     * 新增投票结果
+     * 
+     * @param voteResult 投票结果
+     * @return 结果
+     */
+    @Override
+    public int insertVoteResult(VoteResult voteResult)
+    {
+        voteResult.setCreateTime(DateUtils.getNowDate());
+        return voteResultMapper.insertVoteResult(voteResult);
+    }
+
+    /**
+     * 修改投票结果
+     * 
+     * @param voteResult 投票结果
+     * @return 结果
+     */
+    @Override
+    public int updateVoteResult(VoteResult voteResult)
+    {
+        voteResult.setUpdateTime(DateUtils.getNowDate());
+        return voteResultMapper.updateVoteResult(voteResult);
+    }
+
+    /**
+     * 批量删除投票结果
+     * 
+     * @param voteResultIds 需要删除的投票结果主键
+     * @return 结果
+     */
+    @Override
+    public int deleteVoteResultByVoteResultIds(Long[] voteResultIds)
+    {
+        return voteResultMapper.deleteVoteResultByVoteResultIds(voteResultIds);
+    }
+
+    /**
+     * 删除投票结果信息
+     * 
+     * @param voteResultId 投票结果主键
+     * @return 结果
+     */
+    @Override
+    public int deleteVoteResultByVoteResultId(Long voteResultId)
+    {
+        return voteResultMapper.deleteVoteResultByVoteResultId(voteResultId);
+    }
+}

+ 127 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/VoteThemeServiceImpl.java

@@ -0,0 +1,127 @@
+package com.ruoyi.system.service.impl;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.domain.VoteOption;
+import com.ruoyi.system.domain.VoteTheme;
+import com.ruoyi.system.mapper.VoteThemeMapper;
+import com.ruoyi.system.service.IVoteThemeService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 投票主题Service业务层处理
+ *
+ * @author boman
+ * @date 2024-11-15
+ */
+@Service
+public class VoteThemeServiceImpl implements IVoteThemeService {
+    @Autowired
+    private VoteThemeMapper voteThemeMapper;
+
+    /**
+     * 查询投票主题
+     *
+     * @param themeId 投票主题主键
+     * @return 投票主题
+     */
+    @Override
+    public VoteTheme selectVoteThemeByThemeId(Long themeId) {
+        return voteThemeMapper.selectVoteThemeByThemeId(themeId);
+    }
+
+    /**
+     * 查询投票主题列表
+     *
+     * @param voteTheme 投票主题
+     * @return 投票主题
+     */
+    @Override
+    public List<VoteTheme> selectVoteThemeList(VoteTheme voteTheme) {
+        return voteThemeMapper.selectVoteThemeList(voteTheme);
+    }
+
+    /**
+     * 新增投票主题
+     *
+     * @param voteTheme 投票主题
+     * @return 结果
+     */
+    @Transactional
+    @Override
+    public AjaxResult insertVoteTheme(VoteTheme voteTheme) {
+        int rows = voteThemeMapper.insertVoteTheme(voteTheme);
+        insertVoteOption(voteTheme);
+        if (rows > 0) {
+            VoteTheme voteThemeBack = voteThemeMapper.selectVoteThemeByThemeId(voteTheme.getThemeId());
+            return AjaxResult.success(voteThemeBack);
+        } else {
+            return AjaxResult.error();
+        }
+    }
+
+    /**
+     * 修改投票主题
+     *
+     * @param voteTheme 投票主题
+     * @return 结果
+     */
+    @Transactional
+    @Override
+    public int updateVoteTheme(VoteTheme voteTheme) {
+        voteThemeMapper.deleteVoteOptionByThemeId(voteTheme.getThemeId());
+        insertVoteOption(voteTheme);
+        return voteThemeMapper.updateVoteTheme(voteTheme);
+    }
+
+    /**
+     * 批量删除投票主题
+     *
+     * @param themeIds 需要删除的投票主题主键
+     * @return 结果
+     */
+    @Transactional
+    @Override
+    public int deleteVoteThemeByThemeIds(Long[] themeIds) {
+        voteThemeMapper.deleteVoteOptionByThemeIds(themeIds);
+        return voteThemeMapper.deleteVoteThemeByThemeIds(themeIds);
+    }
+
+    /**
+     * 删除投票主题信息
+     *
+     * @param themeId 投票主题主键
+     * @return 结果
+     */
+    @Transactional
+    @Override
+    public int deleteVoteThemeByThemeId(Long themeId) {
+        voteThemeMapper.deleteVoteOptionByThemeId(themeId);
+        return voteThemeMapper.deleteVoteThemeByThemeId(themeId);
+    }
+
+    /**
+     * 新增投票选项信息
+     *
+     * @param voteTheme 投票主题对象
+     */
+    public void insertVoteOption(VoteTheme voteTheme) {
+        List<VoteOption> voteOptionList = voteTheme.getVoteOptionList();
+        Long themeId = voteTheme.getThemeId();
+        if (StringUtils.isNotNull(voteOptionList)) {
+            List<VoteOption> list = new ArrayList<VoteOption>();
+            for (VoteOption voteOption : voteOptionList) {
+                voteOption.setThemeId(themeId);
+                list.add(voteOption);
+            }
+            if (list.size() > 0) {
+                voteThemeMapper.batchVoteOption(list);
+            }
+        }
+    }
+}

+ 107 - 0
ruoyi-system/src/main/resources/mapper/system/VoteResultMapper.xml

@@ -0,0 +1,107 @@
+<?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="com.ruoyi.system.mapper.VoteResultMapper">
+    
+    <resultMap type="VoteResult" id="VoteResultResult">
+        <result property="voteResultId"    column="vote_result_id"    />
+        <result property="themeId"    column="theme_id"    />
+        <result property="themeContent"    column="theme_content"    />
+        <result property="optionId"    column="option_id"    />
+        <result property="optionName"    column="option_name"    />
+        <result property="conferenceRoomOrderId"    column="conference_room_order_id"    />
+        <result property="userId"    column="user_id"    />
+        <result property="avatar"    column="avatar"    />
+        <result property="nickName"    column="nick_name"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+    <sql id="selectVoteResultVo">
+        select vote_result_id, theme_id, theme_content, option_id, option_name,conference_room_order_id, user_id, avatar, nick_name, create_time, update_by, update_time, remark from vote_result
+    </sql>
+
+    <select id="selectVoteResultList" parameterType="VoteResult" resultMap="VoteResultResult">
+        <include refid="selectVoteResultVo"/>
+        <where>  
+            <if test="themeId != null "> and theme_id = #{themeId}</if>
+            <if test="themeContent != null  and themeContent != ''"> and theme_content = #{themeContent}</if>
+            <if test="optionId != null "> and option_id = #{optionId}</if>
+            <if test="optionName != null  and optionName != ''"> and option_name like concat('%', #{optionName}, '%')</if>
+            <if test="conferenceRoomOrderId != null "> and conference_room_order_id = #{conferenceRoomOrderId}</if>
+            <if test="userId != null "> and user_id = #{userId}</if>
+            <if test="avatar != null  and avatar != ''"> and avatar = #{avatar}</if>
+            <if test="nickName != null  and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
+        </where>
+    </select>
+    
+    <select id="selectVoteResultByVoteResultId" parameterType="Long" resultMap="VoteResultResult">
+        <include refid="selectVoteResultVo"/>
+        where vote_result_id = #{voteResultId}
+    </select>
+        
+    <insert id="insertVoteResult" parameterType="VoteResult" useGeneratedKeys="true" keyProperty="voteResultId">
+        insert into vote_result
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="themeId != null">theme_id,</if>
+            <if test="themeContent != null and themeContent != ''">theme_content,</if>
+            <if test="optionId != null">option_id,</if>
+            <if test="optionName != null and optionName != ''">option_name,</if>
+            <if test="conferenceRoomOrderId != null">conference_room_order_id,</if>
+            <if test="userId != null">user_id,</if>
+            <if test="avatar != null">avatar,</if>
+            <if test="nickName != null and nickName != ''">nick_name,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="themeId != null">#{themeId},</if>
+            <if test="themeContent != null and themeContent != ''">#{themeContent},</if>
+            <if test="optionId != null">#{optionId},</if>
+            <if test="optionName != null and optionName != ''">#{optionName},</if>
+            <if test="conferenceRoomOrderId != null">#{conferenceRoomOrderId},</if>
+            <if test="userId != null">#{userId},</if>
+            <if test="avatar != null">#{avatar},</if>
+            <if test="nickName != null and nickName != ''">#{nickName},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateVoteResult" parameterType="VoteResult">
+        update vote_result
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="themeId != null">theme_id = #{themeId},</if>
+            <if test="themeContent != null and themeContent != ''">theme_content = #{themeContent},</if>
+            <if test="optionId != null">option_id = #{optionId},</if>
+            <if test="optionName != null and optionName != ''">option_name = #{optionName},</if>
+            <if test="conferenceRoomOrderId != null">conference_room_order_id = #{conferenceRoomOrderId},</if>
+            <if test="userId != null">user_id = #{userId},</if>
+            <if test="avatar != null">avatar = #{avatar},</if>
+            <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        where vote_result_id = #{voteResultId}
+    </update>
+
+    <delete id="deleteVoteResultByVoteResultId" parameterType="Long">
+        delete from vote_result where vote_result_id = #{voteResultId}
+    </delete>
+
+    <delete id="deleteVoteResultByVoteResultIds" parameterType="String">
+        delete from vote_result where vote_result_id in 
+        <foreach item="voteResultId" collection="array" open="(" separator="," close=")">
+            #{voteResultId}
+        </foreach>
+    </delete>
+</mapper>

+ 112 - 0
ruoyi-system/src/main/resources/mapper/system/VoteThemeMapper.xml

@@ -0,0 +1,112 @@
+<?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="com.ruoyi.system.mapper.VoteThemeMapper">
+
+    <resultMap type="VoteTheme" id="VoteThemeResult">
+        <result property="themeId" column="theme_id"/>
+        <result property="themeContent" column="theme_content"/>
+        <result property="conferenceRoomOrderId" column="conference_room_order_id"/>
+    </resultMap>
+
+    <resultMap id="VoteThemeVoteOptionResult" type="VoteTheme" extends="VoteThemeResult">
+        <collection property="voteOptionList" notNullColumn="sub_option_id" javaType="java.util.List"
+                    resultMap="VoteOptionResult"/>
+    </resultMap>
+
+    <resultMap type="VoteOption" id="VoteOptionResult">
+        <result property="optionId" column="sub_option_id"/>
+        <result property="optionName" column="sub_option_name"/>
+        <result property="themeId" column="sub_theme_id"/>
+    </resultMap>
+
+    <sql id="selectVoteThemeVo">
+        select theme_id, theme_content, conference_room_order_id
+        from vote_theme
+    </sql>
+
+    <select id="selectVoteThemeList" parameterType="VoteTheme" resultMap="VoteThemeResult">
+        <include refid="selectVoteThemeVo"/>
+        <where>
+            <if test="themeContent != null  and themeContent != ''">and theme_content = #{themeContent}</if>
+            <if test="conferenceRoomOrderId != null ">and conference_room_order_id = #{conferenceRoomOrderId}</if>
+        </where>
+    </select>
+
+    <select id="selectVoteThemeByThemeId" parameterType="Long" resultMap="VoteThemeVoteOptionResult">
+        select a.theme_id,
+               a.theme_content,
+               a.conference_room_order_id,
+               b.option_id   as sub_option_id,
+               b.option_name as sub_option_name,
+               b.theme_id    as sub_theme_id
+        from vote_theme a
+                 left join vote_option b on b.theme_id = a.theme_id
+        where a.theme_id = #{themeId}
+    </select>
+    <select id="selectVoteThemeByConferenceRoomOrderId" parameterType="Long" resultMap="VoteThemeVoteOptionResult">
+        select a.theme_id,
+               a.theme_content,
+               a.conference_room_order_id,
+               b.option_id   as sub_option_id,
+               b.option_name as sub_option_name,
+               b.theme_id    as sub_theme_id
+        from vote_theme a
+                 left join vote_option b on b.theme_id = a.theme_id
+        where a.conference_room_order_id = #{ConferenceRoomOrderId}
+    </select>
+    <insert id="insertVoteTheme" parameterType="VoteTheme" useGeneratedKeys="true" keyProperty="themeId">
+        insert into vote_theme
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="themeContent != null and themeContent != ''">theme_content,</if>
+            <if test="conferenceRoomOrderId != null">conference_room_order_id,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="themeContent != null and themeContent != ''">#{themeContent},</if>
+            <if test="conferenceRoomOrderId != null">#{conferenceRoomOrderId},</if>
+        </trim>
+    </insert>
+
+    <update id="updateVoteTheme" parameterType="VoteTheme">
+        update vote_theme
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="themeContent != null and themeContent != ''">theme_content = #{themeContent},</if>
+            <if test="conferenceRoomOrderId != null">conference_room_order_id = #{conferenceRoomOrderId},</if>
+        </trim>
+        where theme_id = #{themeId}
+    </update>
+
+    <delete id="deleteVoteThemeByThemeId" parameterType="Long">
+        delete
+        from vote_theme
+        where theme_id = #{themeId}
+    </delete>
+
+    <delete id="deleteVoteThemeByThemeIds" parameterType="String">
+        delete from vote_theme where theme_id in
+        <foreach item="themeId" collection="array" open="(" separator="," close=")">
+            #{themeId}
+        </foreach>
+    </delete>
+
+    <delete id="deleteVoteOptionByThemeIds" parameterType="String">
+        delete from vote_option where theme_id in
+        <foreach item="themeId" collection="array" open="(" separator="," close=")">
+            #{themeId}
+        </foreach>
+    </delete>
+
+    <delete id="deleteVoteOptionByThemeId" parameterType="Long">
+        delete
+        from vote_option
+        where theme_id = #{themeId}
+    </delete>
+
+    <insert id="batchVoteOption">
+        insert into vote_option( option_id, option_name, theme_id) values
+        <foreach item="item" index="index" collection="list" separator=",">
+            ( #{item.optionId}, #{item.optionName}, #{item.themeId})
+        </foreach>
+    </insert>
+</mapper>