package com.hys.app.service.erp.impl;

import com.hys.app.converter.erp.CustomerConverter;
import com.hys.app.converter.erp.PostConverter;
import com.hys.app.framework.database.WebPage;
import com.hys.app.framework.database.mybatisplus.base.BaseServiceImpl;
import com.hys.app.framework.exception.ServiceException;
import com.hys.app.mapper.erp.CustomerMapper;
import com.hys.app.mapper.erp.PostMapper;
import com.hys.app.model.erp.dos.CustomerDO;
import com.hys.app.model.erp.dos.PostDO;
import com.hys.app.model.erp.dto.CustomerDTO;
import com.hys.app.model.erp.dto.CustomerQueryParams;
import com.hys.app.model.erp.dto.PostDTO;
import com.hys.app.model.erp.dto.PostQueryParams;
import com.hys.app.model.erp.vo.CustomerVO;
import com.hys.app.model.erp.vo.PostVO;
import com.hys.app.service.erp.CustomerManager;
import com.hys.app.service.erp.PostManager;
import com.hys.app.service.system.AdminUserManager;
import com.hys.app.util.ValidateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 岗位业务层实现
 *
 * @author 张崧
 * 2023-11-29 17:15:22
 */
@Service
public class CustomerManagerImpl extends BaseServiceImpl<CustomerMapper, CustomerDO> implements CustomerManager {

    @Autowired
    private CustomerConverter converter;


    @Override
    public WebPage<CustomerVO> list(CustomerQueryParams queryParams) {
        WebPage<CustomerDO> webPage = baseMapper.selectPage(queryParams);
        return converter.convert(webPage);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void add(CustomerDTO req) {
        save(converter.convert(req));
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void edit(CustomerDTO request) {
        updateById(converter.convert(request));
    }

    @Override
    public CustomerVO getDetail(Long id) {
        return converter.convert(getById(id));
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delete(Long id) {
        removeById(id);
    }


}

