Commit 50541076 authored by Fred's avatar Fred
parents 0fa34796 c630b0d7
...@@ -68,12 +68,14 @@ public class DepartController extends AbstractController{ ...@@ -68,12 +68,14 @@ public class DepartController extends AbstractController{
* @param ids * @param ids
* @return * @return
*/ */
public R deleteDepart(@RequestBody Set<Long> ids) {
Assert.isNull(ids, "删除项不能为空"); @DeleteMapping("/delete")
if(this.userService.userCount(ids)>0) { public R deleteDepart(@RequestBody DepartEntity depart) {
Assert.isNull(depart.getId(), "删除项不能为空");
if(this.userService.userCount(depart.getId())>0) {
return R.error("选中部门下有用户!!"); return R.error("选中部门下有用户!!");
} }
departService.deleteBatch(ids); departService.deleteBatch(depart);
return R.ok(); return R.ok();
} }
......
...@@ -17,8 +17,4 @@ import com.govmade.modules.system.entity.DepartEntity; ...@@ -17,8 +17,4 @@ 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);
} }
...@@ -37,6 +37,4 @@ public interface UserDao extends BaseMapper<UserEntity> { ...@@ -37,6 +37,4 @@ 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);
} }
...@@ -28,7 +28,7 @@ public interface DepartService extends IService<DepartEntity>{ ...@@ -28,7 +28,7 @@ public interface DepartService extends IService<DepartEntity>{
/** /**
* 删除部门 * 删除部门
*/ */
void deleteBatch(Set<Long> ids); void deleteBatch(DepartEntity depart);
/** /**
......
...@@ -43,5 +43,5 @@ public interface UserService extends IService<UserEntity> { ...@@ -43,5 +43,5 @@ public interface UserService extends IService<UserEntity> {
UserEntity queryOne(Map<String, Object> params); UserEntity queryOne(Map<String, Object> params);
Integer userCount(Set<Long> ids); Integer userCount(Long id);
} }
...@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service; ...@@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.govmade.common.utils.Constant;
import com.govmade.common.utils.PageUtils; import com.govmade.common.utils.PageUtils;
import com.govmade.common.utils.Query; import com.govmade.common.utils.Query;
import com.govmade.modules.system.dao.DepartDao; import com.govmade.modules.system.dao.DepartDao;
...@@ -43,8 +44,9 @@ public class DepartServiceImpl extends ServiceImpl<DepartDao,DepartEntity> imple ...@@ -43,8 +44,9 @@ public class DepartServiceImpl extends ServiceImpl<DepartDao,DepartEntity> imple
} }
@Override @Override
public void deleteBatch(Set<Long> ids) { public void deleteBatch(DepartEntity depart) {
this.baseMapper.deleteBatch(ids); depart.setState(Constant.STATE_DELETE);
super.updateById(depart);
} }
@Override @Override
......
...@@ -72,7 +72,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements ...@@ -72,7 +72,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
} }
@Override @Override
public Integer userCount(Set<Long> ids) { public Integer userCount(Long id) {
return this.baseMapper.userCount(ids); return super.selectCount(new EntityWrapper<UserEntity>().eq("dept_id", id));
} }
} }
...@@ -3,11 +3,4 @@ ...@@ -3,11 +3,4 @@
<mapper namespace="com.govmade.modules.system.dao.DepartDao"> <mapper namespace="com.govmade.modules.system.dao.DepartDao">
<!-- 批量删除 -->
<update id="deleteBatch">
UPDATE system_departs SET state =${@com.govmade.common.utils.Constant@STATE_DELETE} WHERE id IN
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</update>
</mapper> </mapper>
\ No newline at end of file
...@@ -10,11 +10,4 @@ ...@@ -10,11 +10,4 @@
#{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