Search in sources :

Example 1 with EntityWrapper

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

the class UserInfoServiceImpl method loginByMobileOrUserName.

@Override
public Integer loginByMobileOrUserName(String type, String loginInfo, String pwd) {
    Wrapper<UserInfo> wrapper = new EntityWrapper<>();
    wrapper.eq(type, loginInfo);
    UserInfo userInfo = this.selectOne(wrapper);
    if (userInfo == null || !pwd.equals(userInfo.getPwd())) {
        return null;
    } else {
        return userInfo.getId();
    }
}
Also used : EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) UserInfo(com.ch999.haha.admin.entity.UserInfo)

Example 2 with EntityWrapper

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

the class CreditComponent method newsHandle.

private void newsHandle(Adoption li, AdoptionSuccessNewsVO adoptionSuccessNewsVO, Integer times) {
    long date = new Date().getTime();
    switch(times) {
        case 1:
            if (date > adoptionSuccessNewsVO.getTime1().getTime()) {
                Wrapper<News> newsWrapper = new EntityWrapper<>();
                newsWrapper.eq("parentid", li.getAdoptionId()).lt("createtime", adoptionSuccessNewsVO.getTime1());
                List<News> news = newsService.selectList(newsWrapper);
                // 到时间没写就减10分信誉分
                if (CollectionUtils.isEmpty(news)) {
                    updateUserCredit(li.getUserId(), 10, false);
                // 写了就加5分
                } else {
                    updateUserCredit(li.getUserId(), 5, true);
                }
                li.setFirstHandle(true);
            }
            break;
        case 2:
            if (date > adoptionSuccessNewsVO.getTime2().getTime()) {
                Wrapper<News> newsWrapper = new EntityWrapper<>();
                newsWrapper.eq("parentid", li.getAdoptionId()).lt("createtime", adoptionSuccessNewsVO.getTime2());
                List<News> news = newsService.selectList(newsWrapper);
                // 到时间没写就减10分信誉分
                if (CollectionUtils.isEmpty(news)) {
                    updateUserCredit(li.getUserId(), 10, false);
                // 写了就加5分
                } else {
                    updateUserCredit(li.getUserId(), 5, true);
                }
                li.setSecondHandle(true);
            }
            break;
        case 3:
            if (date > adoptionSuccessNewsVO.getTime3().getTime()) {
                Wrapper<News> newsWrapper = new EntityWrapper<>();
                newsWrapper.eq("parentid", li.getAdoptionId()).lt("createtime", adoptionSuccessNewsVO.getTime3());
                List<News> news = newsService.selectList(newsWrapper);
                // 到时间没写就减10分信誉分
                if (CollectionUtils.isEmpty(news)) {
                    updateUserCredit(li.getUserId(), 10, false);
                } else {
                    // 写了就加5分
                    updateUserCredit(li.getUserId(), 5, true);
                }
                li.setThirdHandle(true);
            }
            break;
        default:
            break;
    }
}
Also used : News(com.ch999.haha.admin.entity.News) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) Date(java.util.Date)

Example 3 with EntityWrapper

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

the class AdoptionRequestServiceImpl method addAdoptionRequest.

@Override
public Boolean addAdoptionRequest(Integer id, Integer userId) {
    // 先校验是否申请过
    Wrapper<AdoptionRequest> wrapper = new EntityWrapper<>();
    wrapper.eq("newsid", id).eq("userid", userId);
    if (CollectionUtils.isNotEmpty(this.selectList(wrapper))) {
        return false;
    }
    // 由于前一步已经验证了能否领养,这一步就直接存到领养请求表里面
    AdoptionRequest AdoptionRequest = new AdoptionRequest(id, userId);
    return this.insert(AdoptionRequest);
}
Also used : AdoptionRequest(com.ch999.haha.admin.entity.AdoptionRequest) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper)

Example 4 with EntityWrapper

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

the class AdoptionRequestServiceImpl method getMyAdoptionList.

@Override
public PageVO<MyAdoptionVO> getMyAdoptionList(Integer userId, Integer currentPage) {
    Integer size = 10;
    Wrapper<AdoptionRequest> wrapper = new EntityWrapper<>();
    wrapper.eq("userid", userId);
    List<MyAdoptionVO> list = new ArrayList<>();
    List<AdoptionRequest> adoptionRequests = this.selectList(wrapper);
    PageVO<MyAdoptionVO> pageVO = new PageVO<>();
    pageVO.setTotalPage((int) Math.ceil(adoptionRequests.size() / (double) size));
    pageVO.setCurrentPage(currentPage);
    if (CollectionUtils.isNotEmpty(adoptionRequests)) {
        if (adoptionRequests.size() > size * (currentPage - 1)) {
            adoptionRequests = adoptionRequests.subList(size * (currentPage - 1), size * currentPage > adoptionRequests.size() ? adoptionRequests.size() : size * currentPage);
        } else {
            adoptionRequests = new ArrayList<>();
        }
        adoptionRequests.forEach(li -> {
            News news = newsService.selectById(li.getNewsId());
            MyAdoptionVO myAdoptionVO = new MyAdoptionVO();
            myAdoptionVO.setNewsId(li.getNewsId());
            myAdoptionVO.setTitle(news.getTitle());
            // 组装领养成功与否状态
            Adoption adoption = adoptionService.selectOne(new EntityWrapper<Adoption>().eq("adoptionid", li.getNewsId()));
            if (adoption.getIsAdoption()) {
                myAdoptionVO.setIsSuccess(adoption.getUserId().equals(userId) ? 1 : 2);
            } else {
                myAdoptionVO.setIsSuccess(0);
            }
            myAdoptionVO.setPic(getOnePicPath(news));
            list.add(myAdoptionVO);
        });
    }
    pageVO.setList(list);
    return pageVO;
}
Also used : AdoptionRequest(com.ch999.haha.admin.entity.AdoptionRequest) PageVO(com.ch999.haha.admin.vo.PageVO) ArrayList(java.util.ArrayList) MyAdoptionVO(com.ch999.haha.admin.vo.MyAdoptionVO) News(com.ch999.haha.admin.entity.News) EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) Adoption(com.ch999.haha.admin.entity.Adoption)

Example 5 with EntityWrapper

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

the class UserFansServiceImpl method followOrCancel.

@Override
public Boolean followOrCancel(Integer userId1, Integer userId2, Boolean isFollow) {
    if (userInfoService.selectById(userId2) == null) {
        return null;
    }
    Wrapper<UserFans> wrapper = new EntityWrapper<>();
    wrapper.eq("userid1", userId1).eq("userid2", userId2);
    List<UserFans> userFans = this.selectList(wrapper);
    if (isFollow == null || isFollow) {
        if (CollectionUtils.isNotEmpty(userFans)) {
            return false;
        }
        UserFans newUserFans = new UserFans(userId1, userId2);
        return this.insert(newUserFans);
    } else {
        if (CollectionUtils.isEmpty(userFans)) {
            return false;
        }
        UserFans userFans1 = userFans.get(0);
        return this.deleteById(userFans1.getId());
    }
}
Also used : EntityWrapper(com.baomidou.mybatisplus.mapper.EntityWrapper) UserFans(com.ch999.haha.admin.entity.UserFans)

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