开发工具:IDEA ,Tomcat8.0,数据库:mysql5.7
源码获取:关注文末gongzhonghao,输入017领取下载链接
/**
* FileName: MemberController
*
* Date: 2020/10/4 13:32
* Description: 后台:会员管理控制器
*/
package com.qst.goldenarches.controller;
import com.github.pagehelper.PageHelper;
import com.qst.goldenarches.pojo.Msg;
import com.qst.goldenarches.pojo.Product;
import com.qst.goldenarches.pojo.VIP;
import com.qst.goldenarches.service.MemberService;
import com.qst.goldenarches.utils.OrderByEnumUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/member")
public class MemberController {
@Autowired
private MemberService memberService;
@ResponseBody
@RequestMapping("doEdit")
public Msg doEdit(VIP vip){
try {
memberService.editMemberBalance(vip);
return Msg.success();
}catch (Exception e){
return Msg.fail();
}
}
/**
* 会员后台:分页查找
* 查询全部会员并分页显示
* @param pn 页码
* @return json数据 Msg
*/
@ResponseBody
@RequestMapping("/getAll")
public Msg getAll(@RequestParam(value = "pageno",defaultValue = "1") Integer pn, Integer orderIndex){
Map<String,String> map =new HashMap<String, String>();
map.put("orderText", OrderByEnumUtil.getCondition(orderIndex));
PageHelper.startPage(pn,10);
List<VIP> vips =memberService.getAll(map);
com.github.pagehelper.PageInfo<VIP> vipPageInfo =new com.github.pagehelper.PageInfo<VIP>(vips,5);
return Msg.success().add("pageInfo",vipPageInfo);
}
/***
* 会员后台:跳转方法
* 跳转至会员详情主页面
* @return
*/
@RequestMapping("index")
public String index(){
return "member/index";
}
}
/**
import com.qst.goldenarches.pojo.Permission;
import com.qst.goldenarches.service.PermissionService;
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.ResponseBody;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping(“permission”)
public class PermissionController {
@Autowired
private PermissionService permissionService;
/**
* 为带复选框的树获取数据,
* 并传入角色id,为该角色勾选已分配的许可
* @param roleid
* @return
*/
@ResponseBody
@RequestMapping("/loadAssignData")
public Object loadAssignData( Integer roleid ) {
List permissions = new ArrayList();
List ps = permissionService.getAllPermissions();
// 获取当前角色已经分配的许可信息
List permissionids = permissionService.getPermissionIdsByRoleId(roleid);
Map permissionMap = new HashMap();
//根据角色已经分配的许可信息,判断是否勾选复选框
for (Permission p : ps) {
if ( permissionids.contains(p.getId()) ) {
p.setChecked(true);
} else {
p.setChecked(false);
}
permissionMap.put(p.getId(), p);
}
for ( Permission p : ps ) {
Permission child = p;
if ( child.getPid() == 0 ) {
permissions.add(p);
} else {
Permission parent = permissionMap.get(child.getPid());
parent.getChildren().add(child);
}
}
return permissions;
}
}