| package doumeemes.service.business.impl; | 
|   | 
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
| import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
| import com.baomidou.mybatisplus.core.metadata.IPage; | 
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
| import com.github.pagehelper.PageHelper; | 
| import com.github.pagehelper.PageInfo; | 
| import doumeemes.core.constants.ResponseStatus; | 
| import doumeemes.core.exception.BusinessException; | 
| import doumeemes.core.model.LoginUserInfo; | 
| import doumeemes.core.model.PageData; | 
| import doumeemes.core.model.PageWrap; | 
| import doumeemes.core.utils.Constants; | 
| import doumeemes.core.utils.Utils; | 
| import doumeemes.dao.business.ApplianceChangeDetialMapper; | 
| import doumeemes.dao.business.model.ApplianceChangeDetial; | 
| import doumeemes.dao.ext.dto.QueryApplianceChangeDetailExtDTO; | 
| import doumeemes.dao.ext.vo.ApplianceChangeDetailExtListVO; | 
| import doumeemes.service.business.ApplianceChangeDetialService; | 
| import org.apache.shiro.SecurityUtils; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.stereotype.Service; | 
| import org.springframework.util.CollectionUtils; | 
|   | 
| import java.util.List; | 
|   | 
| /** | 
|  * 设置类-工装器具更换明细表Service实现 | 
|  * @author 江蹄蹄 | 
|  * @date 2022/07/19 14:29 | 
|  */ | 
| @Service | 
| public class ApplianceChangeDetialServiceImpl implements ApplianceChangeDetialService { | 
|   | 
|     @Autowired | 
|     private ApplianceChangeDetialMapper applianceChangeDetialMapper; | 
|   | 
|     @Override | 
|     public Integer create(ApplianceChangeDetial applianceChangeDetial) { | 
|         applianceChangeDetialMapper.insert(applianceChangeDetial); | 
|         return applianceChangeDetial.getId(); | 
|     } | 
|   | 
|     @Override | 
|     public void deleteById(Integer id) { | 
|         applianceChangeDetialMapper.deleteById(id); | 
|     } | 
|   | 
|     @Override | 
|     public void delete(ApplianceChangeDetial applianceChangeDetial) { | 
|         UpdateWrapper<ApplianceChangeDetial> deleteWrapper = new UpdateWrapper<>(applianceChangeDetial); | 
|         applianceChangeDetialMapper.delete(deleteWrapper); | 
|     } | 
|   | 
|     @Override | 
|     public void deleteByIdInBatch(List<Integer> ids) { | 
|         if (CollectionUtils.isEmpty(ids)) { | 
|             return; | 
|         } | 
|         applianceChangeDetialMapper.deleteBatchIds(ids); | 
|     } | 
|   | 
|     @Override | 
|     public void updateById(ApplianceChangeDetial applianceChangeDetial) { | 
|         applianceChangeDetialMapper.updateById(applianceChangeDetial); | 
|     } | 
|   | 
|     @Override | 
|     public void updateBycondition(ApplianceChangeDetial applianceChangeDetial) { | 
|         applianceChangeDetialMapper.updateById(applianceChangeDetial); | 
|     } | 
|   | 
|     @Override | 
|     public void updateByIdInBatch(List<ApplianceChangeDetial> applianceChangeDetials) { | 
|         if (CollectionUtils.isEmpty(applianceChangeDetials)) { | 
|             return; | 
|         } | 
|         for (ApplianceChangeDetial applianceChangeDetial: applianceChangeDetials) { | 
|             this.updateById(applianceChangeDetial); | 
|         } | 
|     } | 
|   | 
|     @Override | 
|     public ApplianceChangeDetial findById(Integer id) { | 
|         return applianceChangeDetialMapper.selectById(id); | 
|     } | 
|   | 
|     @Override | 
|     public ApplianceChangeDetial findOne(ApplianceChangeDetial applianceChangeDetial) { | 
|         QueryWrapper<ApplianceChangeDetial> wrapper = new QueryWrapper<>(applianceChangeDetial); | 
|         return applianceChangeDetialMapper.selectOne(wrapper); | 
|     } | 
|   | 
|     @Override | 
|     public List<ApplianceChangeDetial> findList(ApplianceChangeDetial applianceChangeDetial) { | 
|         QueryWrapper<ApplianceChangeDetial> wrapper = new QueryWrapper<>(applianceChangeDetial); | 
|         return applianceChangeDetialMapper.selectList(wrapper); | 
|     } | 
|    | 
|     @Override | 
|     public PageData<ApplianceChangeDetial> findPage(PageWrap<ApplianceChangeDetial> pageWrap) { | 
|         IPage<ApplianceChangeDetial> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|         QueryWrapper<ApplianceChangeDetial> queryWrapper = new QueryWrapper<>(); | 
|         Utils.MP.blankToNull(pageWrap.getModel()); | 
|   | 
|         return PageData.from(applianceChangeDetialMapper.selectPage(page, queryWrapper)); | 
|     } | 
|   | 
|     @Override | 
|     public long count(ApplianceChangeDetial applianceChangeDetial) { | 
|         QueryWrapper<ApplianceChangeDetial> wrapper = new QueryWrapper<>(applianceChangeDetial); | 
|         return applianceChangeDetialMapper.selectCount(wrapper); | 
|     } | 
|   | 
|   | 
|     @Override | 
|     public PageData<ApplianceChangeDetailExtListVO> findListPage(PageWrap<QueryApplianceChangeDetailExtDTO> pageWrap) { | 
|         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
|         if(!Constants.equalsInteger(user.getType(),Constants.USERTYPE.COM)){ | 
|             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "对不起,您无权限进行该操作!"); | 
|         } | 
|         //只能查看当前根组织的数据 | 
|         pageWrap.getModel().setDeleted(Constants.ZERO); | 
|         pageWrap.getModel().setRootDepartId(user.getRootDepartment().getId()); | 
| //        if(!Constants.equalsInteger(user.getCurComDepartment().getId(),user.getRootDepartment().getId())){ | 
|         //如果当前选择的公司级组织非根组织信息,只能查看当前选择公司级组织数据 | 
|         pageWrap.getModel().setDepartId(user.getCurComDepartment().getId()); | 
| //        } | 
|         //数据权限 | 
|      /*   List<Integer> dataPermission = user.getDepartPermissionList(); | 
|         if(dataPermission!=null){ | 
|             if(dataPermission.size() == 0){ | 
|                 //只能看自己的 | 
|               //  pageWrap.getModel().setPmodelUserId(user.getId()); | 
|             }else{ | 
|                 //否则走数据权限 | 
|                 pageWrap.getModel().setDepartIds(dataPermission); | 
|             } | 
|         }*/ | 
|         PageHelper.startPage(pageWrap.getPage(), pageWrap.getCapacity()); | 
|         List<ApplianceChangeDetailExtListVO> result = applianceChangeDetialMapper.selectList(pageWrap.getModel()); | 
|   | 
|         return PageData.from(new PageInfo<>(result)); | 
|     } | 
|   | 
| } |