目录
前言:springboot整体架构
1、ZjGxbMapper.xml
2、ZjGxbMapper.java
3、ZjGxbService.java
4、ZjGxbController.java
5、调用接口测试数据是否正确
6、打包放到服务器即可
前言:springboot整体架构
文件架构,主要编写框选的这几类
1、ZjGxbMapper.xml
编写业务相关的增删改查语句
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.appport.mapper.ZjGxbMapper">
<!-- 查询工程信息 根据需求编写sql语句--><select id="selectGcxx" resultType="java.util.HashMap" >select a,b,c from table3 </select>
</mapper>
2、ZjGxbMapper.java
定义接口
package com.appport.mapper;import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;import java.util.List;
import java.util.Map;@Repository
@Mapper
public interface ZjGxbMapper {/*** 查询所有的工程项目*/public List<Map<String,?>> selectGcxx();
}
3、ZjGxbService.java
调用接口
package com.appport.service;import com.appport.mapper.ZjGxbMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.List;
import java.util.Map;/*** @Author xiao_jiajia* @Description TODO $* @Date $ $* @Param $* @return $**/@Service
public class ZjGxbService {@Autowiredprivate ZjGxbMapper zjGxbMapper;//工程信息public List<Map<String,?>> selectGcxx(){List<Map<String,?>> gclist = zjGxbMapper.selectGcxx();return gclist;};
}
4、ZjGxbController.java
package com.appport.controller.system;import com.alibaba.fastjson.JSONObject;
import com.appport.service.ZjGxbService;
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.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;import java.util.List;
import java.util.Map;/*** @Author xiao_jiajia* @Description TODO $* @Date $ $* @Param xiao_jiajia$* @return $**/
@Controller
public class ZjGxbController {@Autowiredprivate ZjGxbService zjGxbService;/*** 查询工程信息*/@RequestMapping(value="project",method = RequestMethod.POST)@ResponseBodypublic JSONObject project(){JSONObject object = new JSONObject();List<Map<String,?>> projectList = zjGxbService.selectGcxx();object.put("projectList",projectList);object.put("code",200);return object;}}