package com.ruoyi.mall.service.impl;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.set.domain.SetRegion;
import com.ruoyi.set.mapper.SetRegionMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.mall.mapper.MallCareerSalaryMapper;
import com.ruoyi.mall.domain.MallCareerSalary;
import com.ruoyi.mall.service.IMallCareerSalaryService;

import javax.annotation.Resource;

/**
 * 职业薪资Service业务层处理
 *
 * @author LCL
 * @date 2023-10-19
 */
@Service
public class MallCareerSalaryServiceImpl implements IMallCareerSalaryService
{
    @Resource
    private MallCareerSalaryMapper mallCareerSalaryMapper;

    @Resource
    private SetRegionMapper setRegionMapper;

    /**
     * 查询职业薪资
     *
     * @param careerSalaryId 职业薪资主键
     * @return 职业薪资
     */
    @Override
    public MallCareerSalary selectMallCareerSalaryByCareerSalaryId(Long careerSalaryId)
    {
        return mallCareerSalaryMapper.selectMallCareerSalaryByCareerSalaryId(careerSalaryId);
    }

    /**
     * 查询职业薪资列表
     *
     * @param mallCareerSalary 职业薪资
     * @return 职业薪资
     */
    @Override
    public List<MallCareerSalary> selectMallCareerSalaryList(MallCareerSalary mallCareerSalary)
    {
        return mallCareerSalaryMapper.selectMallCareerSalaryList(mallCareerSalary);
    }

    /**
     * 新增职业薪资
     *
     * @param mallCareerSalary 职业薪资
     * @return 结果
     */
    @Override
    public int insertMallCareerSalary(MallCareerSalary mallCareerSalary)
    {
        // 查询省市区名
//        SetRegion province = setRegionMapper.selectSetRegionById(mallCareerSalary.getProvinceId());
//        mallCareerSalary.setProvinceName(province.getName());
//
//        SetRegion city = setRegionMapper.selectSetRegionById(mallCareerSalary.getCityId());
//        mallCareerSalary.setCityName(city.getName());


        mallCareerSalary.setCreateAt(DateUtils.getTime());
        mallCareerSalary.setIsShow("0");
        mallCareerSalary.setStatus("0");
        mallCareerSalary.setDelFlag("0");
        return mallCareerSalaryMapper.insertMallCareerSalary(mallCareerSalary);
    }

    /**
     * 修改职业薪资
     *
     * @param mallCareerSalary 职业薪资
     * @return 结果
     */
    @Override
    public int updateMallCareerSalary(MallCareerSalary mallCareerSalary)
    {
        // 查询省市区名
//        SetRegion province = setRegionMapper.selectSetRegionById(mallCareerSalary.getProvinceId());
//        mallCareerSalary.setProvinceName(province.getName());
//
//        SetRegion city = setRegionMapper.selectSetRegionById(mallCareerSalary.getCityId());
//        mallCareerSalary.setCityName(city.getName());

        mallCareerSalary.setUpdateAt(DateUtils.getTime());
        return mallCareerSalaryMapper.updateMallCareerSalary(mallCareerSalary);
    }

    /**
     * 批量删除职业薪资
     *
     * @param careerSalaryIds 需要删除的职业薪资主键
     * @return 结果
     */
    @Override
    public int deleteMallCareerSalaryByCareerSalaryIds(Long[] careerSalaryIds)
    {
        return mallCareerSalaryMapper.deleteMallCareerSalaryByCareerSalaryIds(careerSalaryIds);
    }

    /**
     * 删除职业薪资信息
     *
     * @param careerSalaryId 职业薪资主键
     * @return 结果
     */
    @Override
    public int deleteMallCareerSalaryByCareerSalaryId(Long careerSalaryId)
    {
        return mallCareerSalaryMapper.deleteMallCareerSalaryByCareerSalaryId(careerSalaryId);
    }

    /**
     * 查询专业前景-职业薪资列表
     *
     * @param cityLevel 城市等级划分
     * @return 专业分类集合
     */
    @Override
    public List<Map<String, Object>> selectMallCareerSalaryListByCareerId(Long careerId, String cityLevel) {
        return mallCareerSalaryMapper.selectMallCareerSalaryListByCareerId(careerId,cityLevel);
    }
}
