chenzx
2024-12-24 44cce9e7bab7c37a24affe56ad66d66fbe8884f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;
using GasolineBlend.Entity;
 
namespace GasolineBlend.DAL
{
    public class QccSearchInfoDAL:BaseDAL
    {
        public List<QccSearchInfo> GetQccSearchInfoDistinctList(int UserId)
        {
            var sql = $"select top 8 a.* from QccSearchInfo a inner join (select CompanyName,max(CreateTime) as CreateTime from QccSearchInfo where UserId={UserId} group by CompanyName) b on a.CreateTime=b.CreateTime and a.CompanyName=b.CompanyName where a.UserId={UserId} and a.SearchType>0 order by a.CreateTime desc";
            return Conn.Query<QccSearchInfo>(sql).ToList();
        }
 
         public List<QccSearchInfo> GetSearchPolicyList()
        {
            var sql = $"SELECT TOP 8 * FROM QccSearchInfo WHERE  SearchType = 9 ORDER BY CreateTime DESC";
            return Conn.Query<QccSearchInfo>(sql).ToList();
        }
 
 
        public List<QccSearchInfo> GetQccSearchInfoDistinctList()
        {
            var sql = $"select top 5 a.* from QccSearchInfo a inner join (select CompanyName,max(CreateTime) as CreateTime from QccSearchInfo  group by CompanyName) b on a.CreateTime=b.CreateTime and a.CompanyName=b.CompanyName where  a.SearchType>0 order by a.CreateTime desc";
            return Conn.Query<QccSearchInfo>(sql).ToList();
        }
 
        public int AddQccSearchInfo(QccSearchInfo QccSearchInfo)
        {
            var sql = $"insert into QccSearchInfo (UserId,CompanyName,SuccessFlag,Note,SearchType) Values(@UserId,@CompanyName,@SuccessFlag,@Note,@SearchType);select @@IDENTITY;";
            return Conn.ExecuteScalar<int>(sql, QccSearchInfo);
        }
    }
}