相关文章:
- tim工具包-dao层查询工具
- tim工具包-sql管理平台-admin
- tim工具包-自动生成api接口
- tim工具包-MyMath牛逼的计算工具
- tim工具包-数据处理工具
配合dao 工具 ApiSql 自动生成接口
import com.utils.ApiSql;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@RestController
public class ApiController extends BaseController {
@Autowired
ApiSql apiSql;
@RequestMapping(value = "/api/getItem/{groups}/{codes}", produces = {"application/json"}, consumes = {
"application/json"})
public Object getItem(@RequestBody Map param, @PathVariable(name = "groups", required = true) String groups,
@PathVariable(name = "codes", required = true) String codes) throws Throwable {
Map runSqlByParamItem = apiSql.runSqlByParamItem(param, groups, codes);
return doOutData(runSqlByParamItem);
}
@RequestMapping(value = "/api/getList/{groups}/{codes}", produces = {"application/json"}, consumes = {
"application/json"})
public Object getList(@RequestBody Map param, @PathVariable(name = "groups", required = true) String groups,
@PathVariable(name = "codes", required = true) String codes) throws Throwable {
List
将以上代码拷贝至应用中
根据body 传参调用以下接口
- getItem
- getList
- exeSql
- getPage
如果是web端调用带web的接口
- getItemWeb
- getListWeb
- exeSqlWeb
- getPageWeb
例如 http://127.0.0.1:8080/witbuild/api/getList/test/test
- test test 则为对应数据库中配置的脚本的groups 和codes
- 如不明白groups 和codes 是什么请查看这一片文章 《tim工具包-dao层查询工具》
一个脚本调用getItem 则查询单个数据
调用getList 则为查询一组数据
getPage 则为分页查询
exeSql 执行脚本内容