项目功能开发

This commit is contained in:
冯辉
2026-07-06 21:12:53 +08:00
parent 734c91eea1
commit 048e417ab5
12 changed files with 693 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
package com.ruoyi.cms.controller.app;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.cms.domain.Project;
import com.ruoyi.cms.domain.ProjectComment;
import com.ruoyi.cms.service.IProjectCommentService;
import com.ruoyi.cms.service.IProjectService;
import com.ruoyi.common.annotation.BussinessLog;
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.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 移动端:项目管理 Controller
*
* @author shz
* @date 2025-07-06
*/
@RestController
@RequestMapping("/app/project")
@Api(tags = "移动端:项目管理")
public class AppProjectController extends BaseController
{
@Autowired
private IProjectService projectService;
@Autowired
private IProjectCommentService projectCommentService;
/**
* 查询已发布项目列表(支持搜索和筛选)
*/
@ApiOperation("查询项目列表")
@GetMapping("/list")
@BussinessLog(title = "查询项目列表")
public TableDataInfo list(Project query)
{
startPage();
LambdaQueryWrapper<Project> wrapper = new LambdaQueryWrapper<>();
wrapper.and(StringUtils.isNotBlank(query.getTitle()),
w -> w.like(Project::getTitle, query.getTitle())
.or()
.like(Project::getDescription, query.getTitle()));
wrapper.eq(StringUtils.isNotBlank(query.getIndustry()), Project::getIndustry, query.getIndustry());
wrapper.eq(StringUtils.isNotBlank(query.getRegion()), Project::getRegion, query.getRegion());
wrapper.eq(StringUtils.isNotBlank(query.getCooperationMode()), Project::getCooperationMode, query.getCooperationMode());
wrapper.eq(Project::getStatus, "1");
wrapper.orderByDesc(Project::getCreateTime);
List<Project> list = projectService.list(wrapper);
return getDataTable(list);
}
/**
* 获取项目详情(含评论列表)
*/
@ApiOperation("获取项目详情")
@GetMapping("/{projectId}")
@BussinessLog(title = "查看项目详情")
public AjaxResult detail(@PathVariable("projectId") Long projectId)
{
Project project = projectService.getById(projectId);
if (project == null)
{
return AjaxResult.error("项目不存在");
}
List<ProjectComment> comments = projectCommentService.listByProjectId(projectId);
Map<String, Object> result = new HashMap<>();
result.put("project", project);
result.put("comments", comments);
return AjaxResult.success(result);
}
/**
* 发表评论
*/
@ApiOperation("发表评论")
@PostMapping("/comment")
@BussinessLog(title = "发表项目评论")
public AjaxResult addComment(@RequestBody ProjectComment comment)
{
if (!StringUtils.hasText(comment.getContent()))
{
return AjaxResult.error("评论内容不能为空");
}
if (comment.getProjectId() == null)
{
return AjaxResult.error("项目ID不能为空");
}
return toAjax(projectCommentService.save(comment));
}
/**
* 获取项目评论列表
*/
@ApiOperation("获取项目评论列表")
@GetMapping("/comments/{projectId}")
@BussinessLog(title = "查看项目评论")
public AjaxResult comments(@PathVariable("projectId") Long projectId)
{
List<ProjectComment> comments = projectCommentService.listByProjectId(projectId);
return AjaxResult.success(comments);
}
}

View File

@@ -0,0 +1,137 @@
package com.ruoyi.cms.controller.cms;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import com.ruoyi.cms.domain.Project;
import com.ruoyi.cms.domain.ProjectComment;
import com.ruoyi.cms.service.IProjectCommentService;
import com.ruoyi.cms.service.IProjectService;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 后台:项目管理 Controller
*
* @author shz
* @date 2025-07-06
*/
@RestController
@RequestMapping("/cms/project")
@Api(tags = "后台:项目管理")
public class ProjectController extends BaseController
{
@Autowired
private IProjectService projectService;
@Autowired
private IProjectCommentService projectCommentService;
/**
* 获取项目的评论列表
*/
@ApiOperation("获取项目评论列表")
@PreAuthorize("@ss.hasPermi('cms:project:query')")
@GetMapping("/comments/{projectId}")
public AjaxResult comments(@PathVariable("projectId") Long projectId)
{
List<ProjectComment> list = projectCommentService.listByProjectId(projectId);
return success(list);
}
/**
* 回复评论
*/
@ApiOperation("回复评论")
@PreAuthorize("@ss.hasPermi('cms:project:edit')")
@Log(title = "项目管理", businessType = BusinessType.UPDATE)
@PutMapping("/comment/reply")
public AjaxResult reply(@RequestBody ProjectComment comment)
{
ProjectComment entity = projectCommentService.getById(comment.getCommentId());
if (entity == null)
{
return AjaxResult.error("评论不存在");
}
entity.setReply(comment.getReply());
entity.setReplyTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
return toAjax(projectCommentService.updateById(entity));
}
/**
* 查询项目列表
*/
@ApiOperation("查询项目列表")
@PreAuthorize("@ss.hasPermi('cms:project:list')")
@GetMapping("/list")
public TableDataInfo list(Project query)
{
startPage();
List<Project> list = projectService.selectProjectList(query);
return getDataTable(list);
}
/**
* 获取项目详细信息
*/
@ApiOperation("获取项目详细信息")
@PreAuthorize("@ss.hasPermi('cms:project:query')")
@GetMapping("/{projectId}")
public AjaxResult getInfo(@PathVariable("projectId") Long projectId)
{
return success(projectService.getById(projectId));
}
/**
* 新增项目
*/
@ApiOperation("新增项目")
@PreAuthorize("@ss.hasPermi('cms:project:add')")
@Log(title = "项目管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Project project)
{
return toAjax(projectService.save(project));
}
/**
* 修改项目
*/
@ApiOperation("修改项目")
@PreAuthorize("@ss.hasPermi('cms:project:edit')")
@Log(title = "项目管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Project project)
{
return toAjax(projectService.updateById(project));
}
/**
* 删除项目
*/
@ApiOperation("删除项目")
@PreAuthorize("@ss.hasPermi('cms:project:remove')")
@Log(title = "项目管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{projectIds}")
public AjaxResult remove(@PathVariable Long[] projectIds)
{
return toAjax(projectService.removeByIds(Arrays.asList(projectIds)));
}
}

View File

@@ -0,0 +1,69 @@
package com.ruoyi.cms.domain;
import lombok.Data;
import com.ruoyi.common.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 项目管理对象 cms_project
*
* @author shz
* @date 2025-07-06
*/
@Data
@ApiModel("项目管理")
@TableName(value = "shz.cms_project")
public class Project extends BaseEntity
{
@TableField(exist = false)
private static final long serialVersionUID = 1L;
@TableId(value = "project_id", type = IdType.AUTO)
@ApiModelProperty("项目ID")
private Long projectId;
@Excel(name = "项目名称")
@ApiModelProperty("项目名称")
private String title;
@Excel(name = "项目描述")
@ApiModelProperty("项目描述")
private String description;
@Excel(name = "项目需求人员")
@ApiModelProperty("项目需求人员")
private String requiredPersonnel;
@Excel(name = "合作方式")
@ApiModelProperty("合作方式")
private String cooperationMode;
@Excel(name = "行业")
@ApiModelProperty("行业")
private String industry;
@Excel(name = "地区")
@ApiModelProperty("地区")
private String region;
@Excel(name = "联系人")
@ApiModelProperty("联系人")
private String contactName;
@Excel(name = "联系电话")
@ApiModelProperty("联系电话")
private String contactPhone;
@Excel(name = "联系邮箱")
@ApiModelProperty("联系邮箱")
private String contactEmail;
@ApiModelProperty("状态 0草稿 1发布")
private String status;
}

View File

@@ -0,0 +1,47 @@
package com.ruoyi.cms.domain;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 项目评论对象 cms_project_comment
*
* @author shz
* @date 2025-07-06
*/
@Data
@ApiModel("项目评论")
@TableName(value = "shz.cms_project_comment")
public class ProjectComment extends BaseEntity
{
@TableField(exist = false)
private static final long serialVersionUID = 1L;
@TableId(value = "comment_id", type = IdType.AUTO)
@ApiModelProperty("评论ID")
private Long commentId;
@ApiModelProperty("关联项目ID")
private Long projectId;
@ApiModelProperty("用户ID")
private Long userId;
@ApiModelProperty("用户名")
private String userName;
@ApiModelProperty("评论内容")
private String content;
@ApiModelProperty("回复内容")
private String reply;
@ApiModelProperty("回复时间")
private String replyTime;
}

View File

@@ -0,0 +1,14 @@
package com.ruoyi.cms.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.cms.domain.ProjectComment;
/**
* 项目评论 Mapper 接口
*
* @author shz
* @date 2025-07-06
*/
public interface ProjectCommentMapper extends BaseMapper<ProjectComment>
{
}

View File

@@ -0,0 +1,14 @@
package com.ruoyi.cms.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.cms.domain.Project;
/**
* 项目管理 Mapper 接口
*
* @author shz
* @date 2025-07-06
*/
public interface ProjectMapper extends BaseMapper<Project>
{
}

View File

@@ -0,0 +1,20 @@
package com.ruoyi.cms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.cms.domain.ProjectComment;
import java.util.List;
/**
* 项目评论 Service 接口
*
* @author shz
* @date 2025-07-06
*/
public interface IProjectCommentService extends IService<ProjectComment>
{
/**
* 根据项目ID查询评论列表
*/
List<ProjectComment> listByProjectId(Long projectId);
}

View File

@@ -0,0 +1,20 @@
package com.ruoyi.cms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.cms.domain.Project;
import java.util.List;
/**
* 项目管理 Service 接口
*
* @author shz
* @date 2025-07-06
*/
public interface IProjectService extends IService<Project>
{
/**
* 查询项目列表(支持多条件筛选)
*/
List<Project> selectProjectList(Project query);
}

View File

@@ -0,0 +1,31 @@
package com.ruoyi.cms.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.cms.domain.ProjectComment;
import com.ruoyi.cms.mapper.ProjectCommentMapper;
import com.ruoyi.cms.service.IProjectCommentService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 项目评论 Service 实现
*
* @author shz
* @date 2025-07-06
*/
@Service
public class ProjectCommentServiceImpl
extends ServiceImpl<ProjectCommentMapper, ProjectComment>
implements IProjectCommentService
{
@Override
public List<ProjectComment> listByProjectId(Long projectId)
{
LambdaQueryWrapper<ProjectComment> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ProjectComment::getProjectId, projectId);
wrapper.orderByAsc(ProjectComment::getCreateTime);
return list(wrapper);
}
}

View File

@@ -0,0 +1,36 @@
package com.ruoyi.cms.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.cms.domain.Project;
import com.ruoyi.cms.mapper.ProjectMapper;
import com.ruoyi.cms.service.IProjectService;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 项目管理 Service 实现
*
* @author shz
* @date 2025-07-06
*/
@Service
public class ProjectServiceImpl
extends ServiceImpl<ProjectMapper, Project>
implements IProjectService
{
@Override
public List<Project> selectProjectList(Project query)
{
LambdaQueryWrapper<Project> wrapper = new LambdaQueryWrapper<>();
wrapper.like(StringUtils.isNotBlank(query.getTitle()), Project::getTitle, query.getTitle());
wrapper.eq(StringUtils.isNotBlank(query.getIndustry()), Project::getIndustry, query.getIndustry());
wrapper.eq(StringUtils.isNotBlank(query.getRegion()), Project::getRegion, query.getRegion());
wrapper.eq(StringUtils.isNotBlank(query.getCooperationMode()), Project::getCooperationMode, query.getCooperationMode());
wrapper.eq(StringUtils.isNotBlank(query.getStatus()), Project::getStatus, query.getStatus());
wrapper.orderByDesc(Project::getCreateTime);
return list(wrapper);
}
}