|  |  |  | 
|---|
|  |  |  | package doumeemes.service.business.impl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import doumeemes.core.constants.ResponseStatus; | 
|---|
|  |  |  | import doumeemes.core.exception.BusinessException; | 
|---|
|  |  |  | import doumeemes.core.model.ApiResponse; | 
|---|
|  |  |  | import doumeemes.core.model.LoginUserInfo; | 
|---|
|  |  |  | import doumeemes.core.model.PageData; | 
|---|
|  |  |  | 
|---|
|  |  |  | @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 BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"单位名称不能重复"); | 
|---|
|  |  |  | }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()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | QueryWrapper<Unit> wrapper = new QueryWrapper<>(unit); | 
|---|
|  |  |  | return unitMapper.selectList(wrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageData<Unit> findPage(PageWrap<Unit> pageWrap) { | 
|---|
|  |  |  | IPage<Unit> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|