根据id删除成员数据和成员数据
impl
public int delete(Integer id) { propertyOwnerMapper.deleteByPid(id); return propertyOwnerMapper.delete(id); }
mapper
int deleteByPid(Integer id);
xml
<delete id="deleteByPid"> delete from property_owner where pid = #{id} </delete>
如果业主下有成员的话就不让他删除,没有成员的业主可以直接删除
controller
@PreAuthorize("@ss.hasPermi('owner:owner:remove')") @GetMapping("delete") public AjaxResult delete(Integer id) { String msg = propertyOwnerService.delete(id); return success(msg); }
service
String delete(Integer id);
impl
@Override public String delete(Integer id) { if (propertyOwnerMapper.selectCountByPid(id)>0){ return "该业主有子成员,不能删除!"; }else { propertyOwnerMapper.deleteByPid(id); propertyOwnerMapper.delete(id); } return "删除成功!"; }
mapper
int selectCountByPid(Integer id);
xml
<select id="selectCountByPid" resultType="java.lang.Integer"> select count(0) from property_owner where pid = #{id} </select>
前端需要吧ms改成后端返回的msg
this.$modal.msgSuccess(response.msg);