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.service.ApiInfoService; import com.iailab.module.data.gateway.dao.ApiInfoDao; import com.iailab.module.data.gateway.entity.ApiInfoEntity; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author PanZhibao * @Description * @createTime 2022年07月15日 14:03:00 */ @Service("apiInfoService") public class ApiInfoServiceImpl extends ServiceImpl implements ApiInfoService { @Override public PageUtils queryPage(Map params) { String apiName = (String)params.get("apiName"); String apiGroupId = (String)params.get("apiGroupId"); String apiServerId = (String)params.get("apiServerId"); Map queryParams = new HashMap<>(3); queryParams.put("apiName", apiName); queryParams.put("apiGroupId", apiGroupId); queryParams.put("apiServerId", apiServerId); IPage page = getBaseMapper().queryList( new Query().getPage(queryParams), params ); return new PageUtils(page); } @Override public List queryList(Map params) { String apiGroupId = (String)params.get("apiGroupId"); String apiServerId = (String)params.get("apiServerId"); return getBaseMapper().selectList(new QueryWrapper() .eq(StringUtils.isNotBlank(apiGroupId), "api_group_id", apiGroupId) .eq(StringUtils.isNotBlank(apiServerId), "api_server_id", apiServerId) .orderByDesc("create_time")); } @Override public void add(ApiInfoEntity apiInfoEntity) { this.save(apiInfoEntity); } @Override public void update(ApiInfoEntity apiInfoEntity) { this.updateById(apiInfoEntity); } @Override public void deleteById(String id) { this.getBaseMapper().delete(new QueryWrapper().eq("id", id)); } @Override public ApiInfoEntity getInfoById(String id) { return this.getById(id); } @Override public int cheack(ApiInfoEntity apiInfoEntity) { String id = apiInfoEntity.getId(); String apiName = apiInfoEntity.getApiName(); QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.ne(StringUtils.isNotBlank(id), "id", id); queryWrapper.and(wrapper -> wrapper.eq("api_name", apiName)); return (int)this.count(queryWrapper); } }