Search in sources :

Example 16 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project vip by guangdada.

the class DictController method deptUpdate.

/**
 * 跳转到修改字典
 */
@Permission(Const.ADMIN_NAME)
@RequestMapping("/dict_edit/{dictId}")
public String deptUpdate(@PathVariable Integer dictId, Model model) {
    Dict dict = dictMapper.selectById(dictId);
    model.addAttribute("dict", dict);
    List<Dict> subDicts = dictMapper.selectList(new EntityWrapper<Dict>().eq("pid", dictId));
    model.addAttribute("subDicts", subDicts);
    LogObjectHolder.me().set(dict);
    return PREFIX + "dict_edit.html";
}
Also used : Dict(com.ikoori.vip.common.persistence.model.Dict) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) Permission(com.ikoori.vip.common.annotion.Permission) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project haha by hahafreeasair666.

the class CreditComponent method timedTaskOfZan.

/*@Scheduled(fixedRate = 5000*1)
    public void testTimedTask(){
        System.out.println("哈哈自在如风");
    }*/
/**
 * 对反馈公告的赞进行每日赞数量检测进行发布者信用积分的修改
 */
@Scheduled(cron = "0 0 0 * * ?")
public void timedTaskOfZan() {
    try {
        // 对收养反馈公告的赞数量进行发布者信用积分改变
        Wrapper<AdoptionFeedBack> wrapper = new EntityWrapper<>();
        adoptionFeedBackService.selectList(wrapper).forEach(li -> {
            News news = newsService.selectById(li.getNewsId());
            if (news.getZan() > li.getLastTimeZan()) {
                updateUserCredit(news.getCreateUserId(), getNumber(news.getZan() - li.getLastTimeZan()), true);
                li.setLastTimeZan(news.getZan());
                adoptionFeedBackService.updateById(li);
            }
        });
        // 对成功收养的反馈公告进行检查对信用积分改变
        Wrapper<Adoption> wrapper1 = new EntityWrapper<>();
        wrapper1.eq("isadoption", 1);
        adoptionService.selectList(wrapper1).forEach(li -> {
            AdoptionSuccessNewsVO adoptionSuccessNewsVO = adoptionMapper.checkUserIsSendNews(li.getId());
            // 第一次
            if (!li.getFirstHandle()) {
                newsHandle(li, adoptionSuccessNewsVO, 1);
            // 第二次
            } else if (!li.getSecondHandle()) {
                newsHandle(li, adoptionSuccessNewsVO, 2);
            // 第三次
            } else if (!li.getThirdHandle()) {
                newsHandle(li, adoptionSuccessNewsVO, 3);
            }
            adoptionService.updateById(li);
        });
        log.info("定时任务处理完毕 " + new Date());
    } catch (Exception e) {
        log.error("拉闸,定时任务异常..............");
    }
}
Also used : AdoptionSuccessNewsVO(com.ch999.haha.admin.vo.mappervo.AdoptionSuccessNewsVO) AdoptionFeedBack(com.ch999.haha.admin.entity.AdoptionFeedBack) News(com.ch999.haha.admin.entity.News) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) Adoption(com.ch999.haha.admin.entity.Adoption) Date(java.util.Date) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 18 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project haha by hahafreeasair666.

the class AdoptionRequestServiceImpl method handleAdoptionInfo.

@Override
public Boolean handleAdoptionInfo(Integer loginUserId, Integer adoptionId, Integer userId) {
    News news = newsService.selectById(adoptionId);
    if (news == null || !news.getCreateUserId().equals(loginUserId) || !news.getIsAdoptionNews()) {
        return null;
    }
    Wrapper<Adoption> wrapper = new EntityWrapper<>();
    wrapper.eq("adoptionid", adoptionId).eq("isadoption", 0);
    List<Adoption> adoptions = adoptionService.selectList(wrapper);
    if (CollectionUtils.isNotEmpty(adoptions)) {
        Wrapper<AdoptionRequest> wrapper1 = new EntityWrapper<>();
        wrapper1.eq("newsid", adoptionId).eq("userid", userId);
        List<AdoptionRequest> adoptionRequests = this.selectList(wrapper1);
        if (CollectionUtils.isEmpty(adoptionRequests)) {
            return null;
        }
        adoptionRequests.get(0).setIsSuccess(true);
        adoptions.get(0).setIsAdoption(true);
        adoptions.get(0).setUserId(userId);
        adoptions.get(0).setAdoptionTime(new Date());
        return this.updateById(adoptionRequests.get(0)) && adoptionService.updateById(adoptions.get(0));
    }
    return null;
}
Also used : AdoptionRequest(com.ch999.haha.admin.entity.AdoptionRequest) News(com.ch999.haha.admin.entity.News) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) Adoption(com.ch999.haha.admin.entity.Adoption) Date(java.util.Date)

Example 19 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project haha by hahafreeasair666.

the class AdoptionRequestServiceImpl method cancelAdoptionRequest.

@Override
public Boolean cancelAdoptionRequest(Integer userId, Integer adoptionId) {
    // 先校验能不能取消
    Adoption adoption = adoptionService.selectOne(new EntityWrapper<Adoption>().eq("adoptionid", adoptionId));
    AdoptionRequest adoptionRequest = this.selectOne(new EntityWrapper<AdoptionRequest>().eq("newsid", adoptionId).eq("userid", userId));
    if (adoption.getUserId() != null || adoptionRequest == null) {
        return false;
    }
    adoptionRequest.setIsDel(true);
    return this.updateById(adoptionRequest);
}
Also used : AdoptionRequest(com.ch999.haha.admin.entity.AdoptionRequest) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) Adoption(com.ch999.haha.admin.entity.Adoption)

Example 20 with EntityWrapper

use of com.baomidou.mybatisplus.mapper.EntityWrapper in project haha by hahafreeasair666.

the class NewsServiceImpl method getNewsById.

@Override
public NewsDetailVO getNewsById(Integer id, Integer userId) {
    NewsDetailVO newsDetailVO = newsMapper.selectNewsDetail(id);
    if (newsDetailVO != null) {
        // 是否已赞
        if (userId != null && newsDetailVO.getZan() > 0) {
            CommentZanBO one = commentZanRepository.findOne(id.toString());
            if (one != null && one.getZanUserList().stream().anyMatch(userId::equals)) {
                newsDetailVO.setIsPraised(true);
            } else {
                newsDetailVO.setIsPraised(false);
            }
        } else {
            newsDetailVO.setIsPraised(false);
        }
        // 是否能收藏
        Wrapper<NewsCollections> wrapper = new EntityWrapper<>();
        wrapper.eq("userid", userId).eq("newid", id);
        if (newsCollectionsService.selectCount(wrapper) > 0) {
            newsDetailVO.setIsCanCollection(false);
        } else {
            newsDetailVO.setIsCanCollection(true);
        }
        if (StringUtils.isNotBlank(newsDetailVO.getPic())) {
            String[] split = newsDetailVO.getPic().split(",");
            List<String> imgMap = new ArrayList<>();
            List<Imgs> imgs = imgsService.selectBatchIds(Arrays.asList(split));
            imgs.forEach(li -> imgMap.add(li.getImgUrl()));
            newsDetailVO.setPicMap(imgMap);
        }
        // 是否能收养
        Wrapper<Adoption> wrapper1 = new EntityWrapper<>();
        wrapper1.eq("adoptionid", newsDetailVO.getId()).eq("isadoption", 0);
        if (CollectionUtils.isNotEmpty(adoptionService.selectList(wrapper1))) {
            newsDetailVO.setIsCanAdoption(true);
        } else {
            newsDetailVO.setIsCanAdoption(false);
        }
        // 组装父公告id
        if (newsDetailVO.getParentId() != null) {
            News news = this.selectById(newsDetailVO.getParentId());
            Map<String, Object> map = new HashMap<>();
            map.put("id", news.getId());
            map.put("title", news.getTitle());
            newsDetailVO.setParentNews(map);
        }
        // 组装反馈公告id
        List<News> news = this.selectList(new EntityWrapper<News>().eq("parentid", id).orderBy("createtime", false));
        if (CollectionUtils.isNotEmpty(news)) {
            Map<String, Object> map = new HashMap<>();
            map.put("id", news.get(0).getId());
            map.put("title", news.get(0).getTitle());
            newsDetailVO.setFeedBackNews(map);
        }
    }
    return newsDetailVO;
}
Also used : NewsDetailVO(com.ch999.haha.admin.vo.NewsDetailVO) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) JSONObject(com.alibaba.fastjson.JSONObject) CommentZanBO(com.ch999.haha.admin.document.redis.CommentZanBO)

Aggregations

EntityWrapper (com.baomidou.mybatisplus.mapper.EntityWrapper)23 News (com.ch999.haha.admin.entity.News)5 Date (java.util.Date)5 Adoption (com.ch999.haha.admin.entity.Adoption)4 AdoptionRequest (com.ch999.haha.admin.entity.AdoptionRequest)4 JSONObject (com.alibaba.fastjson.JSONObject)3 BussinessException (com.ikoori.vip.common.exception.BussinessException)3 Dict (com.ikoori.vip.common.persistence.model.Dict)3 Transactional (org.springframework.transaction.annotation.Transactional)3 JSONArray (com.alibaba.fastjson.JSONArray)2 UserFans (com.ch999.haha.admin.entity.UserFans)2 Permission (com.ikoori.vip.common.annotion.Permission)2 Member (com.ikoori.vip.common.persistence.model.Member)2 Menu (com.ikoori.vip.common.persistence.model.Menu)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 CommentZanBO (com.ch999.haha.admin.document.redis.CommentZanBO)1 UserInfoBO (com.ch999.haha.admin.document.redis.UserInfoBO)1 AdoptionFeedBack (com.ch999.haha.admin.entity.AdoptionFeedBack)1 Phone (com.ch999.haha.admin.entity.Phone)1 UserInfo (com.ch999.haha.admin.entity.UserInfo)1