|  |  | 
 |  |  |  | 
 |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
 |  |  | import com.doumee.core.constants.Constants; | 
 |  |  | import com.doumee.core.model.LoginUserInfo; | 
 |  |  | import com.doumee.core.model.PageData; | 
 |  |  | import com.doumee.core.model.PageWrap; | 
 |  |  | import com.doumee.core.utils.Utils; | 
 |  |  | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | 
 |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
 |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
 |  |  | 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.Date; | 
 |  |  | import java.util.List; | 
 |  |  | import java.util.Objects; | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * 广告信息表Service实现 | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public String create(Ad ad) { | 
 |  |  |         LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
 |  |  |         ad.setIsdeleted(Constants.ZERO); | 
 |  |  |         ad.setStatus(Constants.ZERO); | 
 |  |  |         ad.setCreateDate(new Date()); | 
 |  |  |         ad.setCreator(loginUserInfo.getId()); | 
 |  |  |         adMapper.insert(ad); | 
 |  |  |         return ad.getId(); | 
 |  |  |     } | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public void updateById(Ad ad) { | 
 |  |  |         LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal(); | 
 |  |  |  | 
 |  |  |         UpdateWrapper<Ad> wrapper = new UpdateWrapper<>(); | 
 |  |  |         wrapper.lambda() | 
 |  |  |                 .eq(Ad::getId,ad.getId()) | 
 |  |  |                 .set(Ad::getEditor,ad.getEditor()) | 
 |  |  |                 .set(Ad::getEditor,loginUserInfo.getId()) | 
 |  |  |                 .set(Ad::getEditDate,ad.getEditDate()) | 
 |  |  |                 .set(Ad::getName,ad.getName()) | 
 |  |  |                 .set(Ad::getImgurl,ad.getImgurl()) | 
 |  |  |                 .set(Objects.nonNull(ad.getName()),Ad::getName,ad.getName()) | 
 |  |  |                 .set(Objects.nonNull(ad.getImgurl()),Ad::getImgurl,ad.getImgurl()) | 
 |  |  |                 .set(Ad::getSortnum,ad.getSortnum()) | 
 |  |  |                 .set(Ad::getContent,ad.getContent()) | 
 |  |  |                 .set(Ad::getStatus,ad.getStatus()); | 
 |  |  |                 .set(Objects.nonNull(ad.getContent()),Ad::getContent,ad.getContent()) | 
 |  |  |                 .set(Objects.nonNull(ad.getStatus()),Ad::getStatus,ad.getStatus()); | 
 |  |  |         adMapper.update(null,wrapper); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Ad findById(String id) { | 
 |  |  |         return adMapper.selectById(id); | 
 |  |  |         String path =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.FILE_DIR).getCode()+ | 
 |  |  |                 systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode(); | 
 |  |  |         Ad ad = adMapper.selectById(id); | 
 |  |  |         ad.setImgfullurl(path+ad.getImgurl()); | 
 |  |  |         return ad; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  | 
 |  |  |             queryWrapper.lambda().eq(Ad::getIsdeleted, pageWrap.getModel().getIsdeleted()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getName() != null) { | 
 |  |  |             queryWrapper.lambda().eq(Ad::getName, pageWrap.getModel().getName()); | 
 |  |  |             queryWrapper.lambda().like(Ad::getName, pageWrap.getModel().getName()); | 
 |  |  |         } | 
 |  |  |         if (pageWrap.getModel().getSortnum() != null) { | 
 |  |  |             queryWrapper.lambda().eq(Ad::getSortnum, pageWrap.getModel().getSortnum()); | 
 |  |  | 
 |  |  |         } | 
 |  |  |         queryWrapper.lambda().orderByAsc(Ad::getSortnum); | 
 |  |  |         String path =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.FILE_DIR).getCode()+ | 
 |  |  |                 systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.AD).getCode(); | 
 |  |  |                 systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode(); | 
 |  |  |  | 
 |  |  |         IPage<Ad> adIPage = adMapper.selectPage(page, queryWrapper); | 
 |  |  |         if (!CollectionUtils.isEmpty(adIPage.getRecords())){ |