Commit 616496b1 authored by 刘弈臻's avatar 刘弈臻

部门删除修改

parent a427fdaa
......@@ -70,12 +70,12 @@ public class DepartController extends AbstractController{
* @return
*/
@DeleteMapping("/delete")
public R deleteDepart(@RequestBody Set<Long> ids) {
Assert.isNull(ids, "删除项不能为空");
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("选中部门下有用户!!");
}
departService.deleteBatch(ids);
departService.deleteBatch(depart);
return R.ok();
}
......
......@@ -17,8 +17,4 @@ import com.govmade.modules.system.entity.DepartEntity;
@Mapper
public interface DepartDao extends BaseMapper<DepartEntity>{
/**
* 批量删除或删除
*/
void deleteBatch(@Param("ids") Set<Long> ids);
}
......@@ -37,6 +37,4 @@ public interface UserDao extends BaseMapper<UserEntity> {
void deleteBatch(@Param("ids") Set<Long> ids);
Integer userCount(@Param("ids") Set<Long> ids);
}
......@@ -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> {
UserEntity queryOne(Map<String, Object> params);
Integer userCount(Set<Long> ids);
Integer userCount(Long id);
}
......@@ -8,6 +8,7 @@ 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.Constant;
import com.govmade.common.utils.PageUtils;
import com.govmade.common.utils.Query;
import com.govmade.modules.system.dao.DepartDao;
......@@ -43,8 +44,9 @@ public class DepartServiceImpl extends ServiceImpl<DepartDao,DepartEntity> imple
}
@Override
public void deleteBatch(Set<Long> ids) {
this.baseMapper.deleteBatch(ids);
public void deleteBatch(DepartEntity depart) {
depart.setState(Constant.STATE_DELETE);
super.updateById(depart);
}
@Override
......
......@@ -73,7 +73,7 @@ public class UserServiceImpl extends ServiceImpl<UserDao, UserEntity> implements
}
@Override
public Integer userCount(Set<Long> ids) {
return this.baseMapper.userCount(ids);
public Integer userCount(Long id) {
return super.selectCount(new EntityWrapper<UserEntity>().eq("dept_id", id));
}
}
......@@ -3,11 +3,4 @@
<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>
\ No newline at end of file
......@@ -10,11 +10,4 @@
#{id}
</foreach>
</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>
\ 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