package com.lf.server.controller.data;
|
|
import com.lf.server.aspect.SysLog;
|
import com.lf.server.controller.all.BaseController;
|
import com.lf.server.entity.all.ResponseMsg;
|
import com.lf.server.helper.ClassHelper;
|
import com.lf.server.helper.StringHelper;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
import com.lf.server.mapper.bd.*;
|
|
import java.util.List;
|
|
/**
|
* 数据检索
|
* @author WWW
|
*/
|
@Api(tags = "数据管理\\数据检索")
|
@RestController
|
@RequestMapping("/dataQuery")
|
public class DataQueryController extends BaseController {
|
@SysLog()
|
@ApiOperation(value = "查询记录数")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "ns", value = "名称空间", dataType = "String", paramType = "query", example = "bd"),
|
@ApiImplicitParam(name = "entity", value = "实体名称", dataType = "String", paramType = "query", example = "DlgAgnp")
|
})
|
@GetMapping({"/selectCount"})
|
public ResponseMsg<Integer> selectCount(String ns, String entity) {
|
try {
|
if (StringHelper.isEmpty(ns) || StringHelper.isEmpty(entity)) {
|
return fail("名称空间和实体名称不能为空", null);
|
}
|
|
String className = String.format("com.lf.server.mapper.%s.%sMapper", ns.trim(), entity.trim());
|
Object obj = ClassHelper.createInstance(className);
|
if (obj == null) {
|
return fail("查询对象不存在", null);
|
}
|
|
|
|
|
int count = 0;
|
return success(count);
|
} catch (Exception ex) {
|
return fail(ex.getMessage(), -1);
|
}
|
}
|
|
@SysLog()
|
@ApiOperation(value = "分页查询")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "ns", value = "名称空间", dataType = "String", paramType = "query", example = "bd"),
|
@ApiImplicitParam(name = "entity", value = "实体名称", dataType = "String", paramType = "query", example = "DlgAgnp")
|
})
|
@GetMapping(value = "/selectByPage")
|
public ResponseMsg<List<Object>> selectByPage(String ns, String entity, Integer pageSize, Integer pageIndex) {
|
try {
|
if (pageSize < 1 || pageIndex < 1) {
|
return fail("每页页数或分页数小于1", null);
|
}
|
|
List<Object> rs = null;
|
|
return success(rs);
|
} catch (Exception ex) {
|
return fail(ex.getMessage(), null);
|
}
|
}
|
}
|