QiFeng.ZWY.Dal/DalExt/CollectionExtDal.cs

(开头部分) 4KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using QiFeng.LMSD.DBUtility;
using QiFeng.LMSD.Model;
using QiFeng.LMSD.Model.EnumModel;
using QiFeng.LMSD.Utility;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QiFeng.LMSD.Dal.DalExt
{
    public class CollectionExtDal : BaseDal<CollectionExtDal>
    {
        public bool TransAddCollections(int collectionType, int consumerId, string collectedIds)
        {
            if (consumerId == 0 || string.IsNullOrEmpty(collectedIds))
                throw new FormatException("非法请求参数");

            var type = new CollectionType();
            if (Enum.IsDefined(typeof(CollectionType), collectionType))
            {
                type = (CollectionType)Enum.ToObject(typeof(CollectionType), collectionType);
            }
            else
                throw new FormatException("收藏类型错误");

            var ds = CollectionDal.Instance.GetList(" CollectionType = " + (int)type + " AND ConsumerId = " + consumerId + " AND CollectedId IN (" + collectedIds + ") ");
            var list = ServicesHelper.DataSetToIList<Collection>(ds).ToList();

            var result = false;
            using (var connection = new SqlConnection(DbHelperSQL.ConnectionString))
            {
                connection.Open();
                using (var sqlTrans = connection.BeginTransaction())
                {
                    try
                    {
                        var collectionIdList = collectedIds.Split(',').ToList();
                        collectionIdList.ForEach(u =>
                        {
                            if (!list.Any(c => c.CollectedId.ToString() == u))
                            {
                                var model = new Collection()
                                {
                                    CollectedId = Convert.ToInt32(u),
                                    CollectionType = (int)type,
                                    ConsumerId = consumerId,
                                    IsDelete = false,
                                    AddDate = DateTime.Now
                                };

                                if (Add(connection, sqlTrans, model) <= 0)
                                    throw new Exception();
                            }
                        });

后面还有 55 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。