|
@@ -98,16 +98,25 @@ public class WXCpDepartUtil {
|
|
|
return depatmentId;
|
|
|
}
|
|
|
|
|
|
- public static Long createOrUpdate(Long parentId, String name) throws WxErrorException {
|
|
|
- Map<String, Long> map = getChildDepartMap(parentId);
|
|
|
- Long depatmentId = map.get(name);
|
|
|
- if (depatmentId == null) {
|
|
|
+ public static Long createOrUpdate(Long id, Long parentId, String name) throws WxErrorException {
|
|
|
+ if(id == null) {
|
|
|
+ Map<String, Long> map = getChildDepartMap(parentId);
|
|
|
+ Long depatmentId = map.get(name);
|
|
|
+ if (depatmentId == null) {
|
|
|
+ WxCpDepart depart = new WxCpDepart();
|
|
|
+ depart.setName(name);
|
|
|
+ depart.setParentId(parentId);
|
|
|
+ depatmentId = departService.create(depart);
|
|
|
+ }
|
|
|
+ return depatmentId;
|
|
|
+ } else {
|
|
|
WxCpDepart depart = new WxCpDepart();
|
|
|
+ depart.setId(id);
|
|
|
depart.setName(name);
|
|
|
depart.setParentId(parentId);
|
|
|
- depatmentId = departService.create(depart);
|
|
|
+ departService.update(depart);
|
|
|
+ return id;
|
|
|
}
|
|
|
- return depatmentId;
|
|
|
}
|
|
|
|
|
|
public static List<WxCpDepart> getAllChildDeparts(Long id) throws WxErrorException {
|