Basf_TCC11/HJGL/WebApi/Controllers/UserController.cs

131 lines
4.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using BLL;
using System;
using System.Linq;
using System.Web.Http;
namespace WebAPI.Controllers
{
/// <summary>
/// 用户
/// </summary>
public class UserController : ApiController
{
#region
/// <summary>
/// 登录方法
/// </summary>
/// <param name="userInfo"></param>
/// <returns></returns>
[HttpPost]
public Model.ResponeData postLoginOn([FromBody] Model.UserItem userInfo)
{
//登录方法 Model.UserItem
var responeData = new Model.ResponeData
{
message = "账号密码不匹配!"
};
try
{
////用户登录
var user = APIUserService.UserLogOn(userInfo);
if (user != null)
{
responeData.message = "登录成功!";
responeData.data = user;
}
//else 暂不用
//{
// // 焊工登录
// var user1 = APIWelderService.PersonLogOn(userInfo);
// if (user1 != null)
// {
// responeData.message = "登录成功!";
// responeData.code = 2;
// responeData.data = user1;
// }
//}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region userid获取用户信息
/// <summary>
/// 根据userid获取用户信息
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public Model.ResponeData getUserByUserId(string userId)
{
var responeData = new Model.ResponeData();
try
{
responeData.data = APIUserService.getUserByUserId(userId);
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region ID和选择的项目获取单位类型(12345)
/// <summary>
/// 根据登陆用户的单位ID和选择的项目获取单位类型(1、建设方2、总承包商3、监理4、检测5、施工)
/// </summary>
/// <param name="projectId">项目ID</param>
/// <param name="unitId">单位ID</param>
/// <returns></returns>
public Model.ResponeData getUserInfo(string projectId, string unitId)
{
var responeData = new Model.ResponeData();
try
{
responeData.data = APIUserService.getUserInfo(projectId, unitId);
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
#region
/// <summary>
/// 获取项目区域的用户列表
/// </summary>
/// <param name="projectArea">项目区域</param>
/// <returns></returns>
public Model.ResponeData getUserListByProjectArea(string projectArea)
{
var responeData = new Model.ResponeData();
try
{
responeData.data = APIUserService.getUserListByProjectArea(projectArea);
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
#endregion
}
}