提交 1f38b121 编写于 作者: L laijiaping

完成api接口模块(api_model )新增、修改、删除、列表查询功能

上级 52d458be
/*******************************************************************************
* 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.ApiModelService;
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 ApiModelController {
@Autowired
private ApiModelService apiModelService;
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: queryApiModelList
* @Description: 获取api接口模块列表
*/
@RequestMapping("/post/ApiModelController/queryApiModelList")
@ResponseBody
public void queryApiModelList(InputObject inputObject, OutputObject outputObject) throws Exception {
apiModelService.queryApiModelList(inputObject, outputObject);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: insertApiModelMation
* @Description: 新增api接口模块信息
*/
@RequestMapping("/post/ApiModelController/insertApiModelMation")
@ResponseBody
public void insertApiModelMation(InputObject inputObject, OutputObject outputObject) throws Exception {
apiModelService.insertApiModelMation(inputObject, outputObject);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: deleteApiModelById
* @Description: 删除api接口模块信息
*/
@RequestMapping("/post/ApiModelController/deleteApiModelById")
@ResponseBody
public void deleteApiModelById(InputObject inputObject, OutputObject outputObject) throws Exception {
apiModelService.deleteApiModelById(inputObject, outputObject);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: selectApiModelById
* @Description: 通过id查找对应的api接口模块信息
*/
@RequestMapping("/post/ApiModelController/selectApiModelById")
@ResponseBody
public void selectApiModelById(InputObject inputObject, OutputObject outputObject) throws Exception {
apiModelService.selectApiModelById(inputObject, outputObject);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: editApiModelMationById
* @Description: 通过id编辑对应的api接口模块信息
*/
@RequestMapping("/post/ApiModelController/editApiModelMationById")
@ResponseBody
public void editApiModelMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
apiModelService.editApiModelMationById(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: ApiModelDao
* @Description: api接口模块数据层
* @author: skyeye云系列
* @date: 2021/11/27 16:12
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
public interface ApiModelDao {
public List<Map<String, Object>> queryApiModelList(Map<String, Object> map) throws Exception;
public Map<String, Object> queryApiModelMationByName(Map<String, Object> map) throws Exception;
public int insertApiModel(Map<String, Object> map) throws Exception;
public int deleteApiModelById(Map<String, Object> map) throws Exception;
public Map<String, Object> queryApiModelToEditById(Map<String, Object> map) throws Exception;
public int editApiModelById(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;
public interface ApiModelService {
public void queryApiModelList(InputObject inputObject, OutputObject outputObject) throws Exception;
public void insertApiModelMation(InputObject inputObject, OutputObject outputObject) throws Exception;
public void deleteApiModelById(InputObject inputObject, OutputObject outputObject) throws Exception;
public void selectApiModelById(InputObject inputObject, OutputObject outputObject) throws Exception;
public void editApiModelMationById(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.ApiModelDao;
import com.skyeye.service.ApiModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @ClassName: ApiModelServiceImpl
* @Description: api接口模块服务类
* @author: skyeye云系列
* @date: 2021/11/27 16:15
* @Copyright: 2021 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved.
* 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的
*/
@Service
public class ApiModelServiceImpl implements ApiModelService {
@Autowired
private ApiModelDao apiModelDao;
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: queryApiModelList
* @Description: 获取api接口模块表
*/
@Override
public void queryApiModelList(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 = apiModelDao.queryApiModelList(map);
outputObject.setBeans(beans);
outputObject.settotal(pages.getTotal());
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: insertApiModelMation
* @Description: 新增api接口模块
*/
@Override
@Transactional(value = "transactionManager")
public void insertApiModelMation(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = apiModelDao.queryApiModelMationByName(map);
if (bean != null && !bean.isEmpty()) {
outputObject.setreturnMessage("该模块名称已存在,请更换");
} else {
map.put("id", ToolUtil.getSurFaceId());
map.put("userId", inputObject.getLogParams().get("id"));
map.put("createTime", DateUtil.getTimeAndToString());
apiModelDao.insertApiModel(map);
}
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: deleteApiModelById
* @Description: 删除api接口模块信息
*/
@Override
@Transactional(value = "transactionManager")
public void deleteApiModelById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
apiModelDao.deleteApiModelById(map);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: selectApiModelById
* @Description: 通过id查找对应的api接口模块信息
*/
@Override
public void selectApiModelById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = apiModelDao.queryApiModelToEditById(map);
outputObject.setBean(bean);
outputObject.settotal(1);
}
/**
* @param inputObject
* @param outputObject
* @return void 返回类型
* @throws Exception 参数
* @throws
* @Title: editApiModelMationById
* @Description: 通过id编辑对应的api接口模块信息
*/
@Override
@Transactional(value = "transactionManager")
public void editApiModelMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = apiModelDao.queryApiModelMationByName(map);
if (bean != null && !bean.isEmpty()) {
outputObject.setreturnMessage("该模块名称已存在,请更换");
} else {
map.put("userId", inputObject.getLogParams().get("id"));
map.put("lastUpdateTime", DateUtil.getTimeAndToString());
apiModelDao.editApiModelById(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.ApiModelDao">
<select id="queryApiModelList" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
a.name `name`
FROM
api_model a
WHERE
1 = 1
<if test="name != '' and name != null">
AND a.name LIKE '%${name}%'
</if>
ORDER BY a.last_update_time DESC
</select>
<select id="queryApiModelMationByName" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id
FROM
api_model a
WHERE
a.name = #{name}
<if test="id != '' and id != null">
AND a.id != #{id}
</if>
</select>
<insert id="insertApiModel" parameterType="java.util.Map">
INSERT INTO api_model (id, `name`, create_id, create_time, last_update_id, last_update_time)
VALUES
(#{id}, #{name}, #{userId}, #{createTime}, #{userId}, #{createTime})
</insert>
<select id="queryApiModelToEditById" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id,
a.name `name`
FROM
api_model a
WHERE
a.id = #{id}
</select>
<update id="editApiModelById" parameterType="java.util.Map">
UPDATE api_model
<set>
`name` = #{name},
last_update_id = #{userId},
last_update_time = #{lastUpdateTime}
</set>
WHERE
id = #{id}
</update>
<delete id="deleteApiModelById" parameterType="java.util.Map">
DELETE
FROM
api_model
WHERE
id = #{id}
</delete>
</mapper>
\ No newline at end of file
......@@ -23,4 +23,25 @@
</url>
<!-- api接口信息结束 -->
<!-- api接口模块开始 -->
<url id="apimodel001" path="/post/ApiModelController/queryApiModelList" val="查询api接口模块列表信息" allUse="1" groupName="api接口">
<property id="name" name="name" ref="" var="模块名称" />
<property id="limit" name="limit" ref="required,num" var="分页参数,每页多少条数据" />
<property id="page" name="page" ref="required,num" var="分页参数,第几页"/>
</url>
<url id="apimodel002" path="/post/ApiModelController/insertApiModelMation" val="添加api接口模块信息" allUse="1" method="POST" groupName="api接口">
<property id="name" name="name" ref="required" var="模块名称" />
</url>
<url id="apimodel003" path="/post/ApiModelController/selectApiModelById" val="查询api接口模块信息用于数据回显" allUse="2" method="GET" groupName="api接口">
<property id="rowId" name="id" ref="required" var="模块Id"></property>
</url>
<url id="apimodel004" path="/post/ApiModelController/editApiModelMationById" val="编辑api接口模块信息" allUse="1" method="PUT" groupName="api接口">
<property id="rowId" name="id" ref="required" var="模块Id"></property>
<property id="name" name="name" ref="required" var="模块名称" />
</url>
<url id="apimodel005" path="/post/ApiModelController/deleteApiModelById" val="删除api接口模块信息" allUse="1" method="DELETE" groupName="api接口">
<property id="rowId" name="id" ref="required" var="模块Id"></property>
</url>
<!-- api接口模块结束 -->
</controller>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册