use of com.baomidou.mybatisplus.core.metadata.IPage in project JBM by numen06.
the class GatewayAccessLogsServiceImpl method findListPage.
/**
* 分页查询
*
* @param pageRequestBody
* @return
*/
@Override
public DataPaging<GatewayAccessLogs> findListPage(PageRequestBody pageRequestBody) {
GatewayAccessLogs query = pageRequestBody.tryGet(GatewayAccessLogs.class);
QueryWrapper<GatewayAccessLogs> queryWrapper = new QueryWrapper();
queryWrapper.lambda().likeRight(ObjectUtils.isNotEmpty(query.getPath()), GatewayAccessLogs::getPath, query.getPath()).eq(ObjectUtils.isNotEmpty(query.getIp()), GatewayAccessLogs::getIp, query.getIp()).eq(ObjectUtils.isNotEmpty(query.getServiceId()), GatewayAccessLogs::getServiceId, query.getServiceId());
queryWrapper.orderByDesc("request_time");
IPage page = gatewayLogsMapper.selectPage(pageRequestBody.getPageParams(), queryWrapper);
return ServiceUtils.pageToDataPaging(page);
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project kms by mahonelau.
the class DictUtils method parseDictText.
/**
* 本方法针对返回对象为Result 的IPage的分页列表数据进行动态字典注入
* 字典注入实现 通过对实体类添加注解@dict 来标识需要的字典内容,字典分为单字典code即可 ,table字典 code table text配合使用与原来jeecg的用法相同
* 示例为SysUser 字段为sex 添加了注解@Dict(dicCode = "sex") 会在字典服务立马查出来对应的text 然后在请求list的时候将这个字典text,已字段名称加_dictText形式返回到前端
* 例输入当前返回值的就会多出一个sex_dictText字段
* {
* sex:1,
* sex_dictText:"男"
* }
* 前端直接取值sext_dictText在table里面无需再进行前端的字典转换了
* customRender:function (text) {
* if(text==1){
* return "男";
* }else if(text==2){
* return "女";
* }else{
* return text;
* }
* }
* 目前vue是这么进行字典渲染到table上的多了就很麻烦了 这个直接在服务端渲染完成前端可以直接用
* @param result
*/
public void parseDictText(Object result) {
if (result instanceof Result) {
if (((Result) result).getResult() instanceof IPage) {
List<JSONObject> items = new ArrayList<>();
for (Object record : ((KmSearchResultObjVO) ((Result) result).getResult()).getKmSearchResultVOPage().getRecords()) {
ObjectMapper mapper = new ObjectMapper();
String json = "{}";
try {
// 解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
json = mapper.writeValueAsString(record);
} catch (JsonProcessingException e) {
log.error("json解析失败" + e.getMessage(), e);
}
JSONObject item = JSONObject.parseObject(json);
// for (Field field : record.getClass().getDeclaredFields()) {
for (Field field : oConvertUtils.getAllFields(record)) {
// update-end--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
if (field.getAnnotation(Dict.class) != null) {
String code = field.getAnnotation(Dict.class).dicCode();
String text = field.getAnnotation(Dict.class).dicText();
String table = field.getAnnotation(Dict.class).dictTable();
String key = String.valueOf(item.get(field.getName()));
// 翻译字典值对应的txt
String textValue = translateDictValue(code, text, table, key);
log.debug(" 字典Val : " + textValue);
log.debug(" __翻译字典字段__ " + field.getName() + CommonConstant.DICT_TEXT_SUFFIX + ": " + textValue);
item.put(field.getName() + CommonConstant.DICT_TEXT_SUFFIX, textValue);
}
// date类型默认转换string格式化日期
if (field.getType().getName().equals("java.util.Date") && field.getAnnotation(JsonFormat.class) == null && item.get(field.getName()) != null) {
SimpleDateFormat aDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName()))));
}
}
items.add(item);
}
// ((KmSearchResultObjVO) ((Result) result).getResult()).getKmSearchResultVOPage().setRecords(items);
}
}
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project kms by mahonelau.
the class DictAspect method parseDictText.
/**
* 本方法针对返回对象为Result 的IPage的分页列表数据进行动态字典注入
* 字典注入实现 通过对实体类添加注解@dict 来标识需要的字典内容,字典分为单字典code即可 ,table字典 code table text配合使用与原来jeecg的用法相同
* 示例为SysUser 字段为sex 添加了注解@Dict(dicCode = "sex") 会在字典服务立马查出来对应的text 然后在请求list的时候将这个字典text,已字段名称加_dictText形式返回到前端
* 例输入当前返回值的就会多出一个sex_dictText字段
* {
* sex:1,
* sex_dictText:"男"
* }
* 前端直接取值sext_dictText在table里面无需再进行前端的字典转换了
* customRender:function (text) {
* if(text==1){
* return "男";
* }else if(text==2){
* return "女";
* }else{
* return text;
* }
* }
* 目前vue是这么进行字典渲染到table上的多了就很麻烦了 这个直接在服务端渲染完成前端可以直接用
* @param result
*/
private void parseDictText(Object result) {
if (result instanceof Result) {
if (((Result) result).getResult() instanceof IPage) {
List<JSONObject> items = new ArrayList<>();
for (Object record : ((IPage) ((Result) result).getResult()).getRecords()) {
ObjectMapper mapper = new ObjectMapper();
String json = "{}";
try {
// 解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
json = mapper.writeValueAsString(record);
} catch (JsonProcessingException e) {
log.error("json解析失败" + e.getMessage(), e);
}
JSONObject item = JSONObject.parseObject(json);
// for (Field field : record.getClass().getDeclaredFields()) {
for (Field field : oConvertUtils.getAllFields(record)) {
// update-end--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
if (field.getAnnotation(Dict.class) != null) {
String code = field.getAnnotation(Dict.class).dicCode();
String text = field.getAnnotation(Dict.class).dicText();
String table = field.getAnnotation(Dict.class).dictTable();
String key = String.valueOf(item.get(field.getName()));
// 翻译字典值对应的txt
String textValue = translateDictValue(code, text, table, key);
log.debug(" 字典Val : " + textValue);
log.debug(" __翻译字典字段__ " + field.getName() + CommonConstant.DICT_TEXT_SUFFIX + ": " + textValue);
item.put(field.getName() + CommonConstant.DICT_TEXT_SUFFIX, textValue);
}
// date类型默认转换string格式化日期
if (field.getType().getName().equals("java.util.Date") && field.getAnnotation(JsonFormat.class) == null && item.get(field.getName()) != null) {
SimpleDateFormat aDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName()))));
}
}
items.add(item);
}
((IPage) ((Result) result).getResult()).setRecords(items);
} else if (((Result) result).getResult() instanceof KmSearchResultObjVO) {
List<JSONObject> items = new ArrayList<>();
for (Object record : ((KmSearchResultObjVO) ((Result) result).getResult()).getKmSearchResultVOPage().getRecords()) {
ObjectMapper mapper = new ObjectMapper();
String json = "{}";
try {
// 解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
json = mapper.writeValueAsString(record);
} catch (JsonProcessingException e) {
log.error("json解析失败" + e.getMessage(), e);
}
JSONObject item = JSONObject.parseObject(json);
// for (Field field : record.getClass().getDeclaredFields()) {
for (Field field : oConvertUtils.getAllFields(record)) {
// update-end--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
if (field.getAnnotation(Dict.class) != null) {
String code = field.getAnnotation(Dict.class).dicCode();
String text = field.getAnnotation(Dict.class).dicText();
String table = field.getAnnotation(Dict.class).dictTable();
String key = String.valueOf(item.get(field.getName()));
// 翻译字典值对应的txt
String textValue = translateDictValue(code, text, table, key);
log.debug(" 字典Val : " + textValue);
log.debug(" __翻译字典字段__ " + field.getName() + CommonConstant.DICT_TEXT_SUFFIX + ": " + textValue);
item.put(field.getName() + CommonConstant.DICT_TEXT_SUFFIX, textValue);
}
// date类型默认转换string格式化日期
if (field.getType().getName().equals("java.util.Date") && field.getAnnotation(JsonFormat.class) == null && item.get(field.getName()) != null) {
SimpleDateFormat aDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName()))));
}
}
items.add(item);
}
((KmSearchResultObjVO) ((Result) result).getResult()).getKmSearchResultVOPage().setRecords(items);
}
}
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project kms by mahonelau.
the class SysUserController method departUserList.
/**
* 部门用户列表
*/
@RequestMapping(value = "/departUserList", method = RequestMethod.GET)
public Result<IPage<SysUser>> departUserList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
String depId = req.getParameter("depId");
String username = req.getParameter("username");
// 根据部门ID查询,当前和下级所有的部门IDS
List<String> subDepids = new ArrayList<>();
// 部门id为空时,查询我的部门下所有用户
if (oConvertUtils.isEmpty(depId)) {
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
int userIdentity = user.getUserIdentity() != null ? user.getUserIdentity() : CommonConstant.USER_IDENTITY_1;
if (oConvertUtils.isNotEmpty(userIdentity) && userIdentity == CommonConstant.USER_IDENTITY_2) {
subDepids = sysDepartService.getMySubDepIdsByDepId(user.getDepartIds());
}
} else {
subDepids = sysDepartService.getSubDepIdsByDepId(depId);
}
if (subDepids != null && subDepids.size() > 0) {
IPage<SysUser> pageList = sysUserService.getUserByDepIds(page, subDepids, username);
// 批量查询用户的所属部门
// step.1 先拿到全部的 useids
// step.2 通过 useids,一次性查询用户的所属部门名字
List<String> userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList());
if (userIds != null && userIds.size() > 0) {
Map<String, String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
pageList.getRecords().forEach(item -> {
// 批量查询用户的所属部门
item.setOrgCode(useDepNames.get(item.getId()));
});
}
result.setSuccess(true);
result.setResult(pageList);
} else {
result.setSuccess(true);
result.setResult(null);
}
return result;
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project ddd-framework by ken-xue.
the class DictionaryRepositoryImpl method page.
@Override
public Page<Dictionary> page(DictionaryPageQry qry) {
QueryWrapper<DictionaryDO> qw = new QueryWrapper<>();
IPage doPage = dictionaryMapper.selectPage(new PageDTO(qry.getPageIndex(), qry.getPageSize()), qw);
return Page.of(doPage.getCurrent(), doPage.getSize(), doPage.getTotal(), dictionary2DOConvector.toDomainList(doPage.getRecords()));
}
Aggregations