81 lines
2.5 KiB
C#
81 lines
2.5 KiB
C#
using System.Data.SqlClient;
|
|
using Dapper.Contrib.Extensions;
|
|
using Dapper;
|
|
using static DbTableClass;
|
|
public class resultClass
|
|
{
|
|
public class deptListResult
|
|
{
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
public List<depts> depts = new List<depts>();
|
|
}
|
|
|
|
public class groupUserListResult
|
|
{
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
public List<user> users = new List<user>();
|
|
}
|
|
|
|
public class groupListResult
|
|
{
|
|
public string ret = "no";
|
|
public string err_code = "0000";
|
|
public string message = "";
|
|
public List<groupDetail> groups = new List<groupDetail>();
|
|
}
|
|
|
|
public class groupDetail : group
|
|
{
|
|
|
|
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
|
|
|
|
|
public List<user> users = new List<user>();
|
|
|
|
public groupDetail() { }
|
|
|
|
public groupDetail(group objData) {
|
|
Type projectType = objData.GetType();
|
|
|
|
foreach (var prop in projectType.GetProperties())
|
|
{
|
|
string propName = prop.Name;
|
|
var valueProperty = projectType.GetProperty(propName);
|
|
object propValue = valueProperty.GetValue(objData, null);
|
|
|
|
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
|
}
|
|
|
|
users = conn.Query<user>("select B.* from groupUser A, users B where A.user_uid = B.user_uid and A.group_uid = @group_uid", new {group_uid = objData.group_uid}).ToList();
|
|
}
|
|
}
|
|
|
|
public class userWithDept : user
|
|
{
|
|
SqlConnection conn = new SqlConnection(GlobalClass.appsettings("ConnectionStrings:SQLConnectionString"));
|
|
|
|
public List<depts> Depts = new List<depts>();
|
|
|
|
public userWithDept() { }
|
|
|
|
public userWithDept(user objData) {
|
|
Type projectType = objData.GetType();
|
|
|
|
foreach (var prop in projectType.GetProperties())
|
|
{
|
|
string propName = prop.Name;
|
|
var valueProperty = projectType.GetProperty(propName);
|
|
object propValue = valueProperty.GetValue(objData, null);
|
|
|
|
this.GetType().GetProperty(propName).SetValue(this, propValue);
|
|
}
|
|
|
|
Depts = conn.Query<depts>("select * from userDept where user_uid = @user_uid", new { user_uid = this.user_uid }).ToList();
|
|
}
|
|
}
|
|
}
|