Commit 6d1e0788 authored by 刘弈臻's avatar 刘弈臻

角色 -刘弈臻

parent c3d0ecb3
boot.validation.initialized=true
eclipse.preferences.version=1
package com.govmade.modules.system.controller;
import java.util.Map;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.govmade.common.utils.PageUtils;
import com.govmade.common.utils.R;
import com.govmade.modules.basic.controller.AbstractController;
import com.govmade.modules.system.entity.RoleEntity;
import com.govmade.modules.system.service.RoleService;
/**
* 系统管理 - 角色设置
*
* @author 刘弈臻
* @date 2018年8月7日
*/
@RestController
@RequestMapping("/system/role")
public class RoleController extends AbstractController{
@Autowired
private RoleService roleService;
/**
* 角色列表
*/
@GetMapping("/list")
public R list(@RequestParam Map<String, Object> params) {
PageUtils page = roleService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 保存或更新权限
*/
@PostMapping("/save")
public R save(RoleEntity role) {
if (null == role.getId()) {
if (this.roleService.checkRole(role.getName()) > 0) {
return R.error(role.getName() + " 已存在!");
}
}
roleService.save(role);
return R.ok();
}
/**
* 删除或批量删除角色
*/
@DeleteMapping("/delete")
public R deleteUser(@RequestParam Set<Long> ids) {
roleService.deleteBatchIds(ids);
return R.ok();
}
}
package com.govmade.modules.system.dao;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.govmade.modules.system.entity.RoleEntity;
/**
* 系统管理 - 角色设置
*
* @author 刘弈臻
* @date 2018年8月7日
*/
@Mapper
public interface RoleDao extends BaseMapper<RoleEntity>{
}
package com.govmade.modules.system.entity;
import com.baomidou.mybatisplus.annotations.TableName;
import com.govmade.modules.basic.entity.BaseEntity;
/**
* 系统管理 - 角色设置
*
* @author 刘弈臻
* @date 2018年8月7日
*/
@TableName("system_roles")
public class RoleEntity extends BaseEntity<Long>{
private static final long serialVersionUID = 1L;
private String name; //角色名称
private String descn; //描述
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescn() {
return descn;
}
public void setDescn(String descn) {
this.descn = descn;
}
}
package com.govmade.modules.system.service;
import java.util.Map;
import com.baomidou.mybatisplus.service.IService;
import com.govmade.common.utils.PageUtils;
import com.govmade.modules.system.entity.RoleEntity;
/**
* 系统管理 - 角色设置
*
* @author 刘弈臻
* @date 2018年8月7日
*/
public interface RoleService extends IService<RoleEntity>{
/**
* 查看角色列表
*/
PageUtils queryPage(Map<String, Object> params);
/**
* 保存或修改角色
*/
void save(RoleEntity role);
/**
* 删除角色
*/
void deleteBatch(Long[] roleIds);
/**
* 角色查重
*/
Integer checkRole(String name);
}
package com.govmade.modules.system.service.impl;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.govmade.common.utils.PageUtils;
import com.govmade.common.utils.Query;
import com.govmade.modules.system.dao.RoleDao;
import com.govmade.modules.system.entity.RoleEntity;
import com.govmade.modules.system.service.RoleService;
import cn.hutool.core.util.StrUtil;
/**
* 系统管理 - 角色设置
*
* @author 刘弈臻
* @date 2018年8月7日
*/
@Service("RoleService")
public class RoleServiceImpl extends ServiceImpl<RoleDao, RoleEntity> implements RoleService{
@Override
public PageUtils queryPage(Map<String, Object> params) {
String name = (String) params.get("name");
Page<RoleEntity> page = this.selectPage(new Query<RoleEntity>(params).getPage(), new EntityWrapper<RoleEntity>()
.eq(StrUtil.isNotBlank(name), "name", name));
return new PageUtils(page);
}
@Override
public void save(RoleEntity role) {
super.insertOrUpdate(role);
}
@Override
public void deleteBatch(Long[] roleIds) {
// TODO Auto-generated method stub
}
@Override
public Integer checkRole(String name) {
return super.selectCount(new EntityWrapper<RoleEntity>().eq("name",name));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment