74 lines
2.5 KiB
Plaintext
74 lines
2.5 KiB
Plaintext
package ${package_name}.service;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import org.springframework.stereotype.Service;
|
|
import com.hivekion.common.exception.BusinessException;
|
|
import ${package_name}.domain.${entity};
|
|
import ${package_name}.mapper.${entity}Mapper;
|
|
import ${package_name}.service.I${entity}Service;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* 描述:
|
|
* author: ${author}
|
|
* date: ${date}
|
|
*/
|
|
@Service
|
|
public class ${entity}ServiceImpl extends ServiceImpl<${entity}Mapper, ${entity}> implements I${entity}Service {
|
|
|
|
@Override
|
|
public boolean create(${entity}InputVo vo) {
|
|
${entity} model = new ${entity}();
|
|
BeanUtils.copyProperties(vo, model);
|
|
return this.save(model);
|
|
}
|
|
|
|
@Override
|
|
public boolean delete(String key) {
|
|
return this.removeById(key);
|
|
}
|
|
|
|
@Override
|
|
public ${entity}ModelVo getInfo(String key) {
|
|
${entity} info = this.getById(key);
|
|
${entity}ModelVo vo = new ${entity}ModelVo();
|
|
BeanUtils.copyProperties(info, vo);
|
|
return vo;
|
|
}
|
|
|
|
@Override
|
|
public boolean update(${entity}UpdateInputVo vo) {
|
|
${entity} info = this.getById(key);
|
|
BeanUtils.copyProperties(vo, info);
|
|
return this.saveOrUpdate(info);
|
|
}
|
|
|
|
@Override
|
|
public List<${entity}ViewVo> getList(SearchInputVo vo) {
|
|
LambdaQueryWrapper<${entity}> wrapper = Wrappers.lambdaQuery();
|
|
Page<${entity}> page = new Page<>(vo.getPageNum(), vo.getPageSize());
|
|
page.addOrder(new OrderItem("sort_code", true));
|
|
page.addOrder(new OrderItem("create_time", true));
|
|
IPage<${entity}> pageList = this.page(page, wrapper);
|
|
List<${entity}ViewVo> list = pageList.getRecords().stream()
|
|
.map(item -> {
|
|
${entity}ViewVo vo = new ${entity}ViewVo();
|
|
BeanUtils.copyProperties(item, vo);
|
|
return vo;
|
|
}).collect(Collectors.toList());
|
|
Integer total = (int) pageList.getTotal();
|
|
return new PagedResultVo<>(vo, total, list);
|
|
}
|
|
} |