package cn.sikey.mcdisk.dal.mysql;

import cn.sikey.mcdisk.controller.app.authorizephoto.vo.AppOauthPhotoReqVO;
import cn.sikey.mcdisk.controller.app.authorizephoto.vo.OauthPhotoReqVO;
import cn.sikey.mcdisk.controller.app.authorizephoto.vo.QueryOauthPhotoByDeviceIdRespVO;
import cn.sikey.mcdisk.dal.dataobject.AuthorizePhotoDO;
import cn.sikey.mcdisk.enums.IsAuthorizeEnum;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

import java.util.Objects;

/**
 * 授权相册
 *
 * @author nelson
 */
@Mapper
public interface AuthorizePhotoMapper extends BaseMapper<AuthorizePhotoDO> {


    default void insertOauthPhoto(AppOauthPhotoReqVO appOauthPhotoReqVO) {
        String userId = appOauthPhotoReqVO.getUserId();
        String ticket = appOauthPhotoReqVO.getTicket();
        AuthorizePhotoDO authorizePhotoDO = new AuthorizePhotoDO();
        authorizePhotoDO.setUserId(userId);
        authorizePhotoDO.setDeviceId(ticket);
        authorizePhotoDO.setNickName(appOauthPhotoReqVO.getNickName());
        authorizePhotoDO.setModel(appOauthPhotoReqVO.getModel());
        authorizePhotoDO.setCreator(String.valueOf(userId));
        authorizePhotoDO.setUpdater(String.valueOf(userId));
        insert(authorizePhotoDO);
    }

    /*default AuthorizePhotoDO queryOauthPhotoByUserIdDeviceId(String userId,String deviceId) {
        QueryWrapper<AuthorizePhotoDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id", userId);
        queryWrapper.eq("device_id", deviceId);
        return selectOne(queryWrapper);
    }*/

    /*default void updateAuthorizePhotoByUserIdDeviceId(String deviceId){
        UpdateWrapper<AuthorizePhotoDO> queryWrapper = new UpdateWrapper<>();
        queryWrapper.eq("device_id", deviceId);
        update(queryWrapper);
    }*/

    default AuthorizePhotoDO queryOauthPhotoByDeviceId(String deviceId){
        QueryWrapper<AuthorizePhotoDO> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("device_id", deviceId);
        return selectOne(queryWrapper);
    }
}


