TopicService.java 1.9 KB
Newer Older
刘基明's avatar
刘基明 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
package com.tanpu.community.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.tanpu.community.dao.entity.community.TopicEntity;
import com.tanpu.community.dao.mapper.community.TopicMapper;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
@EnableCaching
public class TopicService {

    @Resource
    private TopicMapper topicMapper;


    public List<TopicEntity> queryTopicList(){
        return topicMapper.selectList(new QueryWrapper<>());
    }

    public void addTopic(TopicEntity topicEntity){
        topicMapper.insert(topicEntity);
    }


    public void updateTopicToTop(String topicId){
        UpdateWrapper<TopicEntity> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id",topicId);
刘基明's avatar
刘基明 committed
34
        updateWrapper.set("is_top",1);
刘基明's avatar
刘基明 committed
35 36 37 38 39 40
        topicMapper.update(null,updateWrapper);
    }

    public void updateTopicNotTop(String topicId){
        UpdateWrapper<TopicEntity> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id",topicId);
刘基明's avatar
刘基明 committed
41
        updateWrapper.set("is_top",0);
刘基明's avatar
刘基明 committed
42 43 44 45 46 47
        topicMapper.update(null,updateWrapper);
    }

    public void updateTopicToConceal(String topicId){
        UpdateWrapper<TopicEntity> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id",topicId);
刘基明's avatar
刘基明 committed
48
        updateWrapper.set("is_conceal",1);
刘基明's avatar
刘基明 committed
49 50 51 52 53 54
        topicMapper.update(null,updateWrapper);
    }

    public void updateTopicNotConceal(String topicId){
        UpdateWrapper<TopicEntity> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("id",topicId);
刘基明's avatar
刘基明 committed
55
        updateWrapper.set("is_conceal",0);
刘基明's avatar
刘基明 committed
56 57 58 59 60 61 62
        topicMapper.update(null,updateWrapper);
    }

    public TopicEntity queryById(String topicId) {
        return topicMapper.selectById(topicId);
    }
}