更新初始化文件

pull/1/head
759675757@qq.com 2019-10-18 15:45:21 +08:00
parent 913af750bd
commit e7b514e3c5
7 changed files with 102 additions and 4 deletions

View File

@ -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";
}

View File

@ -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");
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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 {
}

View File

@ -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 {
}

View File

@ -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 {
}