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<ApiGroupDao, ApiGroupEntity> implements ApiGroupService {
|
|
@Override
|
public PageUtils queryPage(Map<String, Object> params) {
|
String groupName = (String)params.get("groupName");
|
|
IPage<ApiGroupEntity> page = this.page(
|
new Query<ApiGroupEntity>().getPage(params),
|
new QueryWrapper<ApiGroupEntity>()
|
.like(StringUtils.isNotBlank(groupName),"group_name", groupName)
|
.orderByDesc("create_time")
|
);
|
return new PageUtils(page);
|
}
|
|
@Override
|
public List<ApiGroupEntity> queryList() {
|
return getBaseMapper().selectList(new QueryWrapper<ApiGroupEntity>().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<ApiGroupEntity>().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<ApiGroupEntity> queryWrapper = new QueryWrapper<>();
|
queryWrapper.ne(StringUtils.isNotBlank(id), "id", id);
|
queryWrapper.and(wrapper -> wrapper.eq("group_name", groupName));
|
return (int)this.count(queryWrapper);
|
}
|
}
|