Commit 440efa03 authored by 刘弈臻's avatar 刘弈臻

模块-刘弈臻

parent ab02fb41
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.RequestBody;
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.common.validator.Assert;
import com.govmade.modules.basic.controller.AbstractController;
import com.govmade.modules.system.entity.ModuleEntity;
import com.govmade.modules.system.service.ModuleService;
/**
* 系统管理 - 模块设置
*
* @author 刘弈臻
* @date 2018年8月9日
*/
@RestController
@RequestMapping("/system/module")
public class ModuleController extends AbstractController{
@Autowired
private ModuleService moduleService;
/**
* 模块列表
*/
@GetMapping("/list")
public R list(@RequestParam Map<String, Object> params) {
PageUtils page = moduleService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 保存或更新模块
*/
@PostMapping("/save")
public R save(ModuleEntity module) {
if (null == module.getId()) {
if (this.moduleService.checkModule(module.getName()) > 0) {
return R.error(module.getName() + " 已存在!");
}
}
moduleService.save(module);
return R.ok();
}
/**
* 批量删除模块
*
* @param ids
* @return
*/
@DeleteMapping("/delete")
public R deleteModule(@RequestBody Set<Long> ids) {
Assert.isNull(ids, "删除项不能为空");
moduleService.deleteBatch(ids);
return R.ok();
}
}
package com.govmade.modules.system.dao;
import java.util.Set;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.govmade.modules.system.entity.ModuleEntity;
/**
* 系统管理 - 模块设置
*
* @author 刘弈臻
* @date 2018年8月9日
*/
@Mapper
public interface ModuleDao extends BaseMapper<ModuleEntity>{
/**
* 删除或批量删除
*/
void deleteBatch(@Param("ids") Set<Long> ids);
}
package com.govmade.modules.system.entity;
import com.baomidou.mybatisplus.annotations.TableName;
import com.govmade.modules.basic.entity.BaseEntity;
/**
* 系统管理 - 模块设置
*
* @author 刘弈臻
* @date 2018年8月9日
*/
@TableName("system_modules")
public class ModuleEntity extends BaseEntity<Long>{
private static final long serialVersionUID = 1L;
private String name; //模块名称
private String path; //模块路径
private String icon; //图标
private Integer isShow; //是否显示
private Long weight; //权重
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public Integer getIsShow() {
return isShow;
}
public void setIsShow(Integer isShow) {
this.isShow = isShow;
}
public Long getWeight() {
return weight;
}
public void setWeight(Long weight) {
this.weight = weight;
}
}
package com.govmade.modules.system.service;
import java.util.Map;
import java.util.Set;
import com.baomidou.mybatisplus.service.IService;
import com.govmade.common.utils.PageUtils;
import com.govmade.modules.system.entity.ModuleEntity;
/**
* 系统管理 - 模块设置
*
* @author 刘弈臻
* @date 2018年8月9日
*/
public interface ModuleService extends IService<ModuleEntity>{
/**
* 分页查询模块
*/
PageUtils queryPage(Map<String, Object> params);
/**
* 保存或修改模块
*/
void save(ModuleEntity module);
/**
* 删除模块
*/
void deleteBatch(Set<Long> ids);
/**
*模块查重
*/
Integer checkModule(String name);
}
package com.govmade.modules.system.service.impl;
import java.util.Map;
import java.util.Set;
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.ModuleDao;
import com.govmade.modules.system.entity.ModuleEntity;
import com.govmade.modules.system.service.ModuleService;
import cn.hutool.core.util.StrUtil;
/**
* 系统管理 - 模块设置
*
* @author 刘弈臻
* @date 2018年8月9日
*/
@Service("ModuleService")
public class ModuleServiceImpl extends ServiceImpl<ModuleDao, ModuleEntity> implements ModuleService{
@Override
public PageUtils queryPage(Map<String, Object> params) {
String name = (String) params.get("name");
Page<ModuleEntity> page = this.selectPage(new Query<ModuleEntity>(params).getPage(),
new EntityWrapper<ModuleEntity>()
.like(StrUtil.isNotBlank(name), "name", name));
return new PageUtils(page);
}
@Override
public void save(ModuleEntity module) {
super.insertOrUpdate(module);
}
@Override
public void deleteBatch(Set<Long> ids) {
this.baseMapper.deleteBatch(ids);
}
@Override
public Integer checkModule(String name) {
return super.selectCount(new EntityWrapper<ModuleEntity>().eq("name", name));
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.govmade.modules.system.dao.DepartDao">
<!-- 批量删除 -->
<update id="deleteBatch">
UPDATE system_departs SET state =${@com.govmade.common.utils.Constant@STATE_NORMAL} WHERE id IN
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.govmade.modules.system.dao.ModuleDao">
<!-- 批量删除 -->
<update id="deleteBatch">
UPDATE system_modules SET state =${@com.govmade.common.utils.Constant@STATE_NORMAL} WHERE id IN
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</update>
</mapper>
\ No newline at end of file
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