using PoJun.Dapper;
using ASHermed.SinoInterface.Api.IRepository.Test;
using ASHermed.SinoInterface.Entity.Test;
using ASHermed.SinoInterface.Repository.MySql;
using ASHermed.SinoInterface.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ASHermed.SinoInterface.Api.ContractModel.App;
using ASHermed.SinoInterface.Api.IRepository;

namespace ASHermed.SinoInterface.Api.MySqlRepository
{

    public class OutIMGroupRepository : BaseRepositoryToASHermed_SinoInterface<Out_IM_Group>, IOutIMGroupRepository
    {

        public int InsertOutIMGroup(Out_IM_Group outImGroup)
        {
            StringBuilder str = new StringBuilder();
            str.Append("insert into out_im_group ");
            str.Append(@"(GROUP_ID,GROUP_CONTENT,IM_ID,`STATUS`,CREATE_TIME) ");
            str.Append(" values ");
            str.Append(@"(@GROUP_ID,@GROUP_CONTENT,@IM_ID,@STATUS,@CREATE_TIME); ");
            str.Append("select @@identity; ");
            var parms = new Dictionary<string, object>();
            parms.Add("@GROUP_ID", outImGroup.Group_Id);
            parms.Add("@GROUP_CONTENT", outImGroup.Group_Content);
            parms.Add("@IM_ID", outImGroup.IM_Id);
            parms.Add("@STATUS", outImGroup.Status);
            parms.Add("@CREATE_TIME", outImGroup.Create_Time);
            var result = Execute(str.ToString(), parms);
            return result;
        }

        public int DeleteGroupContent(string groupId)
        {
            var parms = new Dictionary<string, object>();
            StringBuilder str = new StringBuilder();
            str.Append(@" update out_im_group
                        set `STATUS` = 0
                        where GROUP_ID = @GROUP_ID");

            parms.Add("@GROUP_ID", groupId);
            var result = Execute(str.ToString(), parms);
            return result;
        }




    }


}
