diff --git a/src/main/java/com/govmade/modules/system/controller/ModuleController.java b/src/main/java/com/govmade/modules/system/controller/ModuleController.java new file mode 100644 index 0000000000000000000000000000000000000000..cad4a8ebf0be25b6fb942a73da8324374bc83ed8 --- /dev/null +++ b/src/main/java/com/govmade/modules/system/controller/ModuleController.java @@ -0,0 +1,75 @@ +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(); + } + +} diff --git a/src/main/java/com/govmade/modules/system/dao/ModuleDao.java b/src/main/java/com/govmade/modules/system/dao/ModuleDao.java new file mode 100644 index 0000000000000000000000000000000000000000..384053aad28c49ac5c9836df03d2646352d802dc --- /dev/null +++ b/src/main/java/com/govmade/modules/system/dao/ModuleDao.java @@ -0,0 +1,25 @@ +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); + +} diff --git a/src/main/java/com/govmade/modules/system/entity/ModuleEntity.java b/src/main/java/com/govmade/modules/system/entity/ModuleEntity.java new file mode 100644 index 0000000000000000000000000000000000000000..c1aea79f73fe67242a82b29a3026ffde0e8b0841 --- /dev/null +++ b/src/main/java/com/govmade/modules/system/entity/ModuleEntity.java @@ -0,0 +1,70 @@ +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; + } + + +} diff --git a/src/main/java/com/govmade/modules/system/service/ModuleService.java b/src/main/java/com/govmade/modules/system/service/ModuleService.java new file mode 100644 index 0000000000000000000000000000000000000000..0eb5128160d538a07f5d724a28a8645753442a54 --- /dev/null +++ b/src/main/java/com/govmade/modules/system/service/ModuleService.java @@ -0,0 +1,37 @@ +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); +} diff --git a/src/main/java/com/govmade/modules/system/service/impl/ModuleServiceImpl.java b/src/main/java/com/govmade/modules/system/service/impl/ModuleServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..e177f9d79c62d6af685ac7bf3da0af58bba1cdca --- /dev/null +++ b/src/main/java/com/govmade/modules/system/service/impl/ModuleServiceImpl.java @@ -0,0 +1,54 @@ +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)); + } +} diff --git a/src/main/resources/mapper/system/DepartDao.xml b/src/main/resources/mapper/system/DepartDao.xml new file mode 100644 index 0000000000000000000000000000000000000000..62f588cc096977bd0d3448970fe71422865aeaf7 --- /dev/null +++ b/src/main/resources/mapper/system/DepartDao.xml @@ -0,0 +1,13 @@ +<?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 diff --git a/src/main/resources/mapper/system/ModuleDao.xml b/src/main/resources/mapper/system/ModuleDao.xml new file mode 100644 index 0000000000000000000000000000000000000000..567d2688449420779f8cd85746f0d9ec88404bd3 --- /dev/null +++ b/src/main/resources/mapper/system/ModuleDao.xml @@ -0,0 +1,13 @@ +<?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