package com.winsun.migration.mapper.db1;

import com.winsun.bean.HhrUser;
import com.winsun.bean.SysUser;
import com.winsun.bean.activity.HhrActivity;
import com.winsun.bean.activity.HhrActivityRecord;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

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

@Mapper
@Component
public interface NewDatabases {

    @Select("select * from sys_user where id = 1")
    public List<Map<String, Object>> getUser();

    @Insert({"insert into sys_user(id, account, password, salt, name, sex, phone, roleid, deptid, status, createtime, substName) " +
            "value(#{id}, #{account}, #{password}, #{salt}, #{name}, #{sex}, #{phone}, #{roleid}, #{deptid}, #{status}, #{createtime}, #{substName} )"})
    public int insert(SysUser user);

    @Insert({"insert into hhr_user(id, id_card, ysm, wx_head_img_url, wx_nick_name, open_id, upload_state, grade, position, parent_id, parent_ids, is_active) " +
            "value(#{id}, #{idCard}, #{ysm}, #{wxHeadImgUrl}, #{wxNickName}, #{openId}, #{uploadState}, #{grade}, #{position}, #{parentId}, #{parentIds}, #{isActive})"})
    public int insertHhr(HhrUser user);

    @Insert({"insert into hhr_activity(id, `title`, `desc`, integral, image_url, activity_type, subclass, `range`, `status`, `sort`, create_time, creator, del_flag) " +
            " value(#{id}, #{title}, #{desc}, #{integral}, #{imageUrl}, #{activityType}, #{subclass}, #{range}, #{status}, #{sort}, #{createTime}, #{creator}, #{delFlag})"})
    public int insertActivity(HhrActivity hhrActivity);

    @Insert({"insert into hhr_activity_record(id, activity_id, record_integral, status, remark, image_url, message, create_time, create_id, creator, is_repeal) " +
            " value(#{id}, #{activityId}, #{recordIntegral}, #{status}, #{remark}, #{imageUrl}, #{message}, #{createTime}, #{createId}, #{creator}, #{isRepeal})"})
    public int insertActivityRecord(HhrActivityRecord hhrActivityRecord);

    @Insert({"insert into migration_log(table_name, object, `status`, message, create_time) " +
            "value(#{tableName}, #{object}, #{status}, #{message}, now())"})
    public int insertLog(@Param("tableName") String tableName,
                         @Param("object") Object object,
                         @Param("status") String status,
                         @Param("message") String message);
}
