package com.iailab.module.data.gateway.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.iailab.module.data.common.utils.PageUtils; import com.iailab.module.data.common.utils.Query; import com.iailab.module.data.gateway.dao.ApiGroupDao; import com.iailab.module.data.gateway.entity.ApiGroupEntity; import com.iailab.module.data.gateway.service.ApiGroupService; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; import java.util.Map; import java.util.UUID; /** * @author PanZhibao * @Description * @createTime 2022年07月15日 14:02:00 */ @Service("apiGroupService") public class ApiGroupServiceImpl extends ServiceImpl implements ApiGroupService { @Override public PageUtils queryPage(Map params) { String groupName = (String)params.get("groupName"); IPage page = this.page( new Query().getPage(params), new QueryWrapper() .like(StringUtils.isNotBlank(groupName),"group_name", groupName) .orderByDesc("create_time") ); return new PageUtils(page); } @Override public List queryList() { return getBaseMapper().selectList(new QueryWrapper().orderByDesc("create_time")); } @Override public void add(ApiGroupEntity apiGroupEntity) { apiGroupEntity.setId(UUID.randomUUID().toString().replace("-", "")); apiGroupEntity.setCreateTime(new Date()); this.save(apiGroupEntity); } @Override public void update(ApiGroupEntity apiGroupEntity) { this.updateById(apiGroupEntity); } @Override public void deleteById(String id) { this.getBaseMapper().delete(new QueryWrapper().eq("id", id)); } @Override public ApiGroupEntity getInfoById(String id) { return this.getById(id); } @Override public int cheack(ApiGroupEntity apiGroupEntity) { String id = apiGroupEntity.getId(); String groupName = apiGroupEntity.getGroupName(); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); queryWrapper.and(wrapper -> wrapper.eq("group_name", groupName)); return (int)this.count(queryWrapper); } }