站点管理部分接口逻辑添加

This commit is contained in:
mi9688 2024-09-30 17:42:15 +08:00
parent 20e7998c13
commit 762eab8fd1
9 changed files with 66 additions and 117 deletions

View File

@ -4,6 +4,7 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.fastbee.ggroup.domain.dto.GGroupSiteDto; import com.fastbee.ggroup.domain.dto.GGroupSiteDto;
import com.fastbee.ggroup.domain.dto.GSitesEditDto;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@ -93,9 +94,9 @@ public class GSitesController extends BaseController
@PreAuthorize("@ss.hasPermi('ggroup:sites:edit')") @PreAuthorize("@ss.hasPermi('ggroup:sites:edit')")
@PutMapping @PutMapping
@ApiOperation("修改站点") @ApiOperation("修改站点")
public AjaxResult edit(@RequestBody GSites gSites) public AjaxResult edit(@RequestBody GSitesEditDto gSitesEditDto)
{ {
return toAjax(gSitesService.updateGSites(gSites)); return toAjax(gSitesService.updateGSites(gSitesEditDto));
} }
/** /**

View File

@ -0,0 +1,29 @@
package com.fastbee.ggroup.domain.dto;
import lombok.Data;
/**
* 站点编辑对象 g_sites
*
* @author kerwincui
* @date 2024-09-29
*/
@Data
public class GSitesEditDto
{
private static final long serialVersionUID = 1L;
private Long id;//站点id
private String name;//站点名称
private String icon;//站点图标
private String type;//站点类型
private String space;//站点空间
private String parentId;//父节点id
}

View File

@ -13,21 +13,6 @@ import com.fastbee.ggroup.domain.GSiteGroups;
*/ */
public interface GSiteGroupsMapper extends BaseMapper<GSiteGroups> public interface GSiteGroupsMapper extends BaseMapper<GSiteGroups>
{ {
/**
* 查询站点组关系
*
* @param id 站点组关系主键
* @return 站点组关系
*/
public GSiteGroups selectGSiteGroupsById(Long id);
/**
* 查询站点组关系列表
*
* @param gSiteGroups 站点组关系
* @return 站点组关系集合
*/
public List<GSiteGroups> selectGSiteGroupsList(GSiteGroups gSiteGroups);
/** /**
* 新增站点组关系 * 新增站点组关系
@ -35,15 +20,8 @@ public interface GSiteGroupsMapper extends BaseMapper<GSiteGroups>
* @param gSiteGroups 站点组关系 * @param gSiteGroups 站点组关系
* @return 结果 * @return 结果
*/ */
public int insertGSiteGroups(GSiteGroups gSiteGroups); int insertGSiteGroups(GSiteGroups gSiteGroups);
/**
* 修改站点组关系
*
* @param gSiteGroups 站点组关系
* @return 结果
*/
public int updateGSiteGroups(GSiteGroups gSiteGroups);
/** /**
* 删除站点组关系 * 删除站点组关系
@ -51,13 +29,6 @@ public interface GSiteGroupsMapper extends BaseMapper<GSiteGroups>
* @param id 站点组关系主键 * @param id 站点组关系主键
* @return 结果 * @return 结果
*/ */
public int deleteGSiteGroupsById(Long id); int deleteGSiteGroupsById(Long id);
/**
* 批量删除站点组关系
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteGSiteGroupsByIds(Long[] ids);
} }

View File

@ -25,13 +25,7 @@ public interface GSitesMapper extends BaseMapper<GSites>
*/ */
public GSites selectGSitesById(Long id); public GSites selectGSitesById(Long id);
/**
* 查询站点列表
*
* @param gSites 站点
* @return 站点集合
*/
public List<GSites> selectGSitesList(GSites gSites);
/** /**
* 新增站点 * 新增站点
@ -58,7 +52,6 @@ public interface GSitesMapper extends BaseMapper<GSites>
* @return 结果 * @return 结果
*/ */
// @Delete("delete from g_site_groups where id= #{id}")
public int deleteGSitesById(@Param("id") Long id); public int deleteGSitesById(@Param("id") Long id);
/** /**

View File

@ -3,6 +3,7 @@ package com.fastbee.ggroup.service;
import java.util.List; import java.util.List;
import com.fastbee.ggroup.domain.GSites; import com.fastbee.ggroup.domain.GSites;
import com.fastbee.ggroup.domain.dto.GGroupSiteDto; import com.fastbee.ggroup.domain.dto.GGroupSiteDto;
import com.fastbee.ggroup.domain.dto.GSitesEditDto;
/** /**
* 站点Service接口 * 站点Service接口
@ -42,7 +43,7 @@ public interface IGSitesService
* @param gSites 站点 * @param gSites 站点
* @return 结果 * @return 结果
*/ */
public int updateGSites(GSites gSites); public int updateGSites(GSitesEditDto gSitesEditDto);
/** /**
* 批量删除站点 * 批量删除站点

View File

@ -1,10 +1,17 @@
package com.fastbee.ggroup.service.impl; package com.fastbee.ggroup.service.impl;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fastbee.common.utils.DateUtils; import com.fastbee.common.utils.DateUtils;
import com.fastbee.ggroup.domain.GSiteGroups; import com.fastbee.ggroup.domain.GSiteGroups;
import com.fastbee.ggroup.domain.dto.GGroupSiteDto; import com.fastbee.ggroup.domain.dto.GGroupSiteDto;
import com.fastbee.ggroup.domain.dto.GSitesEditDto;
import com.fastbee.ggroup.mapper.GSiteGroupsMapper; import com.fastbee.ggroup.mapper.GSiteGroupsMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.fastbee.ggroup.mapper.GSitesMapper; import com.fastbee.ggroup.mapper.GSitesMapper;
@ -60,12 +67,18 @@ public class GSitesServiceImpl implements IGSitesService
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int insertGSites(GGroupSiteDto gGroupSiteDto) public int insertGSites(GGroupSiteDto gGroupSiteDto)
{ //更新关系表 {
//插入关系表
GSites gSites = new GSites(); GSites gSites = new GSites();
gSites.setName(gGroupSiteDto.getName()); gSites.setName(gGroupSiteDto.getName());
gSites.setType(gGroupSiteDto.getType()); gSites.setType(gGroupSiteDto.getType());
gSites.setIcon(gGroupSiteDto.getIcon()); gSites.setIcon(gGroupSiteDto.getIcon());
//根据名称判断是否存在该站点
GSites gSites1=gSitesMapper.selectOne(new LambdaQueryWrapper<GSites>().eq(GSites::getName,gGroupSiteDto.getName()));
if(gSites1!=null){
return 1;
}
//插入站点表
int inserted = gSitesMapper.insert(gSites); int inserted = gSitesMapper.insert(gSites);
gGroupSiteDto.setSiteId(gSites.getId()); gGroupSiteDto.setSiteId(gSites.getId());
int inserted1 = gSitesMapper.insertGSites(gGroupSiteDto); int inserted1 = gSitesMapper.insertGSites(gGroupSiteDto);
@ -75,14 +88,20 @@ public class GSitesServiceImpl implements IGSitesService
/** /**
* 修改站点 * 修改站点
* *
* @param gSites 站点 * @param gSitesEditDto 站点
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updateGSites(GSites gSites) public int updateGSites(GSitesEditDto gSitesEditDto)
{ {
gSites.setUpdateTime(DateUtils.getNowDate()); //不能有重复名字的站点
return gSitesMapper.updateById(gSites); GSites gSites1=gSitesMapper.selectOne(new LambdaQueryWrapper<GSites>().eq(GSites::getName,gSitesEditDto.getName()));
if(gSites1!=null){
throw new RuntimeException("站点名称已存在!");
}
GSites sites = new GSites();
BeanUtils.copyProperties(gSitesEditDto,sites);
return gSitesMapper.updateById(sites);
} }
/** /**

View File

@ -42,6 +42,7 @@
<include refid="selectGGroupsVo"/> <include refid="selectGGroupsVo"/>
<where> <where>
<if test="projectId != null "> and project_id = #{projectId}</if> <if test="projectId != null "> and project_id = #{projectId}</if>
<if test="tag != null "> and tag = #{tag}</if>
</where> </where>
</select> </select>

View File

@ -20,21 +20,6 @@
select id, site_id, parent_id, create_by, create_time, update_time, update_by, project_id, order_num from g_site_groups select id, site_id, parent_id, create_by, create_time, update_time, update_by, project_id, order_num from g_site_groups
</sql> </sql>
<select id="selectGSiteGroupsList" parameterType="GSiteGroups" resultMap="GSiteGroupsResult">
<include refid="selectGSiteGroupsVo"/>
<where>
<if test="siteId != null "> and site_id = #{siteId}</if>
<if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="projectId != null "> and project_id = #{projectId}</if>
<if test="orderNum != null "> and order_num = #{orderNum}</if>
</where>
</select>
<select id="selectGSiteGroupsById" parameterType="Long" resultMap="GSiteGroupsResult">
<include refid="selectGSiteGroupsVo"/>
where id = #{id}
</select>
<insert id="insertGSiteGroups" parameterType="GSiteGroups" useGeneratedKeys="true" keyProperty="id"> <insert id="insertGSiteGroups" parameterType="GSiteGroups" useGeneratedKeys="true" keyProperty="id">
insert into g_site_groups insert into g_site_groups
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@ -59,29 +44,8 @@
</trim> </trim>
</insert> </insert>
<update id="updateGSiteGroups" parameterType="GSiteGroups">
update g_site_groups
<trim prefix="SET" suffixOverrides=",">
<if test="siteId != null">site_id = #{siteId},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="projectId != null">project_id = #{projectId},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteGSiteGroupsById" parameterType="Long"> <delete id="deleteGSiteGroupsById" parameterType="Long">
delete from g_site_groups where id = #{id} delete from g_site_groups where id = #{id}
</delete> </delete>
<delete id="deleteGSiteGroupsByIds" parameterType="String">
delete from g_site_groups where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper> </mapper>

View File

@ -20,46 +20,16 @@
select id, name, icon, type, create_by, create_time, update_time, update_by, space from g_sites select id, name, icon, type, create_by, create_time, update_time, update_by, space from g_sites
</sql> </sql>
<select id="selectGSitesList" parameterType="GSites" resultMap="GSitesResult">
<include refid="selectGSitesVo"/>
<where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="icon != null and icon != ''"> and icon = #{icon}</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="space != null and space != ''"> and space = #{space}</if>
</where>
</select>
<select id="selectGSitesById" parameterType="Long" resultMap="GSitesResult"> <select id="selectGSitesById" parameterType="Long" resultMap="GSitesResult">
<include refid="selectGSitesVo"/> <include refid="selectGSitesVo"/>
where id = #{id} where id = #{id}
</select> </select>
<!-- <insert id="insertGSites" parameterType="GSites" useGeneratedKeys="true" keyProperty="id">-->
<!-- insert into g_sites-->
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
<!-- <if test="name != null and name != ''">name,</if>-->
<!-- <if test="icon != null">icon,</if>-->
<!-- <if test="type != null">type,</if>-->
<!-- <if test="createBy != null">create_by,</if>-->
<!-- <if test="createTime != null">create_time,</if>-->
<!-- <if test="updateTime != null">update_time,</if>-->
<!-- <if test="updateBy != null">update_by,</if>-->
<!-- <if test="space != null">space,</if>-->
<!-- </trim>-->
<!-- <trim prefix="values (" suffix=")" suffixOverrides=",">-->
<!-- <if test="name != null and name != ''">#{name},</if>-->
<!-- <if test="icon != null">#{icon},</if>-->
<!-- <if test="type != null">#{type},</if>-->
<!-- <if test="createBy != null">#{createBy},</if>-->
<!-- <if test="createTime != null">#{createTime},</if>-->
<!-- <if test="updateTime != null">#{updateTime},</if>-->
<!-- <if test="updateBy != null">#{updateBy},</if>-->
<!-- <if test="space != null">#{space},</if>-->
<!-- </trim>-->
<!-- </insert>-->
<update id="updateGSites" parameterType="GSites">
<update id="updateGSites" parameterType="GSitesEditDto">
update g_sites update g_sites
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if> <if test="name != null and name != ''">name = #{name},</if>