20220325 新增用户接口
This commit is contained in:
@@ -323,5 +323,163 @@ namespace BLL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 保存Meeting
|
||||||
|
/// <summary>
|
||||||
|
/// 保存Meeting
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="meeting">会议信息</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string SaveUserInfo(Model.UserListItem listItem)
|
||||||
|
{
|
||||||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||||
|
{
|
||||||
|
List<Model.UserItem> userInfo = listItem.list;
|
||||||
|
string returnInfos = string.Empty;
|
||||||
|
int i = 0;
|
||||||
|
int rowNum = 0;
|
||||||
|
foreach (var item in userInfo)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
string info = string.Empty;
|
||||||
|
if (string.IsNullOrEmpty(item.UnitName))
|
||||||
|
{
|
||||||
|
info += "单位名称为空。";
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(item.UserName))
|
||||||
|
{
|
||||||
|
info += "用户名称为空。";
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(item.Account))
|
||||||
|
{
|
||||||
|
info += "用户账号为空。";
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(info))
|
||||||
|
{
|
||||||
|
Model.Sys_User newUser = new Model.Sys_User
|
||||||
|
{
|
||||||
|
UserId = item.UserId,
|
||||||
|
UserCode = item.UserCode,
|
||||||
|
UserName = item.UserName,
|
||||||
|
Account = item.Account,
|
||||||
|
Password = item.Password,
|
||||||
|
IdentityCard = item.IdentityCard,
|
||||||
|
Telephone = item.Telephone,
|
||||||
|
IsPost = item.IsPost == "1" ? true : false,
|
||||||
|
IsOffice = true,
|
||||||
|
};
|
||||||
|
#region 用户单位
|
||||||
|
newUser.UnitId = Const.UnitId_CD;
|
||||||
|
if (!string.IsNullOrEmpty(item.UnitName) || !string.IsNullOrEmpty(item.UnitCode))
|
||||||
|
{
|
||||||
|
var getUnit = db.Base_Unit.FirstOrDefault(x => x.UnitName == item.UnitName || x.UnitName == item.UnitName);
|
||||||
|
if (getUnit != null)
|
||||||
|
{
|
||||||
|
newUser.UnitId = getUnit.UnitId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Model.Base_Unit newUnit = new Model.Base_Unit
|
||||||
|
{
|
||||||
|
UnitId = SQLHelper.GetNewID(),
|
||||||
|
UnitName = item.UnitName,
|
||||||
|
UnitCode = item.UnitCode,
|
||||||
|
};
|
||||||
|
db.Base_Unit.InsertOnSubmit(newUnit);
|
||||||
|
db.SubmitChanges();
|
||||||
|
newUser.UnitId = newUnit.UnitId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region 用户部门
|
||||||
|
if (!string.IsNullOrEmpty(item.DepartName))
|
||||||
|
{
|
||||||
|
var getDepart = db.Base_Depart.FirstOrDefault(x => x.DepartName == item.DepartName);
|
||||||
|
if (getDepart != null)
|
||||||
|
{
|
||||||
|
newUser.DepartId = getDepart.DepartId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Model.Base_Depart newDepart = new Model.Base_Depart
|
||||||
|
{
|
||||||
|
DepartId = SQLHelper.GetNewID(),
|
||||||
|
DepartName = item.DepartName,
|
||||||
|
};
|
||||||
|
db.Base_Depart.InsertOnSubmit(newDepart);
|
||||||
|
db.SubmitChanges();
|
||||||
|
newUser.DepartId = newDepart.DepartId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region 用户角色
|
||||||
|
if (!string.IsNullOrEmpty(item.RoleName))
|
||||||
|
{
|
||||||
|
var getRole = db.Sys_Role.FirstOrDefault(x => x.RoleName == item.RoleName);
|
||||||
|
if (getRole != null)
|
||||||
|
{
|
||||||
|
newUser.RoleId = getRole.RoleId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Model.Sys_Role newRole = new Model.Sys_Role
|
||||||
|
{
|
||||||
|
RoleId = SQLHelper.GetNewID(),
|
||||||
|
RoleName = item.RoleName,
|
||||||
|
};
|
||||||
|
db.Sys_Role.InsertOnSubmit(newRole);
|
||||||
|
db.SubmitChanges();
|
||||||
|
newUser.RoleId = newRole.RoleId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
if (!string.IsNullOrEmpty(item.Password))
|
||||||
|
{
|
||||||
|
newUser.Password = item.Password;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newUser.Password = Funs.EncryptionPassword(Const.Password);
|
||||||
|
}
|
||||||
|
var geUser = db.Sys_User.FirstOrDefault(x => (x.Account == item.Account && item.Account != null) || (x.IdentityCard == item.IdentityCard && item.IdentityCard != null));
|
||||||
|
if (geUser != null)
|
||||||
|
{
|
||||||
|
geUser.UserCode = newUser.UserCode;
|
||||||
|
geUser.UserName = newUser.UserName;
|
||||||
|
geUser.Account = newUser.Account;
|
||||||
|
geUser.Password = newUser.Password;
|
||||||
|
geUser.IdentityCard = newUser.IdentityCard;
|
||||||
|
geUser.Telephone = newUser.Telephone;
|
||||||
|
geUser.UnitId = newUser.UnitId;
|
||||||
|
geUser.DepartId = newUser.DepartId;
|
||||||
|
geUser.RoleId = newUser.RoleId;
|
||||||
|
geUser.IsPost = newUser.IsPost;
|
||||||
|
db.SubmitChanges();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newUser.UserId = SQLHelper.GetNewID();
|
||||||
|
db.Sys_User.InsertOnSubmit(newUser);
|
||||||
|
db.SubmitChanges();
|
||||||
|
}
|
||||||
|
rowNum++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnInfos += "第" + i.ToString() + "行," + info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(returnInfos))
|
||||||
|
{
|
||||||
|
returnInfos = "同步成功" + rowNum.ToString() + "条记录。" + returnInfos;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
returnInfos = "同步成功" + rowNum.ToString() + "条记录。";
|
||||||
|
}
|
||||||
|
return returnInfos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
src="./images/login.png"
|
src="./images/login.png"
|
||||||
style="height: 100%; left: 0px; top: 0px; bottom: 0px; position: absolute; display: none;" />
|
style="height: 100%; left: 0px; top: 0px; bottom: 0px; position: absolute; display: none;" />
|
||||||
<img alt=""
|
<img alt=""
|
||||||
src="res/index/images/iconlogo.png"
|
<%-- src="res/index/images/iconlogo.png"--%>
|
||||||
style="height: auto;width:400px; left: 100px; top: 65px; position: absolute;" />
|
style="height: auto;width:400px; left: 100px; top: 65px; position: absolute;" />
|
||||||
<div class="bi-flex-center-adapt-layout login-area"
|
<div class="bi-flex-center-adapt-layout login-area"
|
||||||
style="width: 23%; right: 10%; top: 0px; bottom: 0px; position: absolute;">
|
style="width: 23%; right: 10%; top: 0px; bottom: 0px; position: absolute;">
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ namespace Model
|
|||||||
{
|
{
|
||||||
public class UserItem
|
public class UserItem
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户ID
|
/// 用户ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string UserId
|
public string UserId
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
@@ -80,6 +80,30 @@ namespace Model
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 单位代号
|
||||||
|
/// </summary>
|
||||||
|
public string UnitCode
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 部门ID
|
||||||
|
/// </summary>
|
||||||
|
public string DepartId
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 部门名称
|
||||||
|
/// </summary>
|
||||||
|
public string DepartName
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
/// 当前项目ID
|
/// 当前项目ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string LoginProjectId
|
public string LoginProjectId
|
||||||
@@ -136,6 +160,14 @@ namespace Model
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 是否在岗
|
||||||
|
/// </summary>
|
||||||
|
public string IsPost
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
/// 是否本部
|
/// 是否本部
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool? IsOffice
|
public bool? IsOffice
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Model
|
||||||
|
{
|
||||||
|
public class UserListItem
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户信息集合
|
||||||
|
/// </summary>
|
||||||
|
public List<Model.UserItem> list
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -145,6 +145,7 @@
|
|||||||
<Compile Include="APIItem\HSSE\TrainingTaskItemItem.cs" />
|
<Compile Include="APIItem\HSSE\TrainingTaskItemItem.cs" />
|
||||||
<Compile Include="APIItem\HSSE\TrainRecordItem.cs" />
|
<Compile Include="APIItem\HSSE\TrainRecordItem.cs" />
|
||||||
<Compile Include="APIItem\UnitItem.cs" />
|
<Compile Include="APIItem\UnitItem.cs" />
|
||||||
|
<Compile Include="APIItem\UserListItem.cs" />
|
||||||
<Compile Include="APIItem\UserItem.cs" />
|
<Compile Include="APIItem\UserItem.cs" />
|
||||||
<Compile Include="APIItem\UserReadItem.cs" />
|
<Compile Include="APIItem\UserReadItem.cs" />
|
||||||
<Compile Include="BusinessColumn.cs" />
|
<Compile Include="BusinessColumn.cs" />
|
||||||
|
|||||||
@@ -464,5 +464,29 @@ namespace WebAPI.Controllers
|
|||||||
return responeData;
|
return responeData;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region 保存用户信息
|
||||||
|
/// <summary>
|
||||||
|
/// 保存用户信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="list">用户信息</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public Model.ResponeData postUserInfo([FromBody] Model.UserListItem list)
|
||||||
|
{
|
||||||
|
var responeData = new Model.ResponeData();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
responeData.message= APIUserService.SaveUserInfo(list);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
responeData.code = 0;
|
||||||
|
responeData.message = ex.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return responeData;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<SiteUrlToLaunchAfterPublish />
|
<SiteUrlToLaunchAfterPublish />
|
||||||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
||||||
<ExcludeApp_Data>False</ExcludeApp_Data>
|
<ExcludeApp_Data>False</ExcludeApp_Data>
|
||||||
<publishUrl>E:\Package\中国成达\SGGLAPI</publishUrl>
|
<publishUrl>E:\Package\中化成达\SGGLAPI</publishUrl>
|
||||||
<DeleteExistingFiles>True</DeleteExistingFiles>
|
<DeleteExistingFiles>True</DeleteExistingFiles>
|
||||||
<PrecompileBeforePublish>True</PrecompileBeforePublish>
|
<PrecompileBeforePublish>True</PrecompileBeforePublish>
|
||||||
<EnableUpdateable>True</EnableUpdateable>
|
<EnableUpdateable>True</EnableUpdateable>
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user