This commit is contained in:
xiangwbs
2018-06-22 20:16:10 +08:00
parent 51fa478fdc
commit ec4c6498e1
20 changed files with 237 additions and 79 deletions
@@ -1,6 +1,5 @@
package com.xwbing.domain.entity.sys;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -19,7 +18,6 @@ import javax.validation.constraints.Pattern;
@EqualsAndHashCode(callSuper = true)
@Data
@Entity(name = "system_config")
@ApiModel
public class SysConfig extends BaseEntity {
private static final long serialVersionUID = -7587016038432881980L;
@ApiModelProperty(value = "配置项的code",example = "email_config",required = true)
@@ -1,6 +1,5 @@
package com.xwbing.domain.entity.sys;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -8,8 +7,6 @@ import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.validation.constraints.Pattern;
import java.util.List;
@@ -21,7 +18,6 @@ import java.util.List;
*/
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel
public class SysUser extends BaseEntity {
private static final long serialVersionUID = -2447528751353457021L;
public static String table = "sys_user_info";
@@ -0,0 +1,20 @@
package com.xwbing.domain.entity.vo;
import com.xwbing.domain.entity.sys.SysAuthority;
import com.xwbing.util.Pagination;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 项目名称: boot-module-demo
* 创建时间: 2018/1/18 15:52
* 作者: xiangwb
* 说明:
*/
@Data
@ApiModel
public class PageSysAuthorityVo extends RestMessageVo {
@ApiModelProperty(value = "返回数据")
private Pagination<SysAuthority> data;
}
@@ -1,12 +1,11 @@
package com.xwbing.domain.entity.vo;
import com.xwbing.domain.entity.sys.SysRole;
import com.xwbing.util.Pagination;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 项目名称: boot-module-demo
* 创建时间: 2018/1/18 15:57
@@ -15,7 +14,7 @@ import java.util.List;
*/
@Data
@ApiModel
public class ListSysRoleVo extends RestMessageVo {
public class PageSysRoleVo extends RestMessageVo {
@ApiModelProperty(value = "返回数据")
private List<SysRole> data;
private Pagination<SysRole> data;
}
@@ -1,12 +1,11 @@
package com.xwbing.domain.entity.vo;
import com.xwbing.domain.entity.sys.SysUserLoginInOut;
import com.xwbing.util.Pagination;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 项目名称: boot-module-demo
* 创建时间: 2018/1/18 16:05
@@ -15,7 +14,7 @@ import java.util.List;
*/
@Data
@ApiModel
public class ListSysUserLoginInOutVo extends RestMessageVo {
public class PageSysUserLoginInOutVo extends RestMessageVo {
@ApiModelProperty(value = "返回数据")
private List<SysUserLoginInOut> data;
private Pagination<SysUserLoginInOut> data;
}
@@ -1,12 +1,11 @@
package com.xwbing.domain.entity.vo;
import com.xwbing.domain.entity.sys.SysUser;
import com.xwbing.util.Pagination;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 项目名称: boot-module-demo
* 创建时间: 2018/1/18 16:01
@@ -15,7 +14,7 @@ import java.util.List;
*/
@Data
@ApiModel
public class ListSysUserVo extends RestMessageVo {
public class PageSysUserVo extends RestMessageVo {
@ApiModelProperty(value = "返回数据")
private List<SysUser> data;
private Pagination<SysUser> data;
}
@@ -1,11 +1,14 @@
package com.xwbing.service.sys;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xwbing.constant.CommonConstant;
import com.xwbing.domain.entity.sys.SysAuthority;
import com.xwbing.domain.entity.sys.SysRoleAuthority;
import com.xwbing.domain.entity.vo.SysAuthVo;
import com.xwbing.domain.mapper.sys.SysAuthorityMapper;
import com.xwbing.exception.BusinessException;
import com.xwbing.util.Pagination;
import com.xwbing.util.PassWordUtil;
import com.xwbing.util.RestMessage;
import org.apache.commons.collections.CollectionUtils;
@@ -161,6 +164,21 @@ public class SysAuthorityService {
return authorityMapper.find(map);
}
/**
* 分页查询
*
* @param enable
* @return
*/
public Pagination pageByEnable(String enable, Pagination page) {
Map<String, Object> map = new HashMap<>();
if (StringUtils.isNotEmpty(enable)) {
map.put("enable", enable);
}
PageInfo<SysAuthority> pageInfo = PageHelper.startPage(page.getCurrentPage(), page.getPageSize()).doSelectPageInfo(() -> authorityMapper.find(map));
return page.result(page, pageInfo);
}
/**
* 根据状态查询所有子节点
*
@@ -326,4 +344,3 @@ public class SysAuthorityService {
return authorities.size() == 0;
}
}
@@ -1,11 +1,14 @@
package com.xwbing.service.sys;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xwbing.constant.CommonConstant;
import com.xwbing.domain.entity.sys.SysRole;
import com.xwbing.domain.entity.sys.SysRoleAuthority;
import com.xwbing.domain.entity.sys.SysUserRole;
import com.xwbing.domain.mapper.sys.SysRoleMapper;
import com.xwbing.exception.BusinessException;
import com.xwbing.util.Pagination;
import com.xwbing.util.PassWordUtil;
import com.xwbing.util.RestMessage;
import org.apache.commons.collections.CollectionUtils;
@@ -135,15 +138,16 @@ public class SysRoleService {
}
/**
* 根据是否启用列表查询
* 根据是否启用查询
*
* @param enable
* @return
*/
public List<SysRole> listAllByEnable(String enable) {
public Pagination pageByEnable(String enable, Pagination page) {
Map<String, Object> map = new HashMap<>();
map.put("enable", enable);
return roleMapper.find(map);
PageInfo<SysRole> pageInfo = PageHelper.startPage(page.getCurrentPage(), page.getPageSize()).doSelectPageInfo(() -> roleMapper.find(map));
return page.result(page, pageInfo);
}
/**
@@ -193,4 +197,3 @@ public class SysRoleService {
return sysRoles.size() == 0;
}
}
@@ -1,8 +1,11 @@
package com.xwbing.service.sys;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xwbing.constant.CommonEnum;
import com.xwbing.domain.entity.sys.SysUserLoginInOut;
import com.xwbing.domain.mapper.sys.SysUserLoginInOutMapper;
import com.xwbing.util.Pagination;
import com.xwbing.util.RestMessage;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@@ -44,12 +47,12 @@ public class SysUserLoginInOutService {
}
/**
* 根据类型列表查询
* 根据类型分页查询
*
* @param inout
* @return
*/
public List<SysUserLoginInOut> listByType(int inout, String startDate, String endDate) {
public Pagination pageByType(int inout, String startDate, String endDate, Pagination page) {
Map<String, Object> map = new HashMap<>();
map.put("inout", inout);
if (StringUtils.isNotEmpty(startDate)) {
@@ -58,7 +61,8 @@ public class SysUserLoginInOutService {
if (StringUtils.isNotEmpty(endDate)) {
map.put("endDate", endDate + " 23:59:59");
}
List<SysUserLoginInOut> list = loginInOutMapper.findByInoutType(map);
PageInfo<SysUserLoginInOut> pageInfo = PageHelper.startPage(page.getCurrentPage(), page.getPageSize()).doSelectPageInfo(() -> loginInOutMapper.findByInoutType(map));
List<SysUserLoginInOut> list = pageInfo.getList();
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(inOut -> {
//登录登出
@@ -66,7 +70,6 @@ public class SysUserLoginInOutService {
inOut.setInoutTypeName(inOutEnum.getName());
});
}
return list;
return page.result(page, pageInfo);
}
}
@@ -1,6 +1,8 @@
package com.xwbing.service.sys;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xwbing.constant.CommonConstant;
import com.xwbing.constant.CommonEnum;
import com.xwbing.domain.entity.dto.UserDto;
@@ -22,9 +24,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.BufferedOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -185,20 +185,29 @@ public class SysUserService {
}
/**
* 列表查询
* 分页查询
*
* @return
*/
public List<SysUser> listAll() {
List<SysUser> all = userMapper.findAll();
public Pagination page(String name, String sex, Pagination page) {
Map<String, Object> map = new HashMap<>();
if (StringUtils.isNotEmpty(name)) {
map.put("name", name);
}
if (StringUtils.isNotEmpty(sex)) {
map.put("sex", sex);
}
PageInfo<SysUser> pageInfo = PageHelper.startPage(page.getCurrentPage(), page.getPageSize()).doSelectPageInfo(() -> userMapper.find(map));
List<SysUser> all = pageInfo.getList();
if (CollectionUtils.isNotEmpty(all)) {
all.forEach(sysUser -> {
//性别
CommonEnum.SexEnum sexEnum = Arrays.stream(CommonEnum.SexEnum.values()).filter(obj -> obj.getCode().equals(sysUser.getSex())).findFirst().get();
sysUser.setSexName(sexEnum.getName());
});
pageInfo.setList(all);
}
return all;
return page.result(page, pageInfo);
}
/**
@@ -466,4 +475,3 @@ public class SysUserService {
return EmailUtil.sendTextEmail(emailModel);
}
}
@@ -0,0 +1,63 @@
package com.xwbing.util;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 项目名称: boot-module-pro
* 创建时间: 2018/5/7 9:56
* 作者: xiangwb
* 说明: 分页基础类
*/
@Data
@ApiModel
public class Pagination<T> {
@ApiModelProperty(value = "当前页")
private Integer currentPage = 1;
@ApiModelProperty(value = "每页显示的总条数")
private Integer pageSize = 10;
@ApiModelProperty(value = "总条数")
private Long totalNum;
@ApiModelProperty(value = "是否有下一页")
private Boolean hasNext;
@ApiModelProperty(value = "总页数")
private Integer totalPage;
@ApiModelProperty(value = "分页结果")
private List<T> items;
public Pagination() {
super();
}
public Pagination(PageInfo pageInfo) {
super();
this.currentPage = pageInfo.getPageNum();
this.pageSize = pageInfo.getPageSize();
this.totalNum = pageInfo.getTotal();
this.totalPage = pageInfo.getPages();
this.items = (List<T>) JsonUtil.beanToMap(pageInfo.getList());
this.hasNext = pageInfo.isHasNextPage();
}
public Pagination(Page page) {
super();
this.currentPage = page.getPageNum();
this.pageSize = page.getPageSize();
this.totalNum = page.getTotal();
this.totalPage = page.getPages();
this.items = (List<T>) JsonUtil.beanToMap(page);
}
public Pagination result(Pagination page, PageInfo pageInfo) {
page.setTotalNum(pageInfo.getTotal());
page.setTotalPage(pageInfo.getPages());
page.setItems((List) JsonUtil.beanToMap(pageInfo.getList()));
page.setHasNext(pageInfo.isHasNextPage());
return page;
}
}
@@ -27,6 +27,12 @@
</sql>
<sql id="condition">
<where>
<if test="name!=null">
name like CONCAT(#{name},'%')
</if>
<if test="sex!=null">
and sex=#{sex}
</if>
</where>
</sql>
<!-- 插入 -->
@@ -14,7 +14,6 @@ import io.swagger.annotations.ApiImplicitParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -7,17 +7,21 @@ import com.xwbing.constant.CommonConstant;
import com.xwbing.constant.CommonEnum;
import com.xwbing.domain.entity.sys.SysAuthority;
import com.xwbing.domain.entity.vo.ListSysAuthorityVo;
import com.xwbing.domain.entity.vo.PageSysAuthorityVo;
import com.xwbing.domain.entity.vo.RestMessageVo;
import com.xwbing.domain.entity.vo.SysAuthVo;
import com.xwbing.redis.RedisService;
import com.xwbing.service.sys.SysAuthorityService;
import com.xwbing.util.JsonResult;
import com.xwbing.util.Pagination;
import com.xwbing.util.RestMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import java.util.List;
@@ -96,13 +100,17 @@ public class SysAuthorityControl {
return JsonResult.toJSONObj(result);
}
@LogInfo("根据是否启用查询所有权限")
@ApiOperation(value = "根据是否启用查询所有权限", response = ListSysAuthorityVo.class)
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query", dataType = "string")
@GetMapping("listByEnable")
public JSONObject listByEnable(String enable) {
List<SysAuthority> authoritys = sysAuthorityService.listByEnable(enable);
return JsonResult.toJSONObj(authoritys, "");
@LogInfo("根据是否启用分页查询所有权限")
@ApiOperation(value = "根据是否启用分页查询所有权限", response = PageSysAuthorityVo.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "currentPage", value = "当前页", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "页数", paramType = "query", dataType = "int")
})
@GetMapping("pageByEnable")
public JSONObject pageByEnable(String enable, @ApiIgnore Pagination page) {
Pagination pagination = sysAuthorityService.pageByEnable(enable, page);
return JsonResult.toJSONObj(pagination, "");
}
@LogInfo("根据父节点查询子节点")
@@ -5,19 +5,22 @@ import com.xwbing.annotation.LogInfo;
import com.xwbing.domain.entity.sys.SysAuthority;
import com.xwbing.domain.entity.sys.SysRole;
import com.xwbing.domain.entity.sys.SysRoleAuthority;
import com.xwbing.domain.entity.vo.ListSysRoleVo;
import com.xwbing.domain.entity.vo.PageSysRoleVo;
import com.xwbing.domain.entity.vo.RestMessageVo;
import com.xwbing.domain.entity.vo.SysRoleVo;
import com.xwbing.service.sys.SysAuthorityService;
import com.xwbing.service.sys.SysRoleAuthorityService;
import com.xwbing.service.sys.SysRoleService;
import com.xwbing.util.JsonResult;
import com.xwbing.util.Pagination;
import com.xwbing.util.RestMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import java.util.ArrayList;
@@ -85,17 +88,21 @@ public class SysRoleControl {
return JsonResult.toJSONObj(sysRole, "");
}
@LogInfo("根据是否启用查询所有角色")
@ApiOperation(value = "根据是否启用查询所有角色", response = ListSysRoleVo.class)
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query", dataType = "string")
@GetMapping("listByEnable")
public JSONObject listByEnable(String enable) {
List<SysRole> sysRoles = sysRoleService.listAllByEnable(enable);
return JsonResult.toJSONObj(sysRoles, "");
@LogInfo("根据是否启用分页查询所有角色")
@ApiOperation(value = "根据是否启用分页查询所有角色", response = PageSysRoleVo.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "currentPage", value = "当前页", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "页数", paramType = "query", dataType = "int")
})
@GetMapping("pageByEnable")
public JSONObject pageByEnable(String enable, @ApiIgnore Pagination page) {
Pagination pagination = sysRoleService.pageByEnable(enable, page);
return JsonResult.toJSONObj(pagination, "");
}
@LogInfo("根据角色主键查找权限")
@ApiOperation(value = "根据角色主键查找权限", response = ListSysRoleVo.class)
@ApiOperation(value = "根据角色主键查找权限", response = PageSysRoleVo.class)
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query", dataType = "string")
@GetMapping("listAuthorityByRoleId")
public JSONObject listAuthorityByRoleId(@RequestParam String roleId, String enable) {
@@ -12,16 +12,12 @@ import com.xwbing.service.sys.SysAuthorityService;
import com.xwbing.service.sys.SysRoleService;
import com.xwbing.service.sys.SysUserRoleService;
import com.xwbing.service.sys.SysUserService;
import com.xwbing.util.CommonDataUtil;
import com.xwbing.util.JsonResult;
import com.xwbing.util.RestMessage;
import com.xwbing.util.ThreadLocalUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.xwbing.util.*;
import io.swagger.annotations.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@@ -94,12 +90,18 @@ public class SysUserControl {
return JsonResult.toJSONObj(sysUser, "");
}
@LogInfo("列表查询所有用户")
@ApiOperation(value = "列表查询所有用户", response = ListSysUserVo.class)
@GetMapping("listAll")
public JSONObject listAll() {
List<SysUser> list = sysUserService.listAll();
return JsonResult.toJSONObj(list, "");
@LogInfo("查询所有用户")
@ApiOperation(value = "查询所有用户", response = PageSysUserVo.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "name", value = "名字", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "sex", value = "性别", paramType = "query", dataType = "string"),
@ApiImplicitParam(name = "currentPage", value = "当前页", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "页数", paramType = "query", dataType = "int")
})
@GetMapping("page")
public JSONObject page(String name, String sex, @ApiIgnore Pagination page) {
Pagination pagination = sysUserService.page(name, sex, page);
return JsonResult.toJSONObj(pagination, "");
}
@LogInfo("登录")
@@ -212,7 +214,7 @@ public class SysUserControl {
}
@LogInfo("根据用户主键查找所拥有的角色")
@ApiOperation(value = "根据用户主键查找所拥有的角色", response = ListSysRoleVo.class)
@ApiOperation(value = "根据用户主键查找所拥有的角色", response = PageSysRoleVo.class)
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query", dataType = "string")
@GetMapping("listRoleByUserId")
public JSONObject listRoleByUserId(@RequestParam String userId, String enable) {
@@ -224,7 +226,7 @@ public class SysUserControl {
}
@LogInfo("根据用户主键查找所拥有的权限")
@ApiOperation(value = "根据用户主键查找所拥有的权限", response = ListSysAuthorityVo.class)
@ApiOperation(value = "根据用户主键查找所拥有的权限", response = PageSysAuthorityVo.class)
@ApiImplicitParam(name = "enable", value = "是否启用,格式Y|N", paramType = "query", dataType = "string")
@GetMapping("listAuthorityByUserId")
public JSONObject listAuthorityByUserId(@RequestParam String userId, String enable) {
@@ -2,19 +2,21 @@ package com.xwbing.controller.sys;
import com.alibaba.fastjson.JSONObject;
import com.xwbing.annotation.LogInfo;
import com.xwbing.domain.entity.sys.SysUserLoginInOut;
import com.xwbing.domain.entity.vo.ListSysUserLoginInOutVo;
import com.xwbing.domain.entity.vo.PageSysUserLoginInOutVo;
import com.xwbing.service.sys.SysUserLoginInOutService;
import com.xwbing.util.JsonResult;
import com.xwbing.util.Pagination;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import java.util.List;
/**
* 项目名称: boot-module-demo
@@ -30,10 +32,14 @@ public class SysUserLoginInOutControl {
private SysUserLoginInOutService inOutService;
@LogInfo("获取登录或登出信息")
@ApiOperation(value = "获取登录或登出信息", response = ListSysUserLoginInOutVo.class)
@GetMapping("listByType")
public JSONObject listByType(@RequestParam int inout,@RequestParam String startDate,@RequestParam String endDate) {
List<SysUserLoginInOut> sysUserLoginInOuts = inOutService.listByType(inout,startDate,endDate);
return JsonResult.toJSONObj(sysUserLoginInOuts, "获取列表成功");
@ApiOperation(value = "获取登录或登出信息", response = PageSysUserLoginInOutVo.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "currentPage", value = "当前页", paramType = "query", dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "页数", paramType = "query", dataType = "int")
})
@GetMapping("pageByType")
public JSONObject pageByType(@RequestParam int inout, @RequestParam String startDate, @RequestParam String endDate, @ApiIgnore Pagination page) {
Pagination pagination = inOutService.pageByType(inout, startDate, endDate, page);
return JsonResult.toJSONObj(pagination, "获取列表成功");
}
}
+3 -1
View File
@@ -63,9 +63,11 @@ spring:
size: 1
#mybatis
mybatis:
mapper-locations: #classpath:mapper/*.xml
mapper-locations: #classpath:mapper/**/*.xml
type-aliases-package: #com.xwbing.domain.entity
config-location: # classpath:mybatisConfig.xml
pagehelper:
helper-dialect: mysql
#log
logging:
config: classpath:log4j2.xml
@@ -1,17 +1,23 @@
package com.xwbing.service;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xwbing.BaseTest;
import com.xwbing.domain.entity.ExpressInfo;
import com.xwbing.domain.entity.sys.DataDictionary;
import com.xwbing.domain.entity.sys.SysRole;
import com.xwbing.domain.entity.sys.SysUserLoginInOut;
import com.xwbing.domain.entity.vo.ExpressInfoVo;
import com.xwbing.domain.mapper.sys.SysUserLoginInOutMapper;
import com.xwbing.rabbit.Sender;
import com.xwbing.redis.RedisService;
import com.xwbing.service.rest.ExpressDeliveryService;
import com.xwbing.service.rest.QRCodeZipService;
import com.xwbing.service.sys.DataDictionaryService;
import com.xwbing.service.sys.SysRoleService;
import com.xwbing.util.Pagination;
import com.xwbing.util.RSAUtil;
import com.xwbing.util.RestMessage;
import lombok.extern.slf4j.Slf4j;
@@ -24,7 +30,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 项目名称: boot-module-demo
@@ -46,12 +54,26 @@ public class ServiceTest extends BaseTest {
private SysRoleService sysRoleService;
@Resource
private DataDictionaryService dictionaryService;
@Resource
private SysUserLoginInOutMapper loginInOutMapper;
@Test
public void page() {
log.info("分页功能测试");
Map<String, Object> map = new HashMap<>();
map.put("inout", 1);
Page<SysUserLoginInOut> page = PageHelper.startPage(1, 10).doSelectPage(() -> loginInOutMapper.findByInoutType(map));
PageInfo<SysUserLoginInOut> pageInfo = PageHelper.startPage(1, 10).doSelectPageInfo(() -> loginInOutMapper.findByInoutType(map));
Pagination page1 = new Pagination(pageInfo);
Pagination page2 = new Pagination(page);
long count = PageHelper.count(() -> loginInOutMapper.findByInoutType(map));
}
@Transactional("jpaTransactionManager")
@Test
public void jpaTransactionTest() {
log.info("jpa数据源事务回滚");
DataDictionary dictionary=new DataDictionary();
DataDictionary dictionary = new DataDictionary();
dictionary.setDescription("serviceTest");
dictionary.setEnable("Y");
dictionary.setCode("serviceTest");
@@ -4,6 +4,7 @@ import com.xwbing.BaseTest;
import com.xwbing.domain.entity.sys.SysRole;
import com.xwbing.domain.mapper.sys.SysRoleMapper;
import com.xwbing.service.sys.SysRoleService;
import com.xwbing.util.Pagination;
import com.xwbing.util.RestMessage;
import org.junit.Assert;
import org.junit.Test;
@@ -39,7 +40,7 @@ public class SysRoleServiceTest extends BaseTest {
Assert.assertTrue(rest.getMessage(), rest.isSuccess());
Assert.assertNotSame("修改失败", sysRole, sysRoleService.getById(rest.getId()));
//listAllByEnable
Assert.assertNotNull(sysRoleService.listAllByEnable("Y"));
Assert.assertNotNull(sysRoleService.pageByEnable("Y", new Pagination<>()));
//removeById
Assert.assertTrue("删除失败", sysRoleService.removeById(rest.getId()).isSuccess());
//............................