From 2b49e8519df100330a88abb2d5d9d2791add1061 Mon Sep 17 00:00:00 2001 From: hshansha Date: Tue, 24 Jun 2025 08:38:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8A=95=E7=A5=A8=E9=A1=B9?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/KhVoteItemsController.java | 104 +++++++ .../com/ruoyi/kaohe/domain/KhVoteItems.java | 57 ++++ .../ruoyi/kaohe/mapper/KhVoteItemsMapper.java | 61 +++++ .../kaohe/service/IKhVoteItemsService.java | 61 +++++ .../service/impl/KhVoteItemsServiceImpl.java | 96 +++++++ ruoyi-ui/src/api/kaohe/vote_items.js | 44 +++ ruoyi-ui/src/views/kaohe/vote_items/index.vue | 254 ++++++++++++++++++ 7 files changed, 677 insertions(+) create mode 100644 ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhVoteItemsController.java create mode 100644 ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhVoteItems.java create mode 100644 ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/mapper/KhVoteItemsMapper.java create mode 100644 ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/IKhVoteItemsService.java create mode 100644 ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/impl/KhVoteItemsServiceImpl.java create mode 100644 ruoyi-ui/src/api/kaohe/vote_items.js create mode 100644 ruoyi-ui/src/views/kaohe/vote_items/index.vue diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhVoteItemsController.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhVoteItemsController.java new file mode 100644 index 0000000..5591c28 --- /dev/null +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhVoteItemsController.java @@ -0,0 +1,104 @@ +package com.ruoyi.kaohe.controller; + +import java.util.List; +import javax.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.kaohe.domain.KhVoteItems; +import com.ruoyi.kaohe.service.IKhVoteItemsService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 投票项Controller + * + * @author hs + * @date 2025-06-24 + */ +@RestController +@RequestMapping("/kaohe/vote_items") +public class KhVoteItemsController extends BaseController +{ + @Autowired + private IKhVoteItemsService khVoteItemsService; + + /** + * 查询投票项列表 + */ + @PreAuthorize("@ss.hasPermi('kaohe:vote_items:list')") + @GetMapping("/list") + public TableDataInfo list(KhVoteItems khVoteItems) + { + startPage(); + List list = khVoteItemsService.selectKhVoteItemsList(khVoteItems); + return getDataTable(list); + } + + /** + * 导出投票项列表 + */ + @PreAuthorize("@ss.hasPermi('kaohe:vote_items:export')") + @Log(title = "投票项", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, KhVoteItems khVoteItems) + { + List list = khVoteItemsService.selectKhVoteItemsList(khVoteItems); + ExcelUtil util = new ExcelUtil(KhVoteItems.class); + util.exportExcel(response, list, "投票项数据"); + } + + /** + * 获取投票项详细信息 + */ + @PreAuthorize("@ss.hasPermi('kaohe:vote_items:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(khVoteItemsService.selectKhVoteItemsById(id)); + } + + /** + * 新增投票项 + */ + @PreAuthorize("@ss.hasPermi('kaohe:vote_items:add')") + @Log(title = "投票项", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody KhVoteItems khVoteItems) + { + return toAjax(khVoteItemsService.insertKhVoteItems(khVoteItems)); + } + + /** + * 修改投票项 + */ + @PreAuthorize("@ss.hasPermi('kaohe:vote_items:edit')") + @Log(title = "投票项", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody KhVoteItems khVoteItems) + { + return toAjax(khVoteItemsService.updateKhVoteItems(khVoteItems)); + } + + /** + * 删除投票项 + */ + @PreAuthorize("@ss.hasPermi('kaohe:vote_items:remove')") + @Log(title = "投票项", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(khVoteItemsService.deleteKhVoteItemsByIds(ids)); + } +} diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhVoteItems.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhVoteItems.java new file mode 100644 index 0000000..c859f6f --- /dev/null +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhVoteItems.java @@ -0,0 +1,57 @@ +package com.ruoyi.kaohe.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; + +/** + * 投票项对象 kh_vote_items + * + * @author hs + * @date 2025-06-24 + */ +public class KhVoteItems extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 投票选项名称 */ + @Excel(name = "投票选项名称") + private String vitemName; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + + public void setVitemName(String vitemName) + { + this.vitemName = vitemName; + } + + public String getVitemName() + { + return vitemName; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("vitemName", getVitemName()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/mapper/KhVoteItemsMapper.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/mapper/KhVoteItemsMapper.java new file mode 100644 index 0000000..8c8f03a --- /dev/null +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/mapper/KhVoteItemsMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.kaohe.mapper; + +import java.util.List; +import com.ruoyi.kaohe.domain.KhVoteItems; + +/** + * 投票项Mapper接口 + * + * @author hs + * @date 2025-06-24 + */ +public interface KhVoteItemsMapper +{ + /** + * 查询投票项 + * + * @param id 投票项主键 + * @return 投票项 + */ + public KhVoteItems selectKhVoteItemsById(Long id); + + /** + * 查询投票项列表 + * + * @param khVoteItems 投票项 + * @return 投票项集合 + */ + public List selectKhVoteItemsList(KhVoteItems khVoteItems); + + /** + * 新增投票项 + * + * @param khVoteItems 投票项 + * @return 结果 + */ + public int insertKhVoteItems(KhVoteItems khVoteItems); + + /** + * 修改投票项 + * + * @param khVoteItems 投票项 + * @return 结果 + */ + public int updateKhVoteItems(KhVoteItems khVoteItems); + + /** + * 删除投票项 + * + * @param id 投票项主键 + * @return 结果 + */ + public int deleteKhVoteItemsById(Long id); + + /** + * 批量删除投票项 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteKhVoteItemsByIds(Long[] ids); +} diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/IKhVoteItemsService.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/IKhVoteItemsService.java new file mode 100644 index 0000000..c24ac7a --- /dev/null +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/IKhVoteItemsService.java @@ -0,0 +1,61 @@ +package com.ruoyi.kaohe.service; + +import java.util.List; +import com.ruoyi.kaohe.domain.KhVoteItems; + +/** + * 投票项Service接口 + * + * @author hs + * @date 2025-06-24 + */ +public interface IKhVoteItemsService +{ + /** + * 查询投票项 + * + * @param id 投票项主键 + * @return 投票项 + */ + public KhVoteItems selectKhVoteItemsById(Long id); + + /** + * 查询投票项列表 + * + * @param khVoteItems 投票项 + * @return 投票项集合 + */ + public List selectKhVoteItemsList(KhVoteItems khVoteItems); + + /** + * 新增投票项 + * + * @param khVoteItems 投票项 + * @return 结果 + */ + public int insertKhVoteItems(KhVoteItems khVoteItems); + + /** + * 修改投票项 + * + * @param khVoteItems 投票项 + * @return 结果 + */ + public int updateKhVoteItems(KhVoteItems khVoteItems); + + /** + * 批量删除投票项 + * + * @param ids 需要删除的投票项主键集合 + * @return 结果 + */ + public int deleteKhVoteItemsByIds(Long[] ids); + + /** + * 删除投票项信息 + * + * @param id 投票项主键 + * @return 结果 + */ + public int deleteKhVoteItemsById(Long id); +} diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/impl/KhVoteItemsServiceImpl.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/impl/KhVoteItemsServiceImpl.java new file mode 100644 index 0000000..6ba880e --- /dev/null +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/service/impl/KhVoteItemsServiceImpl.java @@ -0,0 +1,96 @@ +package com.ruoyi.kaohe.service.impl; + +import java.util.List; +import com.ruoyi.common.utils.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.kaohe.mapper.KhVoteItemsMapper; +import com.ruoyi.kaohe.domain.KhVoteItems; +import com.ruoyi.kaohe.service.IKhVoteItemsService; + +/** + * 投票项Service业务层处理 + * + * @author hs + * @date 2025-06-24 + */ +@Service +public class KhVoteItemsServiceImpl implements IKhVoteItemsService +{ + @Autowired + private KhVoteItemsMapper khVoteItemsMapper; + + /** + * 查询投票项 + * + * @param id 投票项主键 + * @return 投票项 + */ + @Override + public KhVoteItems selectKhVoteItemsById(Long id) + { + return khVoteItemsMapper.selectKhVoteItemsById(id); + } + + /** + * 查询投票项列表 + * + * @param khVoteItems 投票项 + * @return 投票项 + */ + @Override + public List selectKhVoteItemsList(KhVoteItems khVoteItems) + { + return khVoteItemsMapper.selectKhVoteItemsList(khVoteItems); + } + + /** + * 新增投票项 + * + * @param khVoteItems 投票项 + * @return 结果 + */ + @Override + public int insertKhVoteItems(KhVoteItems khVoteItems) + { + khVoteItems.setCreateTime(DateUtils.getNowDate()); + return khVoteItemsMapper.insertKhVoteItems(khVoteItems); + } + + /** + * 修改投票项 + * + * @param khVoteItems 投票项 + * @return 结果 + */ + @Override + public int updateKhVoteItems(KhVoteItems khVoteItems) + { + khVoteItems.setUpdateTime(DateUtils.getNowDate()); + return khVoteItemsMapper.updateKhVoteItems(khVoteItems); + } + + /** + * 批量删除投票项 + * + * @param ids 需要删除的投票项主键 + * @return 结果 + */ + @Override + public int deleteKhVoteItemsByIds(Long[] ids) + { + return khVoteItemsMapper.deleteKhVoteItemsByIds(ids); + } + + /** + * 删除投票项信息 + * + * @param id 投票项主键 + * @return 结果 + */ + @Override + public int deleteKhVoteItemsById(Long id) + { + return khVoteItemsMapper.deleteKhVoteItemsById(id); + } +} diff --git a/ruoyi-ui/src/api/kaohe/vote_items.js b/ruoyi-ui/src/api/kaohe/vote_items.js new file mode 100644 index 0000000..44b98e7 --- /dev/null +++ b/ruoyi-ui/src/api/kaohe/vote_items.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询投票项列表 +export function listVote_items(query) { + return request({ + url: '/kaohe/vote_items/list', + method: 'get', + params: query + }) +} + +// 查询投票项详细 +export function getVote_items(id) { + return request({ + url: '/kaohe/vote_items/' + id, + method: 'get' + }) +} + +// 新增投票项 +export function addVote_items(data) { + return request({ + url: '/kaohe/vote_items', + method: 'post', + data: data + }) +} + +// 修改投票项 +export function updateVote_items(data) { + return request({ + url: '/kaohe/vote_items', + method: 'put', + data: data + }) +} + +// 删除投票项 +export function delVote_items(id) { + return request({ + url: '/kaohe/vote_items/' + id, + method: 'delete' + }) +} diff --git a/ruoyi-ui/src/views/kaohe/vote_items/index.vue b/ruoyi-ui/src/views/kaohe/vote_items/index.vue new file mode 100644 index 0000000..05f3e23 --- /dev/null +++ b/ruoyi-ui/src/views/kaohe/vote_items/index.vue @@ -0,0 +1,254 @@ + + +