|  |  |  | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public Integer create(Unit unit) { | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | unit.setDeleted(Constants.ZERO); | 
|---|
|  |  |  | unit.setCreateTime(new Date()); | 
|---|
|  |  |  | unit.setCreateUser(user.getId()); | 
|---|
|  |  |  | unit.setRootDepartId(user.getRootDepartment().getId()); | 
|---|
|  |  |  | unit.setStatus(Constants.ONE); | 
|---|
|  |  |  | unit.setType(Constants.ZERO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Unit find=new Unit(); | 
|---|
|  |  |  | find.setRootDepartId(user.getRootDepartment().getId()); | 
|---|
|  |  |  | find.setDeleted(Constants.ZERO); | 
|---|
|  |  |  | find.setName(unit.getName()); | 
|---|
|  |  |  | if( this.count(find)>0){ | 
|---|
|  |  |  | throw new RuntimeException("同一单位类型下名称不能重复"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | unitMapper.insert(unit); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return 1; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | public Integer createOld(Unit unit) { | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  | if(StringUtils.isNotEmpty(unit.getTypes())){ | 
|---|
|  |  |  | String [] str=unit.getTypes().split(","); | 
|---|
|  |  |  | for(String tp:str){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | unit.setDeleted(Constants.ZERO); | 
|---|
|  |  |  | unit.setCreateTime(new Date()); | 
|---|
|  |  |  | unit.setCreateUser(user.getId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public ApiResponse updateById(Unit unit) { | 
|---|
|  |  |  | LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | unit.setUpdateTime(new Date()); | 
|---|
|  |  |  | unit.setUpdateUser(user.getId()); | 
|---|
|  |  |  |  | 
|---|