package com.fjhx.u.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjhx.entity.u.UUser;
import com.fjhx.params.u.UUserVo;
import com.fjhx.u.mapper.UUserMapper;
import com.fjhx.u.service.UUserService;
import com.fjhx.utils.wrapperUtil.IWrapper;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 管理员 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-11-28
 */
@Service
public class UUserServiceImpl extends ServiceImpl<UUserMapper, UUser> implements UUserService {

    @Override
    public Page<UUser> getPage(Map<String, Object> condition) {

        IWrapper<UUser> wrapper = IWrapper.getWrapper(condition);

        return page(condition, wrapper);
    }

    @Override
    public void add(UUserVo uUserVo) {
        save(uUserVo);
    }

    @Override
    public void edit(UUserVo uUserVo) {
        updateById(uUserVo);
    }

    @Override
    public void delete(UUserVo uUserVo) {
        removeById(uUserVo.getId());
    }

    @Override
    public List<Map<String, Object>> getList(Map<String, Object> condition) {
        IWrapper<UUser> wrapper = IWrapper.getWrapper(condition);
        wrapper.in("DepartmentID", condition.get("deptIdList"));
        wrapper.select("id", "RealName", "DepartmentID");
        return listMaps(wrapper);
    }

}
