|
|
|
@ -26,22 +26,17 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
public class LoginPersonController extends Controller {
|
|
|
|
|
//实例化model
|
|
|
|
|
LoginPersonModel model = new LoginPersonModel();
|
|
|
|
|
|
|
|
|
|
LoginPersonModel lm = new LoginPersonModel();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 验证登录
|
|
|
|
|
*
|
|
|
|
|
* @param username
|
|
|
|
|
* @param password
|
|
|
|
|
* @param captcha
|
|
|
|
|
* @param roles 是不是登录的账号拥有指定角色?如果是多个角色,那么中间用逗号隔开
|
|
|
|
|
* 装备验收专家抽取管理员: roles需传入277
|
|
|
|
|
* 目前丁虹元老师有装备验收专家抽取管理员的角色
|
|
|
|
|
* 测试账号 dinghongyuan 123456
|
|
|
|
|
* @param username 用户名
|
|
|
|
|
* @param password 密码(经过加密后的密文)
|
|
|
|
|
* @param captcha 验证码
|
|
|
|
|
*/
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
public void doLogin(String username, String password, String captcha, String roles) {
|
|
|
|
|
public void doLogin(String username, String password, String captcha) {
|
|
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
|
|
if (StrKit.isBlank(captcha)) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
@ -168,36 +163,14 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
int identity_id = Integer.parseInt(loginMap.get("identity_id").toString());
|
|
|
|
|
String person_id = loginMap.get("person_id").toString();
|
|
|
|
|
if (identity_id == 5 || identity_id == 6) {
|
|
|
|
|
List<Record> list = model.getPersonDuty(person_id);
|
|
|
|
|
if (list.size() == 0) {
|
|
|
|
|
List<Record> list = lm.getPersonDuty(person_id);
|
|
|
|
|
if (list.isEmpty()) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("redirect", true);
|
|
|
|
|
resultJson.put("msg", "没有后台管理权限!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//如果前台指定必须具备某些角色才能使用这个登录口的话
|
|
|
|
|
if (!StrKit.isBlank(roles)) {
|
|
|
|
|
//1、需要具备的角色
|
|
|
|
|
List<Integer> roleList = Arrays.stream(roles.split(","))
|
|
|
|
|
.map(Integer::parseInt) // 将字符串转换为整数
|
|
|
|
|
.collect(Collectors.toList()); // 收集成列表
|
|
|
|
|
//2、人员已有的角色
|
|
|
|
|
List<Integer> existRole = new ArrayList<>();
|
|
|
|
|
for (Record record : list) {
|
|
|
|
|
existRole.add(record.getInt("duties_id"));
|
|
|
|
|
}
|
|
|
|
|
//3、求交集
|
|
|
|
|
roleList.retainAll(existRole);
|
|
|
|
|
if (roleList.isEmpty()) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("redirect", true);
|
|
|
|
|
resultJson.put("msg", "登录失败,当前登录页面要求指定角色才能登录成功!");
|
|
|
|
|
renderJson(resultJson);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//防止用户攻击修改Cookie
|
|
|
|
@ -250,7 +223,7 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
String operator = SessionKit.get(getRequest(), getResponse(), "person_id");
|
|
|
|
|
//客户端ip_address
|
|
|
|
|
String ip_address = IpUtil.getIpAddr(getRequest());
|
|
|
|
|
model.changePwd(operator, ip_address, "123456", person_id);
|
|
|
|
|
lm.changePwd(operator, ip_address, "123456", person_id);
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(true, "重置密码成功完成!"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -270,7 +243,7 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
String ip_address = IpUtil.getIpAddr(getRequest());
|
|
|
|
|
|
|
|
|
|
//检查旧密码是不是正确
|
|
|
|
|
boolean success = model.checkPwdByPersonId(person_id, old_pwd);
|
|
|
|
|
boolean success = lm.checkPwdByPersonId(person_id, old_pwd);
|
|
|
|
|
//写入新密码
|
|
|
|
|
if (!success) {
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(false, "输入的旧密码不正确!"));
|
|
|
|
@ -280,7 +253,7 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(false, "输入的密码不被接受,应该输入:长度大于等于6位,并且包含大小字母和数字的组合!"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
model.changePwd(person_id, ip_address, new_pwd, person_id);
|
|
|
|
|
lm.changePwd(person_id, ip_address, new_pwd, person_id);
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(true, "修改密码成功完成!"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -293,7 +266,7 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
public void getLoginPersonInfo() {
|
|
|
|
|
JSONObject resultJson = new JSONObject();
|
|
|
|
|
String personId = SessionKit.get(getRequest(), getResponse(), "person_id");
|
|
|
|
|
Record record = model.getLoginInfoByPersonId(personId);
|
|
|
|
|
Record record = lm.getLoginInfoByPersonId(personId);
|
|
|
|
|
if (record == null) {
|
|
|
|
|
resultJson.put("success", false);
|
|
|
|
|
resultJson.put("message", "获取登录信息异常!");
|
|
|
|
@ -317,7 +290,7 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
@IsSysAdminInterface({"1"})
|
|
|
|
|
@IsNumericInterface({"page", "limit"})
|
|
|
|
|
public void getPrintCityManager(int page, int limit) {
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(model.getPrintCityManager(page, limit));
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(lm.getPrintCityManager(page, limit));
|
|
|
|
|
renderJson(CommonUtil.renderJsonForLayUI(rs));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -334,7 +307,7 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
//转成 json对象
|
|
|
|
|
JSONObject jo = CommonUtil.getJsonFile(filePath);
|
|
|
|
|
//导出
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(model.getPrintCityManager(1, 10000));
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(lm.getPrintCityManager(1, 10000));
|
|
|
|
|
String excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xls";
|
|
|
|
|
ExcelExportUtil.export(rs, jo, excelFile);
|
|
|
|
|
//提供下载
|
|
|
|
@ -353,7 +326,7 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
@IsSysAdminInterface({"1", "2"})
|
|
|
|
|
@IsNumericInterface({"page", "limit"})
|
|
|
|
|
public void getPrintCityBureau(int page, int limit) {
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(model.getPrintCityBureau(page, limit));
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(lm.getPrintCityBureau(page, limit));
|
|
|
|
|
renderJson(CommonUtil.renderJsonForLayUI(rs));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -370,7 +343,7 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
//转成 json对象
|
|
|
|
|
JSONObject jo = CommonUtil.getJsonFile(filePath);
|
|
|
|
|
//导出
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(model.getPrintCityBureau(1, 10000));
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(lm.getPrintCityBureau(1, 10000));
|
|
|
|
|
String excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xls";
|
|
|
|
|
ExcelExportUtil.export(rs, jo, excelFile);
|
|
|
|
|
//提供下载
|
|
|
|
@ -389,7 +362,7 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
@IsSysAdminInterface({"1", "2", "3"})
|
|
|
|
|
@IsNumericInterface({"page", "limit"})
|
|
|
|
|
public void getPrintAreaManager(int page, int limit) {
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(model.getPrintAreaManager(page, limit));
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(lm.getPrintAreaManager(page, limit));
|
|
|
|
|
renderJson(CommonUtil.renderJsonForLayUI(rs));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -406,7 +379,7 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
//转成 json对象
|
|
|
|
|
JSONObject jo = CommonUtil.getJsonFile(filePath);
|
|
|
|
|
//导出
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(model.getPrintAreaManager(1, 10000));
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(lm.getPrintAreaManager(1, 10000));
|
|
|
|
|
String excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xls";
|
|
|
|
|
ExcelExportUtil.export(rs, jo, excelFile);
|
|
|
|
|
//提供下载
|
|
|
|
@ -427,7 +400,7 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
@EmptyInterface({"area_id"})
|
|
|
|
|
@IsNumericInterface({"page", "limit"})
|
|
|
|
|
public void getPrintAreaBureau(int page, int limit, String area_id) {
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(model.getPrintAreaBureau(page, limit, area_id));
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(lm.getPrintAreaBureau(page, limit, area_id));
|
|
|
|
|
renderJson(CommonUtil.renderJsonForLayUI(rs));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -447,7 +420,7 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
//转成 json对象
|
|
|
|
|
JSONObject jo = CommonUtil.getJsonFile(filePath);
|
|
|
|
|
//导出
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(model.getPrintAreaBureau(1, 10000, area_id));
|
|
|
|
|
Page<Record> rs = CommonUtil.ConvertLoginRs(lm.getPrintAreaBureau(1, 10000, area_id));
|
|
|
|
|
String excelFile = excelPath + "excelTemp/" + UUID.randomUUID().toString().toUpperCase() + ".xls";
|
|
|
|
|
ExcelExportUtil.export(rs, jo, excelFile);
|
|
|
|
|
//提供下载
|
|
|
|
@ -508,7 +481,7 @@ public class LoginPersonController extends Controller {
|
|
|
|
|
@IsLoginInterface({})
|
|
|
|
|
public void updateTelephoneEmail(String telephone, String email) {
|
|
|
|
|
String personId = SessionKit.get(getRequest(), getResponse(), "person_id");
|
|
|
|
|
model.updateTelephoneEmail(personId, telephone, email);
|
|
|
|
|
lm.updateTelephoneEmail(personId, telephone, email);
|
|
|
|
|
Kv kv = Kv.create();
|
|
|
|
|
kv.set("success", true);
|
|
|
|
|
kv.set("message", "保存成功!");
|
|
|
|
|