Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
lanxinghua committed Oct 25, 2019
1 parent c60a572 commit c48eb24
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.mall.controller;

import com.mall.common.share.result.CommonResult;
import com.mall.model.UmsMemberLevel;
import com.mall.service.UmsMemberLevelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
* 会员等级管理Controller
*/
@Controller
@Api(tags = "UmsMemberLevelController", description = "会员等级管理")
@RequestMapping("/memberLevel")
public class UmsMemberLevelController {
@Autowired
private UmsMemberLevelService memberLevelService;

@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation("查询所有会员等级")
@ResponseBody
public CommonResult<List<UmsMemberLevel>> list(@RequestParam("defaultStatus") Integer defaultStatus) {
List<UmsMemberLevel> memberLevelList = memberLevelService.list(defaultStatus);
return CommonResult.success(memberLevelList);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.mall.controller;

import com.mall.common.share.result.CommonResult;
import com.mall.dto.UmsPermissionNode;
import com.mall.model.UmsPermission;
import com.mall.service.UmsPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 后台用户权限管理
*/
@Controller
@Api(tags = "UmsPermissionController", description = "后台用户权限管理")
@RequestMapping("/permission")
public class UmsPermissionController {
@Autowired
private UmsPermissionService permissionService;
@ApiOperation("添加权限")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody UmsPermission permission) {
int count = permissionService.create(permission);
if(count>0){
return CommonResult.success(count);
}
return CommonResult.failed();
}

@ApiOperation("修改权限")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long id, @RequestBody UmsPermission permission) {
int count = permissionService.update(id,permission);
if(count>0){
return CommonResult.success(count);
}
return CommonResult.failed();
}

@ApiOperation("根据id批量删除权限")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("ids") List<Long> ids) {
int count = permissionService.delete(ids);
if(count>0){
return CommonResult.success(count);
}
return CommonResult.failed();
}

@ApiOperation("以层级结构返回所有权限")
@RequestMapping(value = "/treeList", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<UmsPermissionNode>> treeList() {
List<UmsPermissionNode> permissionNodeList = permissionService.treeList();
return CommonResult.success(permissionNodeList);
}

@ApiOperation("获取所有权限列表")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<UmsPermission>> list() {
List<UmsPermission> permissionList = permissionService.list();
return CommonResult.success(permissionList);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.mall.controller;

import com.mall.common.share.result.CommonResult;
import com.mall.model.UmsPermission;
import com.mall.model.UmsRole;
import com.mall.service.UmsRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 后台用户角色管理
*/
@Controller
@Api(tags = "UmsRoleController", description = "后台用户角色管理")
@RequestMapping("/role")
public class UmsRoleController {
@Autowired
private UmsRoleService roleService;

@ApiOperation("添加角色")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody UmsRole role) {
int count = roleService.create(role);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}

@ApiOperation("修改角色")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long id, @RequestBody UmsRole role) {
int count = roleService.update(id, role);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}

@ApiOperation("批量删除角色")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("ids") List<Long> ids) {
int count = roleService.delete(ids);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}

@ApiOperation("获取相应角色权限")
@RequestMapping(value = "/permission/{roleId}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<UmsPermission>> getPermissionList(@PathVariable Long roleId) {
List<UmsPermission> permissionList = roleService.getPermissionList(roleId);
return CommonResult.success(permissionList);
}

@ApiOperation("修改角色权限")
@RequestMapping(value = "/permission/update", method = RequestMethod.POST)
@ResponseBody
public CommonResult updatePermission(@RequestParam Long roleId,
@RequestParam("permissionIds") List<Long> permissionIds) {
int count = roleService.updatePermission(roleId, permissionIds);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}

@ApiOperation("获取所有角色")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public Object list() {
List<UmsRole> roleList = roleService.list();
return CommonResult.success(roleList);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class CommonPage<T> implements Serializable {
private Integer pageNum;
private Integer pageSize;
private Integer totalPage;
private Long totalSize;
private List<T> datas;
private Long total;
private List<T> list;


/**
Expand All @@ -27,8 +27,8 @@ public static <T> CommonPage<T> restPage(List<T> list) {
result.setTotalPage(pageInfo.getPages());
result.setPageNum(pageInfo.getPageNum());
result.setPageSize(pageInfo.getPageSize());
result.setTotalSize(pageInfo.getTotal());
result.setDatas(pageInfo.getList());
result.setTotal(pageInfo.getTotal());
result.setList(pageInfo.getList());
return result;
}

Expand Down Expand Up @@ -56,19 +56,19 @@ public void setTotalPage(Integer totalPage) {
this.totalPage = totalPage;
}

public Long getTotalSize() {
return totalSize;
public Long getTotal() {
return total;
}

public void setTotalSize(Long totalSize) {
this.totalSize = totalSize;
public void setTotal(Long total) {
this.total = total;
}

public List<T> getDatas() {
return datas;
public List<T> getList() {
return list;
}

public void setDatas(List<T> datas) {
this.datas = datas;
public void setList(List<T> list) {
this.list = list;
}
}

0 comments on commit c48eb24

Please sign in to comment.