Commit bd434b98 authored by Fred's avatar Fred
parents 5746e67f 7b5d1aa8
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.DepartEntity;
import com.govmade.modules.system.service.DepartService;
/**
* 系统管理 - 部门设置
*
* @author 刘弈臻
* @date 2018年8月8日
*/
@RestController
@RequestMapping("/system/depart")
public class DepartController extends AbstractController{
@Autowired
private DepartService departService;
/**
* 部门列表
*/
@GetMapping("/list")
public R list(@RequestParam Map<String, Object> params) {
PageUtils page = departService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 保存或更新部门
*/
@PostMapping("/save")
public R save(DepartEntity depart) {
if (null == depart.getId()) {
if (this.departService.checkDepart(depart.getName()) > 0) {
return R.error(depart.getName() + " 已存在!");
}
}
departService.save(depart);
return R.ok();
}
/**
* 删除或批量删除角色
*/
@DeleteMapping("/delete")
public R deleteDepart(@RequestParam Set<Long> ids) {
departService.deleteBatchIds(ids);
return R.ok();
}
}
...@@ -42,7 +42,7 @@ public class RoleController extends AbstractController{ ...@@ -42,7 +42,7 @@ public class RoleController extends AbstractController{
} }
/** /**
* 保存或更新权限 * 保存或更新角色
*/ */
@PostMapping("/save") @PostMapping("/save")
public R save(RoleEntity role) { public R save(RoleEntity role) {
......
package com.govmade.modules.system.dao;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.govmade.modules.system.entity.DepartEntity;
/**
* 系统管理 - 部门设置
*
* @author 刘弈臻
* @date 2018年8月8日
*/
@Mapper
public interface DepartDao extends BaseMapper<DepartEntity>{
}
package com.govmade.modules.system.entity;
import com.baomidou.mybatisplus.annotations.TableName;
import com.govmade.modules.basic.entity.BaseEntity;
/**
* 系统管理 - 部门设置
*
* @author 刘弈臻
* @date 2018年8月8日
*/
@TableName("system_departs")
public class DepartEntity extends BaseEntity<Long>{
private static final long serialVersionUID = 1L;
private String code; //机构编码
private String name; //部门名称
private Long areaId; //所属行政区划
private Integer type; //机构类别
private Integer level; //层级
private Long weight; //权重
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getAreaId() {
return areaId;
}
public void setAreaId(Long areaId) {
this.areaId = areaId;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public Long getWeight() {
return weight;
}
public void setWeight(Long weight) {
this.weight = weight;
}
}
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.DepartEntity;
/**
* 系统管理 - 部门设置
*
* @author 刘弈臻
* @date 2018年8月8日
*/
public interface DepartService extends IService<DepartEntity>{
/**
* 查看部门列表
*/
PageUtils queryPage(Map<String, Object> params);
/**
* 保存或修改部门
*/
void save(DepartEntity depart);
/**
* 删除部门
*/
void deleteBatch(Long[] roleIds);
/**
* 部门查重
*/
Integer checkDepart(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.DepartDao;
import com.govmade.modules.system.entity.DepartEntity;
import com.govmade.modules.system.service.DepartService;
import cn.hutool.core.util.StrUtil;
/**
* 系统管理 - 部门设置
*
* @author 刘弈臻
* @date 2018年8月8日
*/
@Service("DepartService")
public class DepartServiceImpl extends ServiceImpl<DepartDao,DepartEntity> implements DepartService{
@Override
public PageUtils queryPage(Map<String, Object> params) {
String name = (String) params.get("name");
Page<DepartEntity> page = this.selectPage(new Query<DepartEntity>(params).getPage(),
new EntityWrapper<DepartEntity>()
.like(StrUtil.isNotBlank(name), "name", name));
return new PageUtils(page);
}
@Override
public void save(DepartEntity depart) {
super.insertOrUpdate(depart);
}
@Override
public void deleteBatch(Long[] roleIds) {
// TODO Auto-generated method stub
}
@Override
public Integer checkDepart(String name) {
return super.selectCount(new EntityWrapper<DepartEntity>().eq("name",name));
}
}
...@@ -28,8 +28,9 @@ public class RoleServiceImpl extends ServiceImpl<RoleDao, RoleEntity> implements ...@@ -28,8 +28,9 @@ public class RoleServiceImpl extends ServiceImpl<RoleDao, RoleEntity> implements
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
String name = (String) params.get("name"); String name = (String) params.get("name");
Page<RoleEntity> page = this.selectPage(new Query<RoleEntity>(params).getPage(), new EntityWrapper<RoleEntity>() Page<RoleEntity> page = this.selectPage(new Query<RoleEntity>(params).getPage(),
.eq(StrUtil.isNotBlank(name), "name", name)); new EntityWrapper<RoleEntity>()
.like(StrUtil.isNotBlank(name), "name", name));
return new PageUtils(page); return new PageUtils(page);
} }
......
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