项目管理crud

This commit is contained in:
mi9688 2024-09-26 13:52:56 +08:00
parent 6498c926ab
commit 162a40aa62
8 changed files with 475 additions and 169 deletions

View File

@ -1,47 +1,110 @@
package com.fastbee.data.controller.project;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.fastbee.common.utils.poi.ExcelUtil;
import com.fastbee.project.domain.Project;
import com.fastbee.project.service.IProjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.fastbee.common.annotation.Log;
import com.fastbee.common.core.controller.BaseController;
import com.fastbee.common.core.domain.AjaxResult;
import com.fastbee.common.core.page.TableDataInfo;
import com.fastbee.project.domain.Project;
import com.fastbee.project.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* <p>
* 项目表 前端控制器
* </p>
* 项目Controller
*
* @author 蒾酒
* @since 2024-09-24
* @author kerwincui
* @date 2024-09-26
*/
@RestController
@RequestMapping("/project")
public class ProjectController extends BaseController {
@Api(tags = "项目")
public class ProjectController extends BaseController
{
@Autowired
private ProjectService projectService;
private IProjectService projectService;
/**
* 查询项目列表
*/
@PreAuthorize("@ss.hasPermi('iot:project:list')")
@GetMapping("/list")
public TableDataInfo getPageList(){
super.startPage();
return super.getDataTable(projectService.list());
}
@GetMapping("/info/{id}")
public AjaxResult getInfo(@PathVariable Long id){
return AjaxResult.success(projectService.getBaseMapper().selectById(id));
}
@PutMapping("/update")
public AjaxResult update(@RequestBody Project project){
projectService.updateById(project);
return AjaxResult.success();
}
@DeleteMapping("/delete/{id}")
public AjaxResult delete(@PathVariable Long id){
projectService.removeById(id);
return AjaxResult.success();
@ApiOperation("查询项目列表")
public TableDataInfo list(Project project)
{
startPage();
List<Project> list = projectService.selectProjectList(project);
return getDataTable(list);
}
/**
* 导出项目列表
*/
@ApiOperation("导出项目列表")
@PreAuthorize("@ss.hasPermi('iot:project:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, Project project)
{
List<Project> list = projectService.selectProjectList(project);
ExcelUtil<Project> util = new ExcelUtil<Project>(Project.class);
util.exportExcel(response, list, "项目数据");
}
/**
* 获取项目详细信息
*/
@PreAuthorize("@ss.hasPermi('iot:project:query')")
@GetMapping(value = "/{projectId}")
@ApiOperation("获取项目详细信息")
public AjaxResult getInfo(@PathVariable("projectId") Long projectId)
{
return success(projectService.selectProjectByProjectId(projectId));
}
/**
* 新增项目
*/
@PreAuthorize("@ss.hasPermi('iot:project:add')")
@PostMapping
@ApiOperation("新增项目")
public AjaxResult add(@RequestBody Project project)
{
return toAjax(projectService.insertProject(project));
}
/**
* 修改项目
*/
@PreAuthorize("@ss.hasPermi('iot:project:edit')")
@PutMapping
@ApiOperation("修改项目")
public AjaxResult edit(@RequestBody Project project)
{
return toAjax(projectService.updateProject(project));
}
/**
* 删除项目
*/
@PreAuthorize("@ss.hasPermi('iot:project:remove')")
@DeleteMapping("/{projectIds}")
@ApiOperation("删除项目")
public AjaxResult remove(@PathVariable Long[] projectIds)
{
return toAjax(projectService.deleteProjectByProjectIds(projectIds));
}
}

View File

@ -1,102 +1,85 @@
package com.fastbee.project.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
import com.fastbee.common.annotation.Excel;
import com.fastbee.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 项目表
* </p>
* 项目对象 project
*
* @author 蒾酒
* @since 2024-09-24
* @author kerwincui
* @date 2024-09-26
*/
@Getter
@Setter
@TableName("project")
public class Project implements Serializable {
@Data
public class Project extends BaseEntity
{
private static final long serialVersionUID = 1L;
/**
* 项目id
*/
@TableId("project_id")
private Integer projectId;
/** 项目id */
private Long projectId;
/**
* 项目名称
*/
@TableField("project_name")
/** 项目名称 */
@Excel(name = "项目名称")
private String projectName;
/**
* 系统显示名称
*/
@TableField("sys_show_name")
/** 系统显示名称 */
@Excel(name = "系统显示名称")
private String sysShowName;
/**
* 中心坐标
*/
@TableField("central_coordinates")
/** 中心坐标 */
@Excel(name = "中心坐标")
private String centralCoordinates;
/**
* 项目范围(经纬度)
*/
@TableField("scope")
/** 项目范围(经纬度) */
@Excel(name = "项目范围(经纬度)")
private String scope;
/**
* 行政区域
*/
@TableField("administrative_area")
/** 行政区域 */
@Excel(name = "行政区域")
private String administrativeArea;
/**
* 项目拥有人
*/
@TableField("owner")
/** 项目拥有人 */
@Excel(name = "项目拥有人")
private String owner;
/**
* 项目logo
*/
@TableField("logo")
/** 项目logo */
@Excel(name = "项目logo")
private String logo;
/**
* 项目图片
*/
@TableField("image")
/** 项目图片 */
@Excel(name = "项目图片")
private String image;
/**
* 园区视频介绍
*/
@TableField("video_introduction")
/** 园区视频介绍 */
@Excel(name = "园区视频介绍")
private String videoIntroduction;
/**
* 备注
*/
@TableField("remark")
private String remark;
/** 项目参数 */
@Excel(name = "项目参数")
private String pParams;
/**
* 项目参数
*/
@TableField("params")
private String params;
/**
* 项目介绍
*/
@TableField("introduce")
/** 项目介绍 */
@Excel(name = "项目介绍")
private String introduce;
/** 删除状态[1删除,-1未删除] */
private Long delFlag;
/** 项目介绍 */
@Excel(name = "项目介绍")
private String remarks;
/** 租户id */
@Excel(name = "租户id")
private Long tenantId;
/** 租户名称 */
@Excel(name = "租户名称")
private String tenantName;
}

View File

@ -8,19 +8,58 @@ import org.apache.ibatis.annotations.Update;
import java.util.List;
/**
* <p>
* 项目表 Mapper 接口
* </p>
* 项目Mapper接口
*
* @author 蒾酒
* @since 2024-09-24
* @author kerwincui
* @date 2024-09-26
*/
public interface ProjectMapper extends BaseMapper<Project> {
public interface ProjectMapper
{
/**
* 查询项目
*
* @param projectId 项目主键
* @return 项目
*/
public Project selectProjectByProjectId(Long projectId);
/**
* 查询项目列表
* @return 列表
*
* @param project 项目
* @return 项目集合
*/
// @Select("SELECT * FROM project")
List<Project> selectProjectList();
public List<Project> selectProjectList(Project project);
/**
* 新增项目
*
* @param project 项目
* @return 结果
*/
public int insertProject(Project project);
/**
* 修改项目
*
* @param project 项目
* @return 结果
*/
public int updateProject(Project project);
/**
* 删除项目
*
* @param projectId 项目主键
* @return 结果
*/
public int deleteProjectByProjectId(Long projectId);
/**
* 批量删除项目
*
* @param projectIds 需要删除的数据主键集合
* @return 结果
*/
public int deleteProjectByProjectIds(Long[] projectIds);
}

View File

@ -1,27 +0,0 @@
<?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.fastbee.project.mapper.ProjectMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.fastbee.project.domain.Project">
<id column="project_id" property="projectId" />
<result column="project_name" property="projectName" />
<result column="sys_show_name" property="sysShowName" />
<result column="central_coordinates" property="centralCoordinates" />
<result column="scope" property="scope" />
<result column="administrative_area" property="administrativeArea" />
<result column="owner" property="owner" />
<result column="logo" property="logo" />
<result column="image" property="image" />
<result column="video_introduction" property="videoIntroduction" />
<result column="remark" property="remark" />
<result column="params" property="params" />
<result column="introduce" property="introduce" />
</resultMap>
<select id="selectProjectList" resultMap="BaseResultMap">
select * from project
</select>
</mapper>

View File

@ -0,0 +1,62 @@
package com.fastbee.project.service;
import com.fastbee.project.domain.Project;
import java.util.List;
/**
* 项目Service接口
*
* @author kerwincui
* @date 2024-09-26
*/
public interface IProjectService
{
/**
* 查询项目
*
* @param projectId 项目主键
* @return 项目
*/
public Project selectProjectByProjectId(Long projectId);
/**
* 查询项目列表
*
* @param project 项目
* @return 项目集合
*/
public List<Project> selectProjectList(Project project);
/**
* 新增项目
*
* @param project 项目
* @return 结果
*/
public int insertProject(Project project);
/**
* 修改项目
*
* @param project 项目
* @return 结果
*/
public int updateProject(Project project);
/**
* 批量删除项目
*
* @param projectIds 需要删除的项目主键集合
* @return 结果
*/
public int deleteProjectByProjectIds(Long[] projectIds);
/**
* 删除项目信息
*
* @param projectId 项目主键
* @return 结果
*/
public int deleteProjectByProjectId(Long projectId);
}

View File

@ -1,20 +0,0 @@
package com.fastbee.project.service;
import com.fastbee.project.domain.Project;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 项目表 服务类
* </p>
*
* @author 蒾酒
* @since 2024-09-24
*/
public interface ProjectService extends IService<Project> {
List<?> getProjectList();
}

View File

@ -1,36 +1,99 @@
package com.fastbee.project.service.impl;
import com.fastbee.common.utils.DateUtils;
import com.fastbee.project.domain.Project;
import com.fastbee.project.mapper.ProjectMapper;
import com.fastbee.project.service.ProjectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fastbee.project.service.IProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 项目表 服务实现类
* </p>
* 项目Service业务层处理
*
* @author 蒾酒
* @since 2024-09-24
* @author kerwincui
* @date 2024-09-26
*/
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> implements ProjectService {
public class ProjectServiceImpl implements IProjectService
{
@Autowired
private ProjectMapper projectMapper;
/**
* 查询项目列表
* @author 蒾酒
* &#064;date 2024-09-24
* 查询项目
*
* @param projectId 项目主键
* @return 项目
*/
public List<?> getProjectList(){
return projectMapper.selectProjectList();
@Override
public Project selectProjectByProjectId(Long projectId)
{
return projectMapper.selectProjectByProjectId(projectId);
}
/**
* 查询项目列表
*
* @param project 项目
* @return 项目
*/
@Override
public List<Project> selectProjectList(Project project)
{
return projectMapper.selectProjectList(project);
}
/**
* 新增项目
*
* @param project 项目
* @return 结果
*/
@Override
public int insertProject(Project project)
{
project.setCreateTime(DateUtils.getNowDate());
return projectMapper.insertProject(project);
}
/**
* 修改项目
*
* @param project 项目
* @return 结果
*/
@Override
public int updateProject(Project project)
{
project.setUpdateTime(DateUtils.getNowDate());
return projectMapper.updateProject(project);
}
/**
* 批量删除项目
*
* @param projectIds 需要删除的项目主键
* @return 结果
*/
@Override
public int deleteProjectByProjectIds(Long[] projectIds)
{
return projectMapper.deleteProjectByProjectIds(projectIds);
}
/**
* 删除项目信息
*
* @param projectId 项目主键
* @return 结果
*/
@Override
public int deleteProjectByProjectId(Long projectId)
{
return projectMapper.deleteProjectByProjectId(projectId);
}
}

View File

@ -0,0 +1,143 @@
<?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.fastbee.project.mapper.ProjectMapper">
<resultMap type="Project" id="ProjectResult">
<result property="projectId" column="project_id" />
<result property="projectName" column="project_name" />
<result property="sysShowName" column="sys_show_name" />
<result property="centralCoordinates" column="central_coordinates" />
<result property="scope" column="scope" />
<result property="administrativeArea" column="administrative_area" />
<result property="owner" column="owner" />
<result property="logo" column="logo" />
<result property="image" column="image" />
<result property="videoIntroduction" column="video_introduction" />
<result property="remark" column="remark" />
<result property="pParams" column="p_params" />
<result property="introduce" column="introduce" />
<result property="delFlag" column="del_flag" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="remarks" column="remarks" />
<result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" />
</resultMap>
<sql id="selectProjectVo">
select project_id, project_name, sys_show_name, central_coordinates, scope, administrative_area, owner, logo, image, video_introduction, remark, p_params, introduce, del_flag, create_time, create_by, update_time, remarks, tenant_id, tenant_name from project
</sql>
<select id="selectProjectList" parameterType="Project" resultMap="ProjectResult">
<include refid="selectProjectVo"/>
<where>
<if test="projectName != null and projectName != ''"> and project_name like concat('%', #{projectName}, '%')</if>
<if test="sysShowName != null and sysShowName != ''"> and sys_show_name like concat('%', #{sysShowName}, '%')</if>
<if test="centralCoordinates != null and centralCoordinates != ''"> and central_coordinates = #{centralCoordinates}</if>
<if test="scope != null and scope != ''"> and scope = #{scope}</if>
<if test="administrativeArea != null and administrativeArea != ''"> and administrative_area = #{administrativeArea}</if>
<if test="owner != null and owner != ''"> and owner = #{owner}</if>
<if test="logo != null and logo != ''"> and logo = #{logo}</if>
<if test="image != null and image != ''"> and image = #{image}</if>
<if test="videoIntroduction != null and videoIntroduction != ''"> and video_introduction = #{videoIntroduction}</if>
<if test="pParams != null and pParams != ''"> and p_params = #{pParams}</if>
<if test="introduce != null and introduce != ''"> and introduce = #{introduce}</if>
<if test="remarks != null and remarks != ''"> and remarks = #{remarks}</if>
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
</where>
</select>
<select id="selectProjectByProjectId" parameterType="Long" resultMap="ProjectResult">
<include refid="selectProjectVo"/>
where project_id = #{projectId}
</select>
<insert id="insertProject" parameterType="Project">
insert into project
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="projectId != null">project_id,</if>
<if test="projectName != null and projectName != ''">project_name,</if>
<if test="sysShowName != null and sysShowName != ''">sys_show_name,</if>
<if test="centralCoordinates != null and centralCoordinates != ''">central_coordinates,</if>
<if test="scope != null and scope != ''">scope,</if>
<if test="administrativeArea != null and administrativeArea != ''">administrative_area,</if>
<if test="owner != null and owner != ''">owner,</if>
<if test="logo != null and logo != ''">logo,</if>
<if test="image != null and image != ''">image,</if>
<if test="videoIntroduction != null and videoIntroduction != ''">video_introduction,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="pParams != null and pParams != ''">p_params,</if>
<if test="introduce != null">introduce,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remarks != null">remarks,</if>
<if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null">tenant_name,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="projectId != null">#{projectId},</if>
<if test="projectName != null and projectName != ''">#{projectName},</if>
<if test="sysShowName != null and sysShowName != ''">#{sysShowName},</if>
<if test="centralCoordinates != null and centralCoordinates != ''">#{centralCoordinates},</if>
<if test="scope != null and scope != ''">#{scope},</if>
<if test="administrativeArea != null and administrativeArea != ''">#{administrativeArea},</if>
<if test="owner != null and owner != ''">#{owner},</if>
<if test="logo != null and logo != ''">#{logo},</if>
<if test="image != null and image != ''">#{image},</if>
<if test="videoIntroduction != null and videoIntroduction != ''">#{videoIntroduction},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="pParams != null and pParams != ''">#{pParams},</if>
<if test="introduce != null">#{introduce},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remarks != null">#{remarks},</if>
<if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null">#{tenantName},</if>
</trim>
</insert>
<update id="updateProject" parameterType="Project">
update project
<trim prefix="SET" suffixOverrides=",">
<if test="projectName != null and projectName != ''">project_name = #{projectName},</if>
<if test="sysShowName != null and sysShowName != ''">sys_show_name = #{sysShowName},</if>
<if test="centralCoordinates != null and centralCoordinates != ''">central_coordinates = #{centralCoordinates},</if>
<if test="scope != null and scope != ''">scope = #{scope},</if>
<if test="administrativeArea != null and administrativeArea != ''">administrative_area = #{administrativeArea},</if>
<if test="owner != null and owner != ''">owner = #{owner},</if>
<if test="logo != null and logo != ''">logo = #{logo},</if>
<if test="image != null and image != ''">image = #{image},</if>
<if test="videoIntroduction != null and videoIntroduction != ''">video_introduction = #{videoIntroduction},</if>
<if test="remark != null and remark != ''">remark = #{remark},</if>
<if test="pParams != null and pParams != ''">p_params = #{pParams},</if>
<if test="introduce != null">introduce = #{introduce},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remarks != null">remarks = #{remarks},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null">tenant_name = #{tenantName},</if>
</trim>
where project_id = #{projectId}
</update>
<delete id="deleteProjectByProjectId" parameterType="Long">
delete from project where project_id = #{projectId}
</delete>
<delete id="deleteProjectByProjectIds" parameterType="String">
delete from project where project_id in
<foreach item="projectId" collection="array" open="(" separator="," close=")">
#{projectId}
</foreach>
</delete>
</mapper>