Commit a427fdaa authored by 刘弈臻's avatar 刘弈臻

删除方法更新

parent 440efa03
...@@ -7,11 +7,13 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -7,11 +7,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.govmade.common.utils.R; import com.govmade.common.utils.R;
import com.govmade.common.validator.Assert;
import com.govmade.modules.basic.controller.AbstractController; import com.govmade.modules.basic.controller.AbstractController;
import com.govmade.modules.system.entity.AreaEntity; import com.govmade.modules.system.entity.AreaEntity;
import com.govmade.modules.system.service.AreaService; import com.govmade.modules.system.service.AreaService;
...@@ -56,15 +58,16 @@ public class AreaController extends AbstractController{ ...@@ -56,15 +58,16 @@ public class AreaController extends AbstractController{
} }
/** /**
* 删除、批量删除区划 * 批量删除区划
* *
* @param ids * @param ids
* @return * @return
*/ */
@DeleteMapping("/delete") @DeleteMapping("/delete")
public R deleteArea(@RequestParam Set<Long> ids) { public R deleteArea(@RequestBody Set<Long> ids) {
Assert.isNull(ids, "删除项不能为空");
areaService.deleteBatchIds(ids); areaService.deleteBatch(ids);
return R.ok(); return R.ok();
} }
......
...@@ -7,15 +7,18 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -7,15 +7,18 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.govmade.common.utils.PageUtils; import com.govmade.common.utils.PageUtils;
import com.govmade.common.utils.R; import com.govmade.common.utils.R;
import com.govmade.common.validator.Assert;
import com.govmade.modules.basic.controller.AbstractController; import com.govmade.modules.basic.controller.AbstractController;
import com.govmade.modules.system.entity.DepartEntity; import com.govmade.modules.system.entity.DepartEntity;
import com.govmade.modules.system.service.DepartService; import com.govmade.modules.system.service.DepartService;
import com.govmade.modules.system.service.UserService;
/** /**
* 系统管理 - 部门设置 * 系统管理 - 部门设置
...@@ -30,6 +33,9 @@ public class DepartController extends AbstractController{ ...@@ -30,6 +33,9 @@ public class DepartController extends AbstractController{
@Autowired @Autowired
private DepartService departService; private DepartService departService;
@Autowired
private UserService userService;
/** /**
* 部门列表 * 部门列表
*/ */
...@@ -58,12 +64,18 @@ public class DepartController extends AbstractController{ ...@@ -58,12 +64,18 @@ public class DepartController extends AbstractController{
/** /**
* 删除或批量删除角色 * 批量删除部门
*
* @param ids
* @return
*/ */
@DeleteMapping("/delete") @DeleteMapping("/delete")
public R deleteDepart(@RequestParam Set<Long> ids) { public R deleteDepart(@RequestBody Set<Long> ids) {
Assert.isNull(ids, "删除项不能为空");
departService.deleteBatchIds(ids); if(this.userService.userCount(ids)>0) {
return R.error("选中部门下有用户!!");
}
departService.deleteBatch(ids);
return R.ok(); return R.ok();
} }
......
...@@ -7,12 +7,14 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -7,12 +7,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.govmade.common.utils.PageUtils; import com.govmade.common.utils.PageUtils;
import com.govmade.common.utils.R; import com.govmade.common.utils.R;
import com.govmade.common.validator.Assert;
import com.govmade.modules.basic.controller.AbstractController; import com.govmade.modules.basic.controller.AbstractController;
import com.govmade.modules.system.entity.RoleEntity; import com.govmade.modules.system.entity.RoleEntity;
import com.govmade.modules.system.service.RoleService; import com.govmade.modules.system.service.RoleService;
...@@ -57,13 +59,18 @@ public class RoleController extends AbstractController{ ...@@ -57,13 +59,18 @@ public class RoleController extends AbstractController{
return R.ok(); return R.ok();
} }
/**
* 删除或批量删除角色 /**
* 批量删除角色
*
* @param ids
* @return
*/ */
@DeleteMapping("/delete") @DeleteMapping("/delete")
public R deleteUser(@RequestParam Set<Long> ids) { public R deleteRole(@RequestBody Set<Long> ids) {
Assert.isNull(ids, "删除项不能为空");
roleService.deleteBatchIds(ids); roleService.deleteBatch(ids);
return R.ok(); return R.ok();
} }
......
package com.govmade.modules.system.dao; package com.govmade.modules.system.dao;
import java.util.Set;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper; import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.govmade.modules.system.entity.AreaEntity; import com.govmade.modules.system.entity.AreaEntity;
...@@ -14,5 +17,8 @@ import com.govmade.modules.system.entity.AreaEntity; ...@@ -14,5 +17,8 @@ import com.govmade.modules.system.entity.AreaEntity;
@Mapper @Mapper
public interface AreaDao extends BaseMapper<AreaEntity> { public interface AreaDao extends BaseMapper<AreaEntity> {
/**
* 批量删除或删除
*/
void deleteBatch(@Param("ids") Set<Long> ids);
} }
package com.govmade.modules.system.dao; package com.govmade.modules.system.dao;
import java.util.Set;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper; import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.govmade.modules.system.entity.DepartEntity; import com.govmade.modules.system.entity.DepartEntity;
...@@ -14,4 +17,8 @@ import com.govmade.modules.system.entity.DepartEntity; ...@@ -14,4 +17,8 @@ import com.govmade.modules.system.entity.DepartEntity;
@Mapper @Mapper
public interface DepartDao extends BaseMapper<DepartEntity>{ public interface DepartDao extends BaseMapper<DepartEntity>{
/**
* 批量删除或删除
*/
void deleteBatch(@Param("ids") Set<Long> ids);
} }
package com.govmade.modules.system.dao; package com.govmade.modules.system.dao;
import java.util.Set;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.mapper.BaseMapper; import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.govmade.modules.system.entity.RoleEntity; import com.govmade.modules.system.entity.RoleEntity;
...@@ -14,5 +17,8 @@ import com.govmade.modules.system.entity.RoleEntity; ...@@ -14,5 +17,8 @@ import com.govmade.modules.system.entity.RoleEntity;
@Mapper @Mapper
public interface RoleDao extends BaseMapper<RoleEntity>{ public interface RoleDao extends BaseMapper<RoleEntity>{
/**
* 批量删除或删除
*/
void deleteBatch(@Param("ids") Set<Long> ids);
} }
...@@ -37,4 +37,6 @@ public interface UserDao extends BaseMapper<UserEntity> { ...@@ -37,4 +37,6 @@ public interface UserDao extends BaseMapper<UserEntity> {
void deleteBatch(@Param("ids") Set<Long> ids); void deleteBatch(@Param("ids") Set<Long> ids);
Integer userCount(@Param("ids") Set<Long> ids);
} }
package com.govmade.modules.system.service; package com.govmade.modules.system.service;
import java.util.List; import java.util.List;
import java.util.Set;
import com.baomidou.mybatisplus.service.IService; import com.baomidou.mybatisplus.service.IService;
import com.govmade.modules.system.entity.AreaEntity; import com.govmade.modules.system.entity.AreaEntity;
...@@ -26,7 +27,7 @@ public interface AreaService extends IService<AreaEntity>{ ...@@ -26,7 +27,7 @@ public interface AreaService extends IService<AreaEntity>{
/** /**
* 删除行政区划 * 删除行政区划
*/ */
void deleteBatch(Long[] areaIds); void deleteBatch(Set<Long> ids);
/** /**
......
package com.govmade.modules.system.service; package com.govmade.modules.system.service;
import java.util.Map; import java.util.Map;
import java.util.Set;
import com.baomidou.mybatisplus.service.IService; import com.baomidou.mybatisplus.service.IService;
import com.govmade.common.utils.PageUtils; import com.govmade.common.utils.PageUtils;
...@@ -27,7 +28,7 @@ public interface DepartService extends IService<DepartEntity>{ ...@@ -27,7 +28,7 @@ public interface DepartService extends IService<DepartEntity>{
/** /**
* 删除部门 * 删除部门
*/ */
void deleteBatch(Long[] roleIds); void deleteBatch(Set<Long> ids);
/** /**
......
package com.govmade.modules.system.service; package com.govmade.modules.system.service;
import java.util.Map; import java.util.Map;
import java.util.Set;
import com.baomidou.mybatisplus.service.IService; import com.baomidou.mybatisplus.service.IService;
import com.govmade.common.utils.PageUtils; import com.govmade.common.utils.PageUtils;
...@@ -26,9 +27,9 @@ public interface RoleService extends IService<RoleEntity>{ ...@@ -26,9 +27,9 @@ public interface RoleService extends IService<RoleEntity>{
void save(RoleEntity role); void save(RoleEntity role);
/** /**
* 删除角色 * 删除或批量删除角色
*/ */
void deleteBatch(Long[] roleIds); void deleteBatch(Set<Long> ids);
/** /**
* 角色查重 * 角色查重
......
...@@ -42,4 +42,6 @@ public interface UserService extends IService<UserEntity> { ...@@ -42,4 +42,6 @@ public interface UserService extends IService<UserEntity> {
Integer checkUser(String username); Integer checkUser(String username);
UserEntity queryOne(Map<String, Object> params); UserEntity queryOne(Map<String, Object> params);
Integer userCount(Set<Long> ids);
} }
package com.govmade.modules.system.service.impl; package com.govmade.modules.system.service.impl;
import java.util.List; import java.util.List;
import java.util.Set;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -53,8 +54,8 @@ public class AreaServiceImpl extends ServiceImpl<AreaDao,AreaEntity> implements ...@@ -53,8 +54,8 @@ public class AreaServiceImpl extends ServiceImpl<AreaDao,AreaEntity> implements
} }
@Override @Override
public void deleteBatch(Long[] areaIds) { public void deleteBatch(Set<Long> ids) {
// TODO Auto-generated method stub this.baseMapper.deleteBatch(ids);
} }
@Override @Override
......
package com.govmade.modules.system.service.impl; package com.govmade.modules.system.service.impl;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -42,8 +43,8 @@ public class DepartServiceImpl extends ServiceImpl<DepartDao,DepartEntity> imple ...@@ -42,8 +43,8 @@ public class DepartServiceImpl extends ServiceImpl<DepartDao,DepartEntity> imple
} }
@Override @Override
public void deleteBatch(Long[] roleIds) { public void deleteBatch(Set<Long> ids) {
// TODO Auto-generated method stub this.baseMapper.deleteBatch(ids);
} }
@Override @Override
......
package com.govmade.modules.system.service.impl; package com.govmade.modules.system.service.impl;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -40,8 +41,8 @@ public class RoleServiceImpl extends ServiceImpl<RoleDao, RoleEntity> implements ...@@ -40,8 +41,8 @@ public class RoleServiceImpl extends ServiceImpl<RoleDao, RoleEntity> implements
} }
@Override @Override
public void deleteBatch(Long[] roleIds) { public void deleteBatch(Set<Long> ids) {
// TODO Auto-generated method stub this.baseMapper.deleteBatch(ids);
} }
@Override @Override
......
...@@ -71,4 +71,9 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements ...@@ -71,4 +71,9 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
return (UserEntity) this return (UserEntity) this
.selectOne(new EntityWrapper<UserEntity>().eq(StrUtil.isNotBlank(username), "username", username)); .selectOne(new EntityWrapper<UserEntity>().eq(StrUtil.isNotBlank(username), "username", username));
} }
@Override
public Integer userCount(Set<Long> ids) {
return this.baseMapper.userCount(ids);
}
} }
<?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.AreaDao">
<!-- 批量删除 -->
<update id="deleteBatch">
UPDATE system_areas SET state =${@com.govmade.common.utils.Constant@STATE_DELETE} WHERE id IN
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</update>
</mapper>
\ No newline at end of file
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<!-- 批量删除 --> <!-- 批量删除 -->
<update id="deleteBatch"> <update id="deleteBatch">
UPDATE system_departs SET state =${@com.govmade.common.utils.Constant@STATE_NORMAL} WHERE id IN UPDATE system_departs SET state =${@com.govmade.common.utils.Constant@STATE_DELETE} WHERE id IN
<foreach collection="ids" item="id" open="(" close=")" separator=","> <foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
......
<?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.RoleDao">
<!-- 批量删除 -->
<update id="deleteBatch">
UPDATE system_roles SET state =${@com.govmade.common.utils.Constant@STATE_DELETE} WHERE id IN
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</update>
</mapper>
...@@ -5,9 +5,16 @@ ...@@ -5,9 +5,16 @@
<!-- 批量删除 --> <!-- 批量删除 -->
<update id="deleteBatch"> <update id="deleteBatch">
UPDATE system_users SET state =${@com.govmade.common.utils.Constant@STATE_NORMAL} WHERE id IN UPDATE system_users SET state =${@com.govmade.common.utils.Constant@STATE_DELETE} WHERE id IN
<foreach collection="ids" item="id" open="(" close=")" separator=","> <foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
</update> </update>
<select id="userCount" resultType="Integer">
SELECT COUNT(*) FROM system_users WHERE state =${@com.govmade.common.utils.Constant@STATE_NORMAL} AND dept_id IN
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</select>
</mapper> </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