package io.renren.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.dao.AppSysUserDao;
import io.renren.dto.AppSysUserDTO;
import io.renren.entity.AppSysUserEntity;
import io.renren.service.AppSysUserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * APP系统用户
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2022-05-09
 */
@Service
public class AppSysUserServiceImpl extends CrudServiceImpl<AppSysUserDao, AppSysUserEntity, AppSysUserDTO> implements AppSysUserService {

    @Autowired
    private AppSysUserDao appSysUserDao;
    @Override
    public QueryWrapper<AppSysUserEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<AppSysUserEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);

        return wrapper;
    }

    @Override
    public AppSysUserEntity selectByUserName(String username) {
        return appSysUserDao.selectOne(new QueryWrapper<AppSysUserEntity>().eq("username",username));
    }
}