Commit d1d003db authored by 黎博's avatar 黎博

修改获取接口列表接口

parent 53c02d66
......@@ -37,25 +37,14 @@ public class InterfaceController {
* @return
*/
@GetMapping("/list")
public JsonResult getInterfaceList(Integer moduleId,
public JsonResult getInterfaceList(Integer projectId,
Integer moduleId,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize) {
IPage<Interface> interfaceIPage = new Page<>(pageNum, pageSize);
IPage<Interface> interfaceIPageEntity;
if (moduleId != null) {
QueryWrapper<Interface> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("module_id", moduleId);
interfaceIPageEntity = interfaceService.page(interfaceIPage, queryWrapper);
} else {
interfaceIPageEntity = interfaceService.page(interfaceIPage);
}
IPage<Interface> interfaceIPageEntity = interfaceService.getInterfaceList(projectId, moduleId, pageNum, pageSize);
Map<String, Object> map = new HashMap<>();
List<Interface> interfaceList = interfaceIPageEntity.getRecords();
for (Interface anInterface: interfaceList) {
anInterface.setModuleName(autoModuleService.getById(anInterface.getModuleId()).getName());
}
map.put("total", interfaceIPageEntity.getTotal());
map.put("list", interfaceList);
map.put("list", interfaceIPageEntity.getRecords());
return JsonResult.buildSuccessResult(map);
}
......
......@@ -30,4 +30,6 @@ public class Interface {
private Date updateTime;
@TableField(exist = false)
private String moduleName;
@TableField(exist = false)
private String projectName;
}
......@@ -2,6 +2,8 @@ package cn.qg.holmes.mapper.auto;
import cn.qg.holmes.entity.auto.Interface;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
public interface InterfaceMapper extends BaseMapper<Interface> {
IPage<Interface> getInterfaceList(IPage<Interface> page, Integer projectId, Integer moduleId);
}
package cn.qg.holmes.service.auto;
import cn.qg.holmes.entity.auto.Interface;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
public interface InterfaceService extends IService<Interface> {
IPage<Interface> getInterfaceList(Integer projectId, Integer moduleId, Integer pageNum, Integer pageSize);
}
package cn.qg.holmes.service.auto.impl;
import cn.qg.holmes.entity.auto.AutoModule;
import cn.qg.holmes.entity.auto.Interface;
import cn.qg.holmes.mapper.auto.InterfaceMapper;
import cn.qg.holmes.service.auto.InterfaceService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 自动化-接口相关service
* @author libo
*/
@Service
public class InterfaceServiceImpl extends ServiceImpl<InterfaceMapper, Interface> implements InterfaceService {
@Autowired
InterfaceMapper interfaceMapper;
@Override
public IPage<Interface> getInterfaceList(Integer projectId, Integer moduleId, Integer pageNum, Integer pageSize) {
IPage<Interface> page = new Page<>(pageNum, pageSize);
IPage<Interface> interfaceIPage = interfaceMapper.getInterfaceList(page, projectId, moduleId);
return interfaceIPage;
}
}
<?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="cn.qg.holmes.mapper.auto.InterfaceMapper">
<select id="getInterfaceList" resultType="cn.qg.holmes.entity.auto.Interface">
SELECT it.*, am.`name` as moduleName, ap.`name` as projectName
FROM `interface` AS `it`
INNER JOIN `auto_module` AS `am` on it.`module_id` = am.`id`
INNER JOIN `auto_project` AS `ap` on am.`project_id` = ap.`id`
WHERE 1=1
<if test="projectId != null and projectId !=''">
AND ap.`id`= #{projectId}
</if>
<if test="moduleId != null and moduleId != ''">
AND am.`id` = #{moduleId}
</if>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment