|
|
@@ -10,11 +10,14 @@ import com.ydtech.core.page.PageResult;
|
|
|
import com.ydtech.exception.SystemException;
|
|
|
import com.ydtech.modules.admin.dao.SysDeptMapper;
|
|
|
import com.ydtech.modules.admin.model.SysDept;
|
|
|
+import com.ydtech.modules.admin.model.vo.SysDeptVo;
|
|
|
import com.ydtech.modules.admin.model.vo.TreeSysDeptVO;
|
|
|
import com.ydtech.modules.admin.service.SysDeptService;
|
|
|
import com.ydtech.modules.protocol.utils.AssertionUtils;
|
|
|
import com.ydtech.utils.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
@@ -40,13 +43,37 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void addDept(SysDept sysDept) {
|
|
|
+ public void addDept(SysDeptVo sysDeptVo) {
|
|
|
+ SysDept sysDept = new SysDept();
|
|
|
+ BeanUtils.copyProperties(sysDeptVo, sysDept);
|
|
|
+ String comlevel = sysDept.getComlevel();
|
|
|
+ String parentId = sysDept.getParentId();
|
|
|
+
|
|
|
+ String number = "9";
|
|
|
+ if (comlevel.equals("2")) {
|
|
|
+ AssertionUtils.isStringEmpty(sysDept.getProvince(), "二级机构份必填");
|
|
|
+ number = sysDept.getProvince();
|
|
|
+ } else if (comlevel.equals("3")) {
|
|
|
+ AssertionUtils.isStringEmpty(sysDept.getCity(), "三级机构市必填");
|
|
|
+ number = sysDept.getCity();
|
|
|
+ } else if (comlevel.equals("4")) {
|
|
|
+ AssertionUtils.isStringEmpty(sysDept.getArea(), "四级机构区必填");
|
|
|
+ number = sysDept.getArea();
|
|
|
+ }
|
|
|
+
|
|
|
+ String substring = number.substring(number.length() - 2);
|
|
|
+ String serialNumber = parentId + substring;
|
|
|
+ sysDept.setId(serialNumber);
|
|
|
+
|
|
|
SysDept dept = getById(sysDept.getId());
|
|
|
- AssertionUtils.isEmpty(dept, "机构编号为:" + dept.getId() + " " + dept.getName() + "已被占用");
|
|
|
+ if (!ObjectUtils.isEmpty(dept)) {
|
|
|
+ throw new SystemException("机构编号为:" + dept.getId() + " " + dept.getName() + "已被占用");
|
|
|
+ }
|
|
|
boolean b = save(sysDept);
|
|
|
AssertionUtils.isSucceed(b, "删除失败");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
public void deleteDept(String deptId) {
|
|
|
SysDept sysDept = getById(deptId);
|
|
|
@@ -60,7 +87,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageResult findSubDepts(PageRequest pageRequest) {
|
|
|
+ public PageResult<SysDept> findSubDepts(PageRequest pageRequest) {
|
|
|
String id = pageRequest.getColumnFilterValue(pageRequest, "id");
|
|
|
|
|
|
Page<SysDept> p = PageRequest.buildPageRequest(pageRequest);
|
|
|
@@ -68,8 +95,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
|
|
|
lqw.eq(StringUtils.isNotEmpty(id), SysDept::getParentId, id);
|
|
|
IPage<SysDept> pResult = page(p, lqw);
|
|
|
//传入查询条件
|
|
|
- PageResult pageResult = PageResult.buildPageResult(pResult);
|
|
|
- return pageResult;
|
|
|
+ return PageResult.buildPageResult(pResult);
|
|
|
|
|
|
}
|
|
|
|