/**
 * Copyright (c) 2016-2019 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有，侵权必究！
 */

package io.renren.modules.app.dao;

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

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.renren.modules.app.entity.UserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 用户
 *
 * @author Mark sunlightcs@gmail.com
 */
@Mapper
public interface UserDao extends BaseMapper<UserEntity> {
    @Select("select p.id, p.order_id orderId, mem.truename, mem.organization, p.pay_time payTime,p.is_pay isPay,(select m.name_cn from meeting as m where m.id=p.meeting_id) as meetingName from attenders join payment p on attenders.id=p.attenders_id join member mem on mem.id=attenders.member_id where attenders.member_id=#{memberId};")
    List<Map<String, Object>> queryOrderList(Long memberId);

    @Select("select mem.truename, mem.organization, mem.position, (select m.name_cn from meeting as m where m.id=a.meeting_id) as meetingName, (select m.start_time from meeting as m where m.id=a.meeting_id) as startTime,(select m.end_time from meeting as m where m.id=a.meeting_id) as endTime,(select p.is_pay from payment as p where p.attenders_id = a.id) as IsPay from attenders a join member mem on mem.id=a.member_id where a.id = #{attendersId};")
    Map<String, Object> queryOrderInfoByAttendersId(Long attendersId);

    @Update("UPDATE member SET `password`=#{password}, `salt`=#{salt} WHERE `id`=#{id}")
    int updatePassWord(Long id, String password, String salt);
}
