package com.css.simulation.oauth.client.mapper;


import api.common.pojo.po.system.UserPO;
import api.common.pojo.vo.system.UserVO;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {

    @Select("select id," +
            " username," +
            " password," +
            " is_deleted" +
            " from system_user" +
            " where openid = #{openid}")
    @ResultType(UserPO.class)
    UserPO selectByOpenIdIgnoreDelete(@Param("openid") String openid);

    @Select("SELECT" +
            " id," +
            " username," +
            " password," +
            " visible" +
            " FROM system_user " +
            " WHERE is_deleted = '0' " +
            " and username = #{username}")
    @ResultType(UserVO.class)
    UserVO selectByUsername(@Param("username") String username);

    @Update("update system_user" +
            " set is_delete = #{isDeleted}" +
            " where openid = #{openid}")
    void updateIsDeleted(@Param("openid") String openid,@Param("isDeleted") String isDeleted);

    //* -------------------------------- insert --------------------------------
    @Insert("insert into system_user(" +
            " id,use_type,username,nickname,openid,password,company,role_code,visible," +
            " create_time,modify_time,create_user_id,modify_user_id,is_deleted)" +
            " values (" +
            " #{user.id}," +
            " #{user.useType}," +
            " #{user.username}," +
            " #{user.nickname}," +
            " #{user.openid}," +
            " #{user.password}," +
            " #{user.company}," +
            " #{user.roleCode}," +
            " #{user.visible}," +
            " #{user.createTime}," +
            " #{user.modifyTime}," +
            " #{user.createUserId}," +
            " #{user.modifyUserId}," +
            " #{user.isDeleted}" +
            " )")
    void insert(@Param("user") UserPO userPO);

}