lixiaojun
2022-10-24 c795cfeb985235bb0e70fdc7f2e551330dfb4b31
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SqlSugar;
using IStation.Entity;
 
namespace IStation.DAL
{
    /// <summary>
    /// 用户
    /// </summary>
    public class User : BaseTraceDAL_Sorter_UseStatus_TagName<Entity.User>
    {
        /// <summary>
        /// 
        /// </summary>
        public override ConnectionConfig ConnectionConfig
        {
            get { return ConfigHelper.DefaultConnectionConfig; }
 
        }
 
        /// <summary>
        /// 更新登录密码
        /// </summary>
        public bool UpdateLoginPwd(long ID, string LoginPwd,long UpdateUserID,DateTime UpdateTime)
        {
            if (string.IsNullOrEmpty(LoginPwd))
                return default;
            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
            {
                return db.Updateable<Entity.User>()
                    .SetColumns(x => x.LoginPwd == LoginPwd)
                    .SetColumns(x => x.UpdateUserID == UpdateUserID)
                    .SetColumns(x => x.UpdateTime == UpdateTime)
                    .Where(x =>  x.ID == ID)
                    .ExecuteCommand() > 0;
            }
        }
 
        /// <summary>
        /// 通过 ID 删除
        /// </summary>
        public override bool DeleteByID(long ID)
        {
            using (SqlSugarClient db = new SqlSugarClient(ConnectionConfig))
            {
                db.BeginTran();
                var result = db.Deleteable<Entity.User>()
                    .Where(x => x.ID == ID)
                    .ExecuteCommandHasChange();
                if (!result)
                {
                    db.RollbackTran();
                    return false;
                }
                db.Deleteable<Entity.UserAttention>()
                    .Where(x => x.UserID == ID)
                    .ExecuteCommand();
                db.CommitTran();
                return true;
            }
        }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    }
}