package com.template.services.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.template.mapper.SmartIdentityMapper;
import com.template.model.pojo.SmartIdentity;
import com.template.model.pojo.SmartIdentity;
import com.template.mapper.SmartIdentityMapper;
import com.template.model.result.PageUtils;
import com.template.services.SmartIdentityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
/**
*
* 服务实现类
*
*
* @author ceshi
* @since 2023-12-04
*/
@Service
public class SmartIdentityServiceImpl extends ServiceImpl implements SmartIdentityService {
@Autowired
private SmartIdentityMapper smartIdentityMapper;
@Override
public int insertSmartIdentity(SmartIdentity sa) {
int result = smartIdentityMapper.insert(sa);
return result;
}
@Override
public int updateSmartIdentity(SmartIdentity sa) {
int result = smartIdentityMapper.updateById(sa);
return result;
}
@Override
public SmartIdentity queryIdentityByName(String name){
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("name", name);
SmartIdentity result = smartIdentityMapper.selectOne(queryWrapper);
return result;
}
@Override
public PageUtils queryPageSmartIdentitys(int currentPage, int pageCount, String name) {
Page page = new Page<>(currentPage, pageCount);
QueryWrapper queryWrapper = new QueryWrapper<>();
//queryWrapper.like(StringUtils.hasText(name), "name", name);
IPage result = smartIdentityMapper.selectPage(page,queryWrapper);
return new PageUtils<>(result);
}
@Override
public int deleteSmartIdentityById(int id) {
int result = smartIdentityMapper.deleteById(id);
return result;
}
@Override
public SmartIdentity getSmartById(int id) {
SmartIdentity result = smartIdentityMapper.selectById(id);
return result;
}
}