package ${package}.service.impl;

import ${package}.mapper.${classUppercaseName}Mapper;
import ${package}.service.${classUppercaseName}Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import ${package}.service.${classUppercaseName}Service;
import ${package}.domain.dto.${classUppercaseName}Dto;
import ${package}.domain.entity.${classUppercaseName}Entity;
import ${package}.domain.vo.${classUppercaseName}Vo;
import ${package}.domain.vo.result.PageResult;
import ${package}.domain.vo.result.Result;
import ${package}.domain.vo.result.ResultCodeEnum;
import java.util.List;

/**
 * <p>
 * ${comment} 服务实现类
 * </p>
 *
 * @author Bunny
 * @since ${date}
 */
@Service
@Transactional
public class ${classUppercaseName}ServiceImpl extends ServiceImpl<${classUppercaseName}Mapper, ${classUppercaseName}Entity> implements ${classUppercaseName}Service {

    /**
     * * ${comment} 服务实现类
     *
     * @param pageParams ${comment}分页查询page对象
     * @param dto        ${comment}分页查询对象
     * @return 查询分页${comment}返回对象
     */
    @Override
    public PageResult<${classUppercaseName}Vo> get${classUppercaseName}Page(Page<${classUppercaseName}Entity> pageParams, ${classUppercaseName}Dto dto) {
        IPage<${classUppercaseName}Vo> page = baseMapper.selectListByPage(pageParams, dto);

        return PageResult.<${classUppercaseName}Vo>builder()
                .list(page.getRecords())
                .pageNo(page.getCurrent())
                .pageSize(page.getSize())
                .total(page.getTotal())
                .build();
    }

    /**
     * 添加${comment}
     *
     * @param dto ${comment}添加
     */
    @Override
    public void add${classUppercaseName}(${classUppercaseName}Dto dto) {
            ${classUppercaseName}Entity ${classLowercaseName} = new ${classUppercaseName}Entity();
        BeanUtils.copyProperties(dto, ${classLowercaseName});
        save(${classLowercaseName});
    }

    /**
     * 更新${comment}
     *
     * @param dto ${comment}更新
     */
    @Override
    public void update${classUppercaseName}(${classUppercaseName}Dto dto) {
            ${classUppercaseName}Entity ${classLowercaseName} = new ${classUppercaseName}Entity();
        BeanUtils.copyProperties(dto, ${classLowercaseName});
        updateById(${classLowercaseName});
    }

    /**
     * 删除|批量删除${comment}
     *
     * @param ids 删除id列表
     */
    @Override
    public void delete${classUppercaseName}(List<Long> ids) {
        removeByIds(ids);
    }
}