提交 a4b82c18 编写于 作者: L laijiaping

api参数(api_property)新增、修改、删除、列表查询功能

上级 d98a8eac
/*******************************************************************************
* 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.ApiPropertyService;
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 ApiPropertyController {
@Autowired
private ApiPropertyService apiPropertyService;
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: queryApiPropertyList
* @Description: 获取api接口参数列表
*/
@RequestMapping("/post/ApiPropertyController/queryApiPropertyList")
@ResponseBody
public void queryApiPropertyList(InputObject inputObject, OutputObject outputObject) throws Exception {
apiPropertyService.queryApiPropertyMationList(inputObject, outputObject);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: insertApiPropertyMation
* @Description: 新增api接口参数信息
*/
@RequestMapping("/post/ApiPropertyController/insertApiPropertyMation")
@ResponseBody
public void insertApiPropertyMation(InputObject inputObject, OutputObject outputObject) throws Exception {
apiPropertyService.insertApiPropertyMation(inputObject, outputObject);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: deleteApiPropertyById
* @Description: 删除api接口参数信息
*/
@RequestMapping("/post/ApiPropertyController/deleteApiPropertyById")
@ResponseBody
public void deleteApiPropertyById(InputObject inputObject, OutputObject outputObject) throws Exception {
apiPropertyService.deleteApiPropertyMationById(inputObject, outputObject);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: selectApiPropertyById
* @Description: 通过id查找对应的api接口参数信息
*/
@RequestMapping("/post/ApiPropertyController/selectApiPropertyById")
@ResponseBody
public void selectApiPropertyById(InputObject inputObject, OutputObject outputObject) throws Exception {
apiPropertyService.selectApiPropertyMationById(inputObject, outputObject);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: editApiPropertyMationById
* @Description: 通过id编辑对应的api接口参数信息
*/
@RequestMapping("/post/ApiPropertyController/editApiPropertyMationById")
@ResponseBody
public void editApiPropertyMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
apiPropertyService.editApiPropertyMationById(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: ApiPropertyDao
* @Description: api接口参数数据层
* @author: skyeye云系列
* @date: 2021/11/28 14:42
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
public interface ApiPropertyDao {
public List<Map<String, Object>> queryApiPropertyList(Map<String, Object> map) throws Exception;
public Map<String, Object> queryApiPropertyMationByApiId(Map<String, Object> map) throws Exception;
public int insertApiProperty(List<Map<String, Object>> beans) throws Exception;
public int deleteApiPropertyById(Map<String, Object> map) throws Exception;
public int deleteApiPropertyByApiId(Map<String, Object> map) throws Exception;
public int deleteApiPropertyByGroupId(Map<String, Object> map) throws Exception;
public int deleteApiPropertyByModelId(Map<String, Object> map) throws Exception;
public Map<String, Object> queryApiPropertyToEditById(Map<String, Object> map) throws Exception;
public int editApiPropertyById(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 ApiPropertyService {
void queryApiPropertyMationList(InputObject inputObject, OutputObject outputObject) throws Exception;
void insertApiPropertyMation(InputObject inputObject, OutputObject outputObject) throws Exception;
void insertApiPropertyMationList(List<Map<String, Object>> beans, String userId) throws Exception;
void deleteApiPropertyMationById(InputObject inputObject, OutputObject outputObject) throws Exception;
void selectApiPropertyMationById(InputObject inputObject, OutputObject outputObject) throws Exception;
void editApiPropertyMationById(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.ApiPropertyDao;
import com.skyeye.service.ApiPropertyService;
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: ApiPropertyServiceImpl
* @Description: api接口参数服务类
* @author: skyeye云系列
* @date: 2021/11/28 15:10
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@Service
public class ApiPropertyServiceImpl implements ApiPropertyService {
@Autowired
private ApiPropertyDao apiPropertyDao;
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception ApiProperty
* @throws
* @Title: queryApiPropertyList
* @Description: 获取api接口参数表
*/
@Override
public void queryApiPropertyMationList(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 = apiPropertyDao.queryApiPropertyList(map);
outputObject.setBeans(beans);
outputObject.settotal(pages.getTotal());
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception ApiProperty
* @throws
* @Title: insertApiPropertyMation
* @Description: 新增api接口参数
*/
@Override
@Transactional(value = "transactionManager")
public void insertApiPropertyMation(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = apiPropertyDao.queryApiPropertyMationByApiId(map);
if (bean != null && !bean.isEmpty()) {
outputObject.setreturnMessage("该API参数已存在,请更换");
} else {
this.insertApiPropertyMationList(Arrays.asList(map), inputObject.getLogParams().get("id").toString());
}
}
@Override
@Transactional(value = "transactionManager")
public void insertApiPropertyMationList(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());
});
apiPropertyDao.insertApiProperty(beans);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception ApiProperty
* @throws
* @Title: deleteApiPropertyMationById
* @Description: 删除api接口参数信息
*/
@Override
@Transactional(value = "transactionManager")
public void deleteApiPropertyMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
apiPropertyDao.deleteApiPropertyById(map);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception ApiProperty
* @throws
* @Title: selectApiPropertyMationById
* @Description: 通过id查找对应的api接口参数信息
*/
@Override
public void selectApiPropertyMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = apiPropertyDao.queryApiPropertyToEditById(map);
outputObject.setBean(bean);
outputObject.settotal(1);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception ApiProperty
* @throws
* @Title: editApiPropertyMationById
* @Description: 通过id编辑对应的api接口参数信息
*/
@Override
@Transactional(value = "transactionManager")
public void editApiPropertyMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
apiPropertyDao.deleteApiPropertyById(map);
this.insertApiPropertyMationList(Arrays.asList(map), inputObject.getLogParams().get("id").toString());
}
}
<?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.ApiPropertyDao">
<select id="queryApiPropertyList" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
a.api_id apiId,
a.property_id propertyId,
a.property_name propertyName,
a.ref ref,
a.example_default exampleDefault,
a.default `default`,
a.remark remark
FROM
api_property a
WHERE
1 = 1
<if test="apiId != '' and apiId != null">
AND a.api_id = #{apiId}
</if>
<if test="propertyId != '' and propertyId != null">
AND a.property_id = #{propertyId}
</if>
<if test="propertyName != '' and propertyName != null">
AND a.property_name = #{propertyName}
</if>
ORDER BY a.last_update_time DESC
</select>
<select id="queryApiPropertyMationByApiId" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id
FROM
api_property a
WHERE
a.api_id = #{apiId}
<if test="id != '' and id != null">
AND a.id != #{id}
</if>
</select>
<insert id="insertApiProperty" parameterType="java.util.Map">
INSERT INTO api_property
(id, `default`, api_id, property_id, property_name, ref, example_default, remark, create_id, create_time, last_update_id, last_update_time)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id}, #{item.default}, #{item.apiId}, #{item.propertyId}, #{item.propertyName}, #{item.ref}, #{item.exampleDefault}, #{item.remark}, #{item.userId}, #{item.createTime}, #{item.userId}, #{item.createTime})
</foreach>
</insert>
<select id="queryApiPropertyToEditById" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
a.api_id apiId,
a.property_id propertyId,
a.property_name propertyName,
a.ref ref,
a.example_default exampleDefault,
a.default `default`,
a.remark remark
FROM
api_property a
WHERE
a.id = #{id}
</select>
<update id="editApiPropertyById" parameterType="java.util.Map">
UPDATE api_property
<set>
`default` = #{defaul},
api_id = #{apiId},
property_id = #{propertyId},
property_name = #{propertyName},
ref = #{ref},
example_default = #{exampleDefault},
remark = #{remark}
</set>
WHERE
id = #{id}
</update>
<delete id="deleteApiPropertyById" parameterType="java.util.Map">
DELETE
FROM
api_property
WHERE
id = #{id}
</delete>
<delete id="deleteApiPropertyByApiId" parameterType="java.util.Map">
DELETE
FROM
api_property
WHERE
api_id = #{id}
</delete>
<delete id="deleteApiPropertyByGroupId" parameterType="java.util.Map">
DELETE a
FROM
api_property a
INNER JOIN api_mation b ON a.api_id = b.id
INNER JOIN api_group d ON b.group_id = d.id
WHERE
b.group_id = #{id}
</delete>
<delete id="deleteApiPropertyByModelId" parameterType="java.util.Map">
DELETE a
FROM
api_property a
LEFT JOIN api_mation b ON a.api_id = b.id
LEFT JOIN api_group d ON b.group_id = d.id
LEFT JOIN api_model f ON d.model_id = f.id
WHERE
f.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.
先完成此消息的编辑!
想要评论请 注册