[HandlerLogin]
public class UserInfoController : BaseController<UserInfo, UserInfoV>
{
UserInfoDal UserInfoDal = new UserInfoDal();
// GET: Administration/UserInfo
public ActionResult Index()
{
return View();
}
public ActionResult Edit()
{
return View();
}
public override ActionResult GetPageListForSQL(FormCollection collection)
{
JObject obj = new JObject();
try
{
UserInfoV t = new UserInfoV();
TryUpdateModel<UserInfoV>(t, collection);
int CurrentPage = Convert.ToInt32(collection["page"]);
int limit = Convert.ToInt32(collection["limit"]);
PageDataView<UserInfoV> dailies = UserInfoDal.GetPageListForSQL(CurrentPage, limit, t);
LayUIDataResult<UserInfoV> layUIDataResult = new LayUIDataResult<UserInfoV>()
{
code = 0,
count = dailies.TotalNum,
msg = "",
data = dailies.Items.ToList()
};
obj.Add("code", "0");
obj.Add("msg", "成功");
obj.Add("data", dailies.ToJson());
return Json(layUIDataResult, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
obj.Add("code", "-1");
obj.Add("msg", ex.ToString());
LoggerHelper._.Error(ex.ToString());
}
return Json("", JsonRequestBehavior.AllowGet);
}
/// <summary>
/// 新增、修改
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public ActionResult InsertForUpdate2(UserInfoV t)
{
try
{
if (t.IsEnable == null)
{
t.IsEnable = 0;
}
int res = UserInfoDal.InsertForUpdate(t);
return Content(res.ToString());
}
catch (Exception ex)
{
LoggerHelper._.Error(ex.ToString());
return Content("0");
}
}
/// <summary>
/// 删除用户 逻辑删除
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public ActionResult LogicDeleteBatch(List<UserInfo> list)
{
try
{
int res = UserInfoDal.LogicDeleteBatch(list);
return Content(res.ToString());
}
catch (Exception ex)
{
LoggerHelper._.Error(ex.ToString());
return Content("0");
}
}
public override ActionResult UpdateNotNull(UserInfo t)
{
ResponseResult result = new ResponseResult();
result.code = 0;
result.msg = "成功";
try
{
bool res = UserInfoDal.UpdateNotNull(t);
result.data = res;
return Json(result, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LoggerHelper._.Error(ex.ToString());
result.code = -1;
result.msg = ex.Message;
return Json(result, JsonRequestBehavior.AllowGet);
}
}
[HttpPost]
public override ActionResult QueryFirstOrDefaultView(FormCollection collection)
{
try
{
UserInfoV t = new UserInfoV();
TryUpdateModel<UserInfoV>(t, collection);
UserInfoV res = UserInfoDal.QueryFirstOrDefaultView(t);
return Json(res, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LoggerHelper._.Error(ex.ToString());
return Json("", JsonRequestBehavior.AllowGet);
}
}
/// <summary>
/// 是否存在 工号
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
public ActionResult IsExist(UserInfoV model)
{
try
{
UserInfoV t = new UserInfoV();
//TryUpdateModel<UserInfoV>(t, collection);
List<UserInfoV> res = UserInfoDal.QueryForSQL(model);
string b = (res == null || res.Where(p => p.Id != model.Id).Count() == 0) ? "0" : "1";
return Content(b);
}
catch (Exception ex)
{
LoggerHelper._.Error(ex.ToString());
return Content("0");
}
}
/// <summary>
/// 验证原密码是否正确
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
public ActionResult OriginalPassword(UserInfoV model)
{
ResponseResult result = new ResponseResult();
result.code = 0;
result.msg = "成功";
try
{
UserInfo userInfo = CacheObjHelper.GetUserInfo();
string pwd = EncryptionHelper.GetUserPwd(model.Password);
result.data = userInfo;
if (userInfo.Password != pwd)
{
result.code = -1;
result.msg = "原密码错误";
}
return Json(result, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
LoggerHelper._.Error(ex.ToString());
result.code = -1;
result.msg = ex.Message;
return Json(result, JsonRequestBehavior.AllowGet);
}
}
/// <summary>
/// 初始化密码
/// </summary>
/// <returns></returns>
[HttpPost]
public virtual ActionResult InitializationPassword(UserInfo t)
{
try
{
UserInfo userInfo = CacheObjHelper.GetUserInfo();
t.LastModifyBy = userInfo.UserName + "|" + userInfo.Id;
t.LastModifyTime = DateTime.Now;
t.Password = EncryptionHelper.GetUserPwd("123456");
bool res = UserInfoDal.UpdateNotNull(t);
return Content(res.ToString());
}
catch (Exception ex)
{
LoggerHelper._.Error(ex.ToString());
return Content("false");
}
}
/// <summary>
/// 修改角色
/// </summary>
/// <param name="t"></param>
/// <returns></returns>
//public ActionResult ExecuteUpdateRole(UserInfoV t)
//{
// try
// {
// int res = UserInfoDal.ExecuteUpdateRole(t);
// return Content(res.ToString());
// }
// catch (Exception ex)
// {
// LoggerHelper._.Error(ex.ToString());
// return Content("0");
// }
//}
}