修改添加组织接口。

dev_0531
kevin jiang 6 years ago
parent 9acb88ed69
commit 198454103f

@ -198,6 +198,23 @@ public class StoreStaffController extends BaseController {
}
}
/**
*
* @author dexiang.jiang
* @date 2020/05/20 14:52
*/
@RequestMapping(value = "/region/add",method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> addRegion(@RequestParam("name") String name, @RequestParam("code") String code) {
try {
boolean b = storeEmployeeService.addOrganizationalByRegion(name,code);
return data(b);
} catch (KiisooException e) {
log.error("添加组织", e);
return fail(e.getCode(),e.getMsg());
}
}
/**
*
* @author dexiang.jiang
@ -215,6 +232,23 @@ public class StoreStaffController extends BaseController {
}
}
/**
*
* @author dexiang.jiang
* @date 2020/05/20 14:52
*/
@RequestMapping(value = "/company/add/code",method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> companyAddCode(@RequestParam("name") String name, @RequestParam("code") String code, @RequestParam("parentCode") String parentCode, @RequestParam("level") Long level) {
try {
boolean b = storeEmployeeService.addOrganizationalByCode(name,code, parentCode, level);
return data(b);
} catch (KiisooException e) {
log.error("添加组织", e);
return fail(e.getCode(),e.getMsg());
}
}
/**
*
* @author dexiang.jiang

@ -949,6 +949,108 @@ public class StoreEmployeeService {
return bsdResponse.getSuccess();
}
/**
*
* @param name
* @param code
* @author dexiang.jiang
* @date 2020/05/20 14:57
*/
@Transactional(rollbackFor = Exception.class)
public boolean addOrganizationalByRegion(String name, String code) throws KiisooException {
Map<String, Object> map = new HashMap<>();
map.put("name", name);
map.put("code", code);
map.put("level", 1);
List<PrivilageOrganizational> list = retailCompanyMapper.selectByMap(map);
if(CollectionUtils.isNotEmpty(list) && list.size() > 0){
throw new KiisooException(Constants.MSG_ORGANIZATIONAL_HAS, Constants.CODE_ORGANIZATIONAL_HAS);
}
PrivilageOrganizational entity = new PrivilageOrganizational();
entity.setName(name);
entity.setCode(code);
entity.setParentId(0L);
entity.setLevel(1L);
entity.setStatus(1L);
entity.setType(1L);
entity.setCreateBy(Constants.SYS_OPERATION);
entity.setUpdateBy(Constants.SYS_OPERATION);
entity.setCreateTime(new Date());
entity.setUpdateTime(new Date());
int b = retailCompanyMapper.insert(entity);
return b > 0;
}
/**
*
* @param name
* @param code
* @author dexiang.jiang
* @date 2020/05/20 14:57
*/
@Transactional(rollbackFor = Exception.class)
public boolean addOrganizationalByCode(String name, String code, String parentCode, Long level) throws KiisooException {
Map<String, Object> map = new HashMap<>();
map.put("name", name);
map.put("code", code);
map.put("level", level);
List<PrivilageOrganizational> list = retailCompanyMapper.selectByMap(map);
if(CollectionUtils.isNotEmpty(list) && list.size() > 0){
throw new KiisooException(Constants.MSG_ORGANIZATIONAL_HAS, Constants.CODE_ORGANIZATIONAL_HAS);
}
Map<String, Object> cMap = new HashMap<>();
cMap.put("code", parentCode);
List<PrivilageOrganizational> companyList = retailCompanyMapper.selectByMap(cMap);
if(CollectionUtils.isEmpty(companyList)){
throw new KiisooException(Constants.MSG_ORGANIZATIONAL_HAS, Constants.CODE_ORGANIZATIONAL_HAS);
}
PrivilageOrganizational item = companyList.get(0);
PrivilageOrganizational entity = new PrivilageOrganizational();
entity.setName(name);
entity.setCode(code);
entity.setParentId(item.getId());
entity.setLevel(level);
entity.setStatus(1L);
entity.setType(1L);
entity.setCreateBy(Constants.SYS_OPERATION);
entity.setUpdateBy(Constants.SYS_OPERATION);
entity.setCreateTime(new Date());
entity.setUpdateTime(new Date());
int b = retailCompanyMapper.insert(entity);
if(level == 3){
//添加客户多了2步骤
Map<String, Object> domainEntityMap = new HashMap<>();
domainEntityMap.put("name", name);
List<PrivilageDomainDO> domainList = privilageDomainDOMapper.selectByMap(domainEntityMap);
if(domainList.size() > 1){
throw new KiisooException(Constants.MSG_DOMAIN_ENTITY_HAS, Constants.CODE_DOMAIN_ENTITY_HAS);
}
//添加域
PrivilageDomainDO domainEntity = new PrivilageDomainDO();
domainEntity.setName(name);
domainEntity.setStatus(1);
domainEntity.setCreateTime(new Date());
domainEntity.setUpdateTime(new Date());
domainEntity.setCreateBy(Constants.SYS_OPERATION);
domainEntity.setUpdateBy(Constants.SYS_OPERATION);
int b2 = privilageDomainDOMapper.insert(domainEntity);
//添加域和组织的关系
PrivilageOrganizationalDomain orgDomainEntity = new PrivilageOrganizationalDomain();
orgDomainEntity.setOrgId(entity.getId());
orgDomainEntity.setDomainId(domainEntity.getId());
int b3 = privilageOrganizationalDomainMapper.insert(orgDomainEntity);
return (b + b2 + b3) == 3;
}else{
return b > 0;
}
}
/**
*
* @param name
@ -956,6 +1058,7 @@ public class StoreEmployeeService {
* @author dexiang.jiang
* @date 2020/05/20 14:57
*/
@Transactional(rollbackFor = Exception.class)
public boolean addOrganizational(String name, String code, Long parentId, Long level) throws KiisooException {
Map<String, Object> map = new HashMap<>();
map.put("name", name);
@ -1036,7 +1139,6 @@ public class StoreEmployeeService {
Map<String, Object> domainMap = new HashMap<>();
domainMap.put("name", poiStore.getCustomerName());
domainMap.put("code", poiStore.getCustomerCode());
List<PrivilageDomainDO> domainList = privilageDomainDOMapper.selectByMap(domainMap);
if(CollectionUtils.isEmpty(domainList)){

Loading…
Cancel
Save