io.github.wslxm.springbootplus2.manage.test.service.impl.GcTestServiceImpl Maven / Gradle / Ivy
The newest version!
package io.github.wslxm.springbootplus2.manage.test.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.wslxm.springbootplus2.starter.redis.lock.XjDistributedLock;
import org.springframework.stereotype.Service;
import io.github.wslxm.springbootplus2.core.base.model.BasePage;
import io.github.wslxm.springbootplus2.core.constant.SymbolConst;
import io.github.wslxm.springbootplus2.core.base.service.impl.BaseServiceImpl;
import io.github.wslxm.springbootplus2.core.utils.XjBeanUtil;
import io.github.wslxm.springbootplus2.manage.test.mapper.GcTestMapper;
import io.github.wslxm.springbootplus2.manage.test.service.GcTestService;
import io.github.wslxm.springbootplus2.manage.test.model.entity.GcTest;
import io.github.wslxm.springbootplus2.manage.test.model.vo.GcTestVO;
import io.github.wslxm.springbootplus2.manage.test.model.dto.GcTestDTO;
import io.github.wslxm.springbootplus2.manage.test.model.query.GcTestQuery;
import org.apache.commons.lang3.StringUtils;
/**
* base--gc--代码生成测试表 ServiceImpl
*
*
* ::本代码由[兮家小二]提供的代码生成器生成,如有问题,请手动修改 ::作者CSDN:https://blog.csdn.net/qq_41463655
*
* @author ws
* @email [email protected]
* @date 2023-08-28 14:43:41
*/
@Service
public class GcTestServiceImpl extends BaseServiceImpl implements GcTestService {
@Override
public BasePage findPage(GcTestQuery query) {
LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper().orderByDesc(GcTest::getCreateTime);
queryWrapper.select(GcTest.class, info -> !"text_two".equals(info.getColumn())
&& !"text_three".equals(info.getColumn()));
queryWrapper.likeRight(StringUtils.isNotBlank(query.getName()), GcTest::getName, query.getName());
queryWrapper.eq(query.getAge() != null, GcTest::getAge, query.getAge());
queryWrapper.eq(query.getDisable() != null, GcTest::getDisable, query.getDisable());
if (StringUtils.isNotBlank(query.getTime()) && query.getTime().split(SymbolConst.COMMA).length >= 1) {
queryWrapper.between(GcTest::getTime, query.getTime().split(",")[0], query.getTime().split(",")[1]);
}
Page page = this.page(new Page<>(query.getCurrent(), query.getSize()), queryWrapper);
return XjBeanUtil.pageVo(page, GcTestVO.class);
}
@Override
public GcTestVO findId(String id) {
return XjBeanUtil.convert(this.getById(id), GcTestVO.class);
}
@Override
public String insert(GcTestDTO dto) {
GcTest entity = dto.convert(GcTest.class);
boolean b = this.save(entity);
return entity.getId();
}
@Override
public boolean upd(String id, GcTestDTO dto) {
GcTest entity = dto.convert(GcTest.class);
entity.setId(id);
return this.updateById(entity);
}
@Override
@XjDistributedLock(lockName = "#lockKey", leaseTime = 0L)
public boolean del(String id) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
// 0000
return true;
}
}