package com.xingxi.master.designer.service.impl;

import com.xingxi.common.core.text.Convert;
import com.xingxi.common.enums.EDelFlag;
import com.xingxi.common.utils.DateUtils;
import com.xingxi.common.utils.ShiroUtils;
import com.xingxi.master.designer.domain.Designer;
import com.xingxi.master.designer.mapper.DesignerMapper;
import com.xingxi.master.designer.service.IDesignerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 设计师Service业务层处理
 *
 * @author xingxi
 * @date 2025-03-06
 */
@Service
public class DesignerServiceImpl implements IDesignerService {
    @Resource
    private DesignerMapper designerMapper;

    /**
     * 查询设计师
     *
     * @param id 设计师主键
     * @return 设计师
     */
    @Override
    public Designer selectDesignerById(Long id) {
        return designerMapper.selectDesignerById(id);
    }

    /**
     * 查询设计师列表
     *
     * @param designer 设计师
     * @return 设计师
     */
    @Override
    public List<Designer> selectDesignerList(Designer designer) {
        designer.setDelFlag(EDelFlag.NO.getVal());
        return designerMapper.selectDesignerList(designer);
    }

    /**
     * 新增设计师
     *
     * @param designer 设计师
     * @return 结果
     */
    @Override
    public int insertDesigner(Designer designer) {
        designer.setDelFlag(EDelFlag.NO.getVal());
        designer.setCreateUser(ShiroUtils.getLoginName());
        designer.setCreateTime(DateUtils.getNowDate());
        return designerMapper.insertDesigner(designer);
    }

    /**
     * 新增设计师
     *
     * @param designerList 设计师
     * @return 结果
     */
    @Override
    public int batchInsertDesigner(List<Designer> designerList) {
        return designerMapper.batchInsertDesigner(designerList);
    }

    /**
     * 修改设计师
     *
     * @param designer 设计师
     * @return 结果
     */
    @Override
    public int updateDesigner(Designer designer) {
        designer.setUpdateUser(ShiroUtils.getLoginName());
        designer.setUpdateTime(DateUtils.getNowDate());
        return designerMapper.updateDesigner(designer);
    }

    /**
     * 批量删除设计师
     *
     * @param ids 需要删除的设计师主键
     * @return 结果
     */
    @Override
    public int deleteDesignerByIds(String ids) {
        return designerMapper.deleteDesignerByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除设计师信息
     *
     * @param id 设计师主键
     * @return 结果
     */
    @Override
    public int deleteDesignerById(Long id) {
        return designerMapper.deleteDesignerById(id);
    }

    /**
     * 逻辑删除设计师
     *
     * @param id 设计师主键
     * @return 结果
     */
    @Override
    public int logicDeleteDesignerById(Long id) {
        return designerMapper.logicDeleteDesignerById(id);
    }

    /**
     * 逻辑批量删除设计师
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    @Override
    public int logicDeleteDesignerByIds(String ids) {
        return designerMapper.logicDeleteDesignerByIds(Convert.toStrArray(ids));
    }

    /**
     * 逻辑批量删除设计师
     *
     * @param designer 设计师
     * @return 结果
     */
    @Override
    public int logicDeleteDesignerByCondition(Designer designer) {
        return designerMapper.logicDeleteDesignerByCondition(designer);
    }
}
