更新初始化文件
parent
913af750bd
commit
e7b514e3c5
|
@ -0,0 +1,18 @@
|
|||
package com.songpeng.sparchetype.common;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 基础分页查询参数
|
||||
*
|
||||
* @author SongPeng
|
||||
* @date 2019/9/27 16:05
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class BasePageReq {
|
||||
|
||||
private String orderBy = "last_upd";
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.songpeng.sparchetype.common.Result;
|
|||
import com.songpeng.sparchetype.common.util.HttpServletUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.AuthorizationException;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
@ -29,6 +30,16 @@ public class ExceptionAdvice {
|
|||
return new ModelAndView("error/403");
|
||||
}
|
||||
|
||||
@ExceptionHandler(DuplicateKeyException.class)
|
||||
@ResponseBody
|
||||
public Object handleDuplicateKeyException(DuplicateKeyException e, HttpServletRequest request) {
|
||||
log.error(e.getMessage(), e);
|
||||
if (HttpServletUtils.isAjax(request)) {
|
||||
return Result.failure("数据重复");
|
||||
}
|
||||
return new ModelAndView("error/403");
|
||||
}
|
||||
|
||||
@ExceptionHandler({Exception.class})
|
||||
@ResponseBody
|
||||
public Object handleException(Exception e, HttpServletRequest request) {
|
||||
|
@ -38,4 +49,5 @@ public class ExceptionAdvice {
|
|||
}
|
||||
return new ModelAndView("error/500");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.songpeng.sparchetype.system.controller.admin;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.songpeng.sparchetype.common.BaseController;
|
||||
import com.songpeng.sparchetype.common.Result;
|
||||
import com.songpeng.sparchetype.system.entity.SysRole;
|
||||
import com.songpeng.sparchetype.system.request.SysRolePageReq;
|
||||
import com.songpeng.sparchetype.system.service.ISysRoleService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -38,8 +40,10 @@ public class SysRoleController extends BaseController {
|
|||
|
||||
@PostMapping("/page")
|
||||
@ResponseBody
|
||||
public Result page(Page page) {
|
||||
IPage result = sysRoleService.page(page);
|
||||
public Result page(Page page, SysRolePageReq req) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
qw.orderByDesc(req.getOrderBy());
|
||||
IPage result = sysRoleService.page(page, qw);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.songpeng.sparchetype.system.controller.admin;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.songpeng.sparchetype.common.BaseController;
|
||||
import com.songpeng.sparchetype.common.Result;
|
||||
import com.songpeng.sparchetype.system.entity.SysUser;
|
||||
import com.songpeng.sparchetype.system.request.SysUserPageReq;
|
||||
import com.songpeng.sparchetype.system.service.ISysUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -40,8 +42,10 @@ public class SysUserController extends BaseController {
|
|||
|
||||
@PostMapping("/page")
|
||||
@ResponseBody
|
||||
public Result page(Page page) {
|
||||
IPage result = sysUserService.page(page);
|
||||
public Result page(Page page, SysUserPageReq req) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
qw.orderByDesc(req.getOrderBy());
|
||||
IPage result = sysUserService.page(page, qw);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.songpeng.sparchetype.system.request;
|
||||
|
||||
import com.songpeng.sparchetype.common.BasePageReq;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统用户分页查询参数
|
||||
* </p>
|
||||
*
|
||||
* @author SongPeng
|
||||
* @since 2019-10-15
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SysMenuPageReq extends BasePageReq {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.songpeng.sparchetype.system.request;
|
||||
|
||||
import com.songpeng.sparchetype.common.BasePageReq;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统用户分页查询参数
|
||||
* </p>
|
||||
*
|
||||
* @author SongPeng
|
||||
* @since 2019-10-15
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SysRolePageReq extends BasePageReq {
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.songpeng.sparchetype.system.request;
|
||||
|
||||
import com.songpeng.sparchetype.common.BasePageReq;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 系统用户分页查询参数
|
||||
* </p>
|
||||
*
|
||||
* @author SongPeng
|
||||
* @since 2019-10-15
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class SysUserPageReq extends BasePageReq {
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue