Commit 6b52b963 authored by xixinzhao's avatar xixinzhao

增加删除接口

parent 1f958e64
...@@ -12,5 +12,5 @@ public interface IOrganizationUserService { ...@@ -12,5 +12,5 @@ public interface IOrganizationUserService {
IPage<OrganizationUser> getListPage(int pageNumber, int pageSize, Long id); IPage<OrganizationUser> getListPage(int pageNumber, int pageSize, Long id);
int deleteById(Long id);
} }
...@@ -37,5 +37,5 @@ public interface OrganizationService { ...@@ -37,5 +37,5 @@ public interface OrganizationService {
Organization getDetailsById(Long id); Organization getDetailsById(Long id);
boolean deleteById(Long id); int deleteById(Long id);
} }
...@@ -59,4 +59,11 @@ public class OrganizationUserController extends BaseController { ...@@ -59,4 +59,11 @@ public class OrganizationUserController extends BaseController {
@RequestParam(value = "pageSize") int pageSize, @RequestParam() Long id) { @RequestParam(value = "pageSize") int pageSize, @RequestParam() Long id) {
return ResponseHelper.buildResponse(organizationUserService.getListPage(pageNumber, pageSize, id)); return ResponseHelper.buildResponse(organizationUserService.getListPage(pageNumber, pageSize, id));
} }
@GetMapping(value = "/deleteById")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "删除", notes = "根据id删除")
public ResponseModel deleteById(@RequestParam() Long id) {
return ResponseHelper.buildResponse(organizationUserService.deleteById(id));
}
} }
...@@ -14,6 +14,7 @@ import org.springframework.beans.BeanUtils; ...@@ -14,6 +14,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
...@@ -89,6 +90,7 @@ public class OrganizationImpl extends BaseService<Organization,Organization, Org ...@@ -89,6 +90,7 @@ public class OrganizationImpl extends BaseService<Organization,Organization, Org
@Override @Override
public Organization saveOrganization(Organization organization) { public Organization saveOrganization(Organization organization) {
organization.setSort(organizationMapper.selectMaxSort() + 1);
return this.createWithModel(organization); return this.createWithModel(organization);
} }
...@@ -149,7 +151,13 @@ public class OrganizationImpl extends BaseService<Organization,Organization, Org ...@@ -149,7 +151,13 @@ public class OrganizationImpl extends BaseService<Organization,Organization, Org
} }
@Override @Override
public boolean deleteById(Long id) { public int deleteById(Long id) {
return false; LambdaQueryWrapper<OrganizationUser> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(OrganizationUser::getEmergencyTeamId, id);
List<OrganizationUser> organizationUsers = organizationUserMapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(organizationUsers)) {
throw new BadRequest("该应急小组下有成员不可删除!");
}
return this.baseMapper.deleteById(id);
} }
} }
...@@ -41,4 +41,9 @@ public class OrganizationUserImpl extends BaseService<OrganizationUser,Organizat ...@@ -41,4 +41,9 @@ public class OrganizationUserImpl extends BaseService<OrganizationUser,Organizat
wrapper.orderByDesc(BaseEntity::getRecDate); wrapper.orderByDesc(BaseEntity::getRecDate);
return this.baseMapper.selectPage(page, wrapper); return this.baseMapper.selectPage(page, wrapper);
} }
@Override
public int deleteById(Long id) {
return this.baseMapper.deleteById(id);
}
} }
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