提交 d98a8eac 编写于 作者: L laijiaping

api分组(api_group)新增、修改、删除、列表查询功能

上级 8f4f39d6
/*******************************************************************************
* Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye
******************************************************************************/
package com.skyeye.controller;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
import com.skyeye.service.ApiGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class ApiGroupController {
@Autowired
private ApiGroupService apiGroupService;
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: queryApiGroupList
* @Description: 获取api接口分组列表
*/
@RequestMapping("/post/ApiGroupController/queryApiGroupList")
@ResponseBody
public void queryApiGroupList(InputObject inputObject, OutputObject outputObject) throws Exception {
apiGroupService.queryApiGroupMationList(inputObject, outputObject);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: insertApiGroupMation
* @Description: 新增api接口分组信息
*/
@RequestMapping("/post/ApiGroupController/insertApiGroupMation")
@ResponseBody
public void insertApiGroupMation(InputObject inputObject, OutputObject outputObject) throws Exception {
apiGroupService.insertApiGroupMation(inputObject, outputObject);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: deleteApiGroupById
* @Description: 删除api接口分组信息
*/
@RequestMapping("/post/ApiGroupController/deleteApiGroupById")
@ResponseBody
public void deleteApiGroupById(InputObject inputObject, OutputObject outputObject) throws Exception {
apiGroupService.deleteApiGroupMationById(inputObject, outputObject);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: selectApiGroupById
* @Description: 通过id查找对应的api接口分组信息
*/
@RequestMapping("/post/ApiGroupController/selectApiGroupById")
@ResponseBody
public void selectApiGroupById(InputObject inputObject, OutputObject outputObject) throws Exception {
apiGroupService.selectApiGroupMationById(inputObject, outputObject);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: editApiGroupMationById
* @Description: 通过id编辑对应的api接口分组信息
*/
@RequestMapping("/post/ApiGroupController/editApiGroupMationById")
@ResponseBody
public void editApiGroupMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
apiGroupService.editApiGroupMationById(inputObject, outputObject);
}
}
/*******************************************************************************
* Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye
******************************************************************************/
package com.skyeye.dao;
import java.util.List;
import java.util.Map;
/**
* @ClassName: ApiGroupDao
* @Description: api接口分组数据层
* @author: skyeye云系列
* @date: 2021/11/28 13:20
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
public interface ApiGroupDao {
public List<Map<String, Object>> queryApiGroupList(Map<String, Object> map) throws Exception;
public Map<String, Object> queryApiGroupByName(Map<String, Object> map) throws Exception;
public int insertApiGroup(List<Map<String, Object>> beans) throws Exception;
public int deleteApiGroupById(Map<String, Object> map) throws Exception;
public int deleteApiGroupByModelId(Map<String, Object> map) throws Exception;
public Map<String, Object> queryApiGroupToEditById(Map<String, Object> map) throws Exception;
public int editApiGroupById(Map<String, Object> map) throws Exception;
}
/*******************************************************************************
* Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye
******************************************************************************/
package com.skyeye.service;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
import java.util.List;
import java.util.Map;
public interface ApiGroupService {
void queryApiGroupMationList(InputObject inputObject, OutputObject outputObject) throws Exception;
void insertApiGroupMation(InputObject inputObject, OutputObject outputObject) throws Exception;
void insertApiGroupMationList(List<Map<String, Object>> beans, String userId) throws Exception;
void deleteApiGroupMationById(InputObject inputObject, OutputObject outputObject) throws Exception;
void selectApiGroupMationById(InputObject inputObject, OutputObject outputObject) throws Exception;
void editApiGroupMationById(InputObject inputObject, OutputObject outputObject) throws Exception;
}
/*******************************************************************************
* Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye
******************************************************************************/
package com.skyeye.service.impl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.skyeye.common.object.InputObject;
import com.skyeye.common.object.OutputObject;
import com.skyeye.common.util.DateUtil;
import com.skyeye.common.util.ToolUtil;
import com.skyeye.dao.ApiGroupDao;
import com.skyeye.dao.ApiMationDao;
import com.skyeye.dao.ApiPropertyDao;
import com.skyeye.service.ApiGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* @ClassName: ApiGroupServiceImpl
* @Description: api接口分组服务类
* @author: skyeye云系列
* @date: 2021/11/28 13:45
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@Service
public class ApiGroupServiceImpl implements ApiGroupService {
@Autowired
private ApiGroupDao apiGroupDao;
@Autowired
private ApiMationDao apiMationDao;
@Autowired
private ApiPropertyDao apiPropertyDao;
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: queryApiGroupList
* @Description: 获取api接口分组表
*/
@Override
public void queryApiGroupMationList(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
map.put("userId", inputObject.getLogParams().get("id"));
Page pages = PageHelper.startPage(Integer.parseInt(map.get("page").toString()), Integer.parseInt(map.get("limit").toString()));
List<Map<String, Object>> beans = apiGroupDao.queryApiGroupList(map);
outputObject.setBeans(beans);
outputObject.settotal(pages.getTotal());
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: insertApiGroupMation
* @Description: 新增api接口分组
*/
@Override
@Transactional(value = "transactionManager")
public void insertApiGroupMation(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = apiGroupDao.queryApiGroupByName(map);
if (bean != null && !bean.isEmpty()) {
outputObject.setreturnMessage("该分组名称已存在,请更换");
} else {
this.insertApiGroupMationList(Arrays.asList(map), inputObject.getLogParams().get("id").toString());
}
}
@Override
@Transactional(value = "transactionManager")
public void insertApiGroupMationList(List<Map<String, Object>> beans, String userId) throws Exception{
beans.forEach(bean -> {
bean.put("id", ToolUtil.getSurFaceId());
bean.put("userId", userId);
bean.put("createTime", DateUtil.getTimeAndToString());
});
apiGroupDao.insertApiGroup(beans);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: deleteApiGroupMationById
* @Description: 删除api接口分组信息
*/
@Override
@Transactional(value = "transactionManager")
public void deleteApiGroupMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
apiPropertyDao.deleteApiPropertyByGroupId(map);
apiMationDao.deleteApiMationByGroupId(map);
apiGroupDao.deleteApiGroupById(map);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: selectApiGroupMationById
* @Description: 通过id查找对应的api接口分组信息
*/
@Override
public void selectApiGroupMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = apiGroupDao.queryApiGroupToEditById(map);
outputObject.setBean(bean);
outputObject.settotal(1);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: editApiGroupMationById
* @Description: 通过id编辑对应的api接口分组信息
*/
@Override
@Transactional(value = "transactionManager")
public void editApiGroupMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = apiGroupDao.queryApiGroupByName(map);
if (bean != null && !bean.isEmpty()) {
outputObject.setreturnMessage("该分组名称已存在,请更换");
} else {
map.put("userId", inputObject.getLogParams().get("id"));
map.put("lastUpdateTime", DateUtil.getTimeAndToString());
apiGroupDao.editApiGroupById(map);
}
}
}
<?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.skyeye.dao.ApiGroupDao">
<select id="queryApiGroupList" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
a.name `name`,
a.model_id modelId
FROM
api_group a
WHERE
1 = 1
<if test="name != '' and name != null">
AND a.name LIKE '%${name}%'
</if>
<if test="modelId != '' and modelId != null">
AND a.model_id = #{modelId}
</if>
ORDER BY a.last_update_time DESC
</select>
<select id="queryApiGroupByName" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id
FROM
api_group a
WHERE
a.name = #{name}
AND a.model_id = #{modelId}
<if test="id != '' and id != null">
AND a.id != #{id}
</if>
</select>
<insert id="insertApiGroup" parameterType="java.util.Map">
INSERT INTO api_group
(id, `name`, model_id, create_id, create_time, last_update_id, last_update_time)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id}, #{item.name}, #{item.modelId}, #{item.userId}, #{item.createTime}, #{item.userId}, #{item.createTime})
</foreach>
</insert>
<select id="queryApiGroupToEditById" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
a.name `name`,
a.model_id modelId
FROM
api_group a
WHERE
a.id = #{id}
</select>
<update id="editApiGroupById" parameterType="java.util.Map">
UPDATE api_group
<set>
`name` = #{name},
model_id = #{modelId}
</set>
WHERE
id = #{id}
</update>
<delete id="deleteApiGroupById" parameterType="java.util.Map">
DELETE
FROM
api_group
WHERE
id = #{id}
</delete>
<delete id="deleteApiGroupByModelId" parameterType="java.util.Map">
DELETE
FROM
api_group
WHERE
model_id = #{id}
</delete>
</mapper>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册