package com.zy.asrs.service.impl; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.core.exception.CoolException; import org.springframework.stereotype.Service; import com.zy.asrs.entity.Tag; import com.zy.asrs.mapper.TagMapper; import com.zy.asrs.service.TagService; @Service("tagService") public class TagServiceImpl extends ServiceImpl implements TagService { @Override public synchronized Tag getTop() { Tag top = this.selectOne(new EntityWrapper().eq("level", 1)); if (top == null) { top = new Tag(); top.setName("全部"); top.setType(0); top.setLevel(1); top.setStatus(1); top.setSort(0); Integer insert = this.baseMapper.insert(top); if (insert == 0) { throw new CoolException("服务器异常"); } } return top; } @Override public Tag selectByName(String name, Integer level) { return this.selectOne(new EntityWrapper().eq("name", name).eq("level", level)); } }