| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import com.doumee.biz.system.SystemDictDataBiz; |
| | | import com.doumee.core.constants.Constants; |
| | | import com.doumee.core.model.PageData; |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Utils; |
| | |
| | | |
| | | @Autowired |
| | | private AdMapper adMapper; |
| | | |
| | | @Autowired |
| | | SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @Override |
| | | public String create(Ad ad) { |
| | |
| | | |
| | | @Override |
| | | public void updateById(Ad ad) { |
| | | adMapper.updateById(ad); |
| | | UpdateWrapper<Ad> wrapper = new UpdateWrapper<>(); |
| | | wrapper.lambda() |
| | | .eq(Ad::getId,ad.getId()) |
| | | .set(Ad::getEditor,ad.getEditor()) |
| | | .set(Ad::getEditDate,ad.getEditDate()) |
| | | .set(Ad::getName,ad.getName()) |
| | | .set(Ad::getImgurl,ad.getImgurl()) |
| | | .set(Ad::getSortnum,ad.getSortnum()) |
| | | .set(Ad::getContent,ad.getContent()) |
| | | .set(Ad::getStatus,ad.getStatus()); |
| | | adMapper.update(null,wrapper); |
| | | } |
| | | |
| | | @Override |
| | |
| | | QueryWrapper<Ad> wrapper = new QueryWrapper<>(ad); |
| | | return adMapper.selectList(wrapper); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public PageData<Ad> findPage(PageWrap<Ad> pageWrap) { |
| | | IPage<Ad> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); |
| | |
| | | if (pageWrap.getModel().getImgurl() != null) { |
| | | queryWrapper.lambda().eq(Ad::getImgurl, pageWrap.getModel().getImgurl()); |
| | | } |
| | | for(PageWrap.SortData sortData: pageWrap.getSorts()) { |
| | | if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) { |
| | | queryWrapper.orderByDesc(sortData.getProperty()); |
| | | } else { |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | queryWrapper.lambda().orderByAsc(Ad::getSortnum); |
| | | String path =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.FILE_DIR).getCode()+ |
| | | systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.AD).getCode(); |
| | | |
| | | IPage<Ad> adIPage = adMapper.selectPage(page, queryWrapper); |
| | | if (!CollectionUtils.isEmpty(adIPage.getRecords())){ |
| | | adIPage.getRecords().forEach(s->{ |
| | | s.setImgfullurl(path+s.getImgurl()); |
| | | }); |
| | | } |
| | | return PageData.from(adMapper.selectPage(page, queryWrapper)); |
| | | return PageData.from(adIPage); |
| | | } |
| | | |
| | | @Override |