ModelMap相关代码优化

This commit is contained in:
mazhicheng 2019-07-20 13:42:29 +08:00
parent 061298f334
commit 8d76fe8963
6 changed files with 13 additions and 20 deletions

View File

@ -51,7 +51,7 @@ public class MessageController extends BaseCrudRestController {
* @throws Exception
*/
@GetMapping("/{id}")
public JsonResult getModel(@PathVariable("id")Long id, HttpServletRequest request, ModelMap modelMap)
public JsonResult getModel(@PathVariable("id")Long id, HttpServletRequest request)
throws Exception{
MessageVO entityVO = messageService.getViewObject(id, MessageVO.class);
return new JsonResult(entityVO);

View File

@ -47,7 +47,7 @@ public class MessageTemplateController extends BaseCrudRestController {
* @throws Exception
*/
@GetMapping("/{id}")
public JsonResult getModel(@PathVariable("id")Long id, HttpServletRequest request, ModelMap modelMap)
public JsonResult getModel(@PathVariable("id")Long id, HttpServletRequest request)
throws Exception{
MessageTemplate entity = messageTemplateService.getEntity(id);
return new JsonResult(entity);
@ -72,7 +72,7 @@ public class MessageTemplateController extends BaseCrudRestController {
*/
@PutMapping("/{id}")
public JsonResult updateModel(@PathVariable("id")Long id, @ModelAttribute MessageTemplate entity, BindingResult result,
HttpServletRequest request, ModelMap modelMap) throws Exception{
HttpServletRequest request) throws Exception{
return super.updateEntity(entity, result);
}

View File

@ -110,7 +110,7 @@ public class DepartmentController extends BaseCrudRestController {
* @throws Exception
*/
@GetMapping("/{id}")
public JsonResult getModel(@PathVariable("id")Long id, HttpServletRequest request, ModelMap modelMap)
public JsonResult getModel(@PathVariable("id")Long id, HttpServletRequest request)
throws Exception{
DepartmentVO vo = departmentService.getViewObject(id, DepartmentVO.class);
return new JsonResult(vo);

View File

@ -71,7 +71,7 @@ public class SysUserController extends BaseCrudRestController {
* @throws Exception
*/
@PostMapping("/")
public JsonResult createEntity(@RequestBody SysUser entity, BindingResult result, HttpServletRequest request, ModelMap modelMap)
public JsonResult createEntity(@RequestBody SysUser entity, BindingResult result, HttpServletRequest request)
throws Exception{
boolean success = sysUserService.createSysUser(entity);
if(success){
@ -90,15 +90,11 @@ public class SysUserController extends BaseCrudRestController {
*/
@PutMapping("/{id}")
public JsonResult updateModel(@PathVariable("id")Long id, @RequestBody SysUser entity, BindingResult result,
HttpServletRequest request, ModelMap modelMap) throws Exception{
HttpServletRequest request) throws Exception{
// Model属性值验证结果
if(result.hasErrors()) {
return new JsonResult(Status.FAIL_INVALID_PARAM, super.getBindingError(result));
}
if(modelMap.get(ERROR) != null){
return new JsonResult(Status.FAIL_VALIDATION, (String) modelMap.get(ERROR));
}
entity.setId(id);
boolean success = sysUserService.updateSysUser(entity);
if(success){
@ -115,7 +111,7 @@ public class SysUserController extends BaseCrudRestController {
* @throws Exception
*/
@GetMapping("/{id}")
public JsonResult getModel(@PathVariable("id")Long id, HttpServletRequest request, ModelMap modelMap)
public JsonResult getModel(@PathVariable("id")Long id, HttpServletRequest request)
throws Exception{
SysUserVO sysUserVO = sysUserService.getSysUser(id);
return new JsonResult(sysUserVO);

View File

@ -47,7 +47,7 @@ public class PermissionController extends BaseCrudRestController {
*/
@GetMapping("/{id}")
@AuthorizationWrapper(value = @RequiresPermissions("get"), name = "查看")
public JsonResult getModel(@PathVariable("id")Long id, HttpServletRequest request, ModelMap modelMap)
public JsonResult getModel(@PathVariable("id")Long id, HttpServletRequest request)
throws Exception{
PermissionVO vo = permissionService.getViewObject(id, PermissionVO.class);
return new JsonResult(vo);

View File

@ -71,7 +71,7 @@ public class RoleController extends BaseCrudRestController {
* @throws Exception
*/
@PostMapping("/")
public JsonResult createEntity(@RequestBody Role entity, BindingResult result, HttpServletRequest request, ModelMap modelMap)
public JsonResult createEntity(@RequestBody Role entity, BindingResult result, HttpServletRequest request)
throws Exception{
// 创建
boolean success = roleService.createRole(entity);
@ -88,7 +88,7 @@ public class RoleController extends BaseCrudRestController {
* @throws Exception
*/
@GetMapping("/toUpdatePage/{id}")
public JsonResult toUpdatePage(@PathVariable("id")Long id, HttpServletRequest request, ModelMap modelMap)
public JsonResult toUpdatePage(@PathVariable("id")Long id, HttpServletRequest request)
throws Exception{
RoleVO roleVO = roleService.toUpdatePage(id);
return new JsonResult(roleVO);
@ -103,14 +103,11 @@ public class RoleController extends BaseCrudRestController {
*/
@PutMapping("/{id}")
public JsonResult updateModel(@PathVariable("id")Long id, @RequestBody Role entity, BindingResult result,
HttpServletRequest request, ModelMap modelMap) throws Exception{
HttpServletRequest request) throws Exception{
// Model属性值验证结果
if(result.hasErrors()) {
return new JsonResult(Status.FAIL_INVALID_PARAM, super.getBindingError(result));
}
if(modelMap.get(ERROR) != null){
return new JsonResult(Status.FAIL_VALIDATION, (String) modelMap.get(ERROR));
}
entity.setId(id);
boolean success = roleService.updateRole(entity);
@ -129,7 +126,7 @@ public class RoleController extends BaseCrudRestController {
* @throws Exception
*/
@GetMapping("/{id}")
public JsonResult getModel(@PathVariable("id")Long id, HttpServletRequest request, ModelMap modelMap)
public JsonResult getModel(@PathVariable("id")Long id, HttpServletRequest request)
throws Exception{
RoleVO roleVO = roleService.getRole(id);
return new JsonResult(roleVO);
@ -157,7 +154,7 @@ public class RoleController extends BaseCrudRestController {
* @throws Exception
*/
@GetMapping("/getAllMenu")
public JsonResult getAllMenu(HttpServletRequest request, ModelMap modelMap)
public JsonResult getAllMenu(HttpServletRequest request)
throws Exception{
List<Permission> list = roleService.getAllMenu();
return new JsonResult(list);