using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using JLHHJSvr.BLL;
using JLHHJSvr.Com;
using JLHHJSvr.Com.Model;
using JLHHJSvr.DBA.DBModle;
using LJLib.DAL.SQL;
using LJLib.Net.SPI.Server;

namespace JLHHJSvr.Excutor
{
    internal sealed class GetDeptExcutor : ExcutorBase<GetDeptRequest, GetDeptResponse>
    {
        protected override void ExcuteInternal(GetDeptRequest request, object state, GetDeptResponse rslt)
        {
            var tokendata = BllHelper.GetToken(request.token);
            if (tokendata == null)
            {
                rslt.ErrMsg = "会话已经中断，请重新登录";
                return;
            }
            using (var con = new SqlConnection(GlobalVar.ConnectionString))
            using (var cmd = con.CreateCommand())
            {
                con.Open();

                rslt.list = new List<u_dept>();
                DbSqlHelper.Select(cmd, "u_dept", null, null, null, 0, 0, rslt.list, null,
                    "deptid, deptname, profitrate, pricelistid, springtypeid, flag");
            }
        }
    }
}
