• 通用权限管理系统底层的软删除数据的处理方法介绍


    一、单条记录设置软删除:可同时设置记录是否可启用

            /// <summary>
            /// 设置删除标志
            /// </summary>
            /// <param name="id">主键</param>
            /// <param name="changeEnabled">修改有效状态</param>
            /// <param name="recordModifiedUser">记录修改者</param>
            /// <returns>影响行数</returns>
            public virtual int SetDeleted(object id, bool changeEnabled = false, bool recordModifiedUser = false)
            {
                List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
                parameters.Add(new KeyValuePair<string, object>(BaseBusinessLogic.FieldDeletionStateCode, 1));
                if (changeEnabled)
                {
                    parameters.Add(new KeyValuePair<string, object>(BaseBusinessLogic.FieldEnabled, 0));
                }
                if (recordModifiedUser && this.UserInfo != null)
                {
                    parameters.Add(new KeyValuePair<string, object>(BaseBusinessLogic.FieldModifiedUserId, this.UserInfo.Id));
                    //宋彪发现这里的错误 文字与格式字符串错误
                    //parameters.Add(new KeyValuePair<string, object>(BaseBusinessLogic.FieldModifiedOn, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
                    parameters.Add(new KeyValuePair<string, object>(BaseBusinessLogic.FieldModifiedOn, DateTime.Now));
                }
                return this.SetProperty(new KeyValuePair<string, object>(this.PrimaryKey, id), parameters);
            }
            public virtual int SetProperty(KeyValuePair<string, object> whereParameter, List<KeyValuePair<string, object>> parameters)
            {
                List<KeyValuePair<string, object>> whereParameters = new List<KeyValuePair<string, object>>();
                whereParameters.Add(whereParameter);
                return DbLogic.SetProperty(DbHelper, this.CurrentTableName, whereParameters, parameters);
            }

    二、多条记录设置软删除标志:可同时设置记录是否可启用

            /// <summary>
            /// 批量删除标志
            /// </summary>
            /// <param name="ids">主键数组</param>
            /// <param name="enabled">有效</param>
            /// <param name="modifiedUser">修改者</param>
            /// <returns>影响行数</returns>
            public virtual int SetDeleted(object[] ids, bool enabled = false, bool modifiedUser = false)
            {
                List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
                parameters.Add(new KeyValuePair<string, object>(BaseBusinessLogic.FieldDeletionStateCode, 1));
                if (enabled)
                {
                    parameters.Add(new KeyValuePair<string, object>(BaseBusinessLogic.FieldEnabled, 0));
                }
                if (modifiedUser && this.UserInfo != null)
                {
                    parameters.Add(new KeyValuePair<string, object>(BaseBusinessLogic.FieldModifiedUserId, this.UserInfo.Id));
                    parameters.Add(new KeyValuePair<string, object>(BaseBusinessLogic.FieldModifiedBy, this.UserInfo.RealName));
                    parameters.Add(new KeyValuePair<string, object>(BaseBusinessLogic.FieldModifiedOn, DateTime.Now));
                }
                return this.SetProperty(ids, parameters);
            }
            public virtual int SetProperty(object[] ids, List<KeyValuePair<string, object>> parameters)
            {
                return this.SetProperty(this.PrimaryKey, ids, parameters);
            }
            public virtual int SetProperty(string name, object[] values, List<KeyValuePair<string, object>> parameters)
            {
                int result = 0;
                if (values == null)
                {
                    result += this.SetProperty(new KeyValuePair<string, object>(name, string.Empty), parameters);
                }
                else
                {
                    for (int i = 0; i < values.Length; i++)
                    {
                        result += this.SetProperty(new KeyValuePair<string, object>(name, values[i]), parameters);
                    }
                }
                return result;
            }
            public virtual int SetProperty(KeyValuePair<string, object> whereParameter, List<KeyValuePair<string, object>> parameters)
            {
                List<KeyValuePair<string, object>> whereParameters = new List<KeyValuePair<string, object>>();
                whereParameters.Add(whereParameter);
                return DbLogic.SetProperty(DbHelper, this.CurrentTableName, whereParameters, parameters);
            }
  • 相关阅读:
    RDD, DataFrame or Dataset
    RDD的基础知识
    RDD的源码
    窄依赖与宽依赖&stage的划分依据
    HDFS中的读写数据流
    HDFS的Java API
    使用distcp并行拷贝大数据文件
    Flume+Morphlines实现数据的实时ETL
    磕碰,擦伤了,紧急处理方法
    redis linux 基本命令
  • 原文地址:https://www.cnblogs.com/hnsongbiao/p/4516957.html
Copyright © 2020-2023  润新知