use of com.qlangtech.tis.manage.biz.dal.pojo.Department in project tis by qlangtech.
the class DepartmentAction method processDepartment.
private boolean processDepartment(Context context, Department dpt, IDepartmentProcess dptProcess, Object... validateRuleParams) {
//
Map<String, Validator.FieldValidators> validateRule = //
Validator.fieldsValidator(//
"name", new Validator.FieldValidators(Validator.require) {
@Override
public void setFieldVal(String val) {
dpt.setName(val);
}
}, //
"parentId", new Validator.FieldValidators(Validator.require, Validator.integer) {
@Override
public void setFieldVal(String val) {
dpt.setParentId(Integer.parseInt(val));
}
}, validateRuleParams);
// //////////////////
IControlMsgHandler handler = new DelegateControl4JsonPostMsgHandler(this, this.parseJsonPost());
if (!Validator.validate(handler, context, validateRule)) {
return false;
}
Department parentDpt = this.getDepartmentDAO().selectByPrimaryKey(dpt.getParentId());
dpt.setFullName("/" + parentDpt.getName() + "/" + dpt.getName());
dpt.setGmtCreate(new Date());
dpt.setGmtModified(new Date());
dpt.setLeaf(true);
dptProcess.process(dpt);
this.setBizResult(context, dpt);
return true;
}
use of com.qlangtech.tis.manage.biz.dal.pojo.Department in project tis by qlangtech.
the class OrgAuthorityAction method processDepartment.
/**
* @param
* @param
*/
public static void processDepartment(IDepartmentDAO departmentDAO, List<Department> dptlist, Integer dptId) {
Department department = departmentDAO.loadFromWriteDB(dptId);
if (department == null) {
return;
}
if (department.getParentId() == null) {
dptlist.add(department);
return;
}
processDepartment(departmentDAO, dptlist, department.getParentId());
dptlist.add(department);
}
use of com.qlangtech.tis.manage.biz.dal.pojo.Department in project tis by qlangtech.
the class BizlineAction method doAddBizline.
@Func(value = PermissionConstant.APP_DEPARTMENT_MANAGE)
public void doAddBizline(Context context) {
this.errorsPageShow(context);
final String name = this.getString("name");
if (StringUtils.isBlank(name)) {
this.addErrorMessage(context, "请填写业务线名称");
return;
}
DepartmentCriteria criteria = new DepartmentCriteria();
criteria.createCriteria().andIsLeaf(false).andNameEqualTo(name).andParentIdEqualTo(-1);
if (this.getDepartmentDAO().countByExample(criteria) > 0) {
this.addErrorMessage(context, "业务线:''" + name + "' 已经存在,不能重复添加");
return;
}
Department dpt = new Department();
dpt.setLeaf(false);
dpt.setName(name);
dpt.setFullName(name);
dpt.setGmtModified(new Date());
dpt.setGmtCreate(new Date());
dpt.setParentId(-1);
dpt.setDptId(this.getDepartmentDAO().insertSelective(dpt));
this.setBizResult(context, dpt);
this.addActionMessage(context, "业务线:'" + name + "' 添加成功");
// this.setBizResult(context, getAllBizDomain(false));
}
use of com.qlangtech.tis.manage.biz.dal.pojo.Department in project tis by qlangtech.
the class DepartmentAction method doUpdateDepartment.
/**
* 更新部门
*
* @param context
*/
public void doUpdateDepartment(Context context) {
Department department = new Department();
this.processDepartment(context, department, (dpt) -> {
if (dpt.getDptId() == null) {
throw new IllegalStateException("dpt.getDptId() can not be null");
}
final Integer dptId = dpt.getDptId();
try {
DepartmentCriteria criteria = new DepartmentCriteria();
criteria.createCriteria().andDptIdEqualTo(dptId).andIsLeaf(true);
dpt.setDptId(null);
if (this.getDepartmentDAO().updateByExampleSelective(dpt, criteria) > 0) {
DataxAction.cleanDepsCache();
this.addActionMessage(context, "更新部门:'" + dpt.getName() + "'");
} else {
this.addErrorMessage(context, "更新部门 '" + dpt.getName() + "' 失败");
}
} finally {
dpt.setDptId(dptId);
}
}, //
"dptId", new Validator.FieldValidators(Validator.require, Validator.integer) {
@Override
public void setFieldVal(String val) {
department.setDptId(Integer.parseInt(val));
}
});
}
use of com.qlangtech.tis.manage.biz.dal.pojo.Department in project tis by qlangtech.
the class UserAction method doChangeDepartment.
/**
* 用户部门更新
*
* @param context
*/
@Func(PermissionConstant.AUTHORITY_USER_MANAGE)
public void doChangeDepartment(Context context) {
String usrid = this.getString("usrid");
Integer selecteddptid = this.getInt("selecteddptid");
Assert.assertNotNull(usrid);
Assert.assertNotNull(selecteddptid);
UsrDptRelation usr = this.getUsrDptRelationDAO().loadFromWriteDB(usrid);
Assert.assertNotNull(usr);
Department department = this.getDepartmentDAO().loadFromWriteDB(selecteddptid);
Assert.assertNotNull(department);
UsrDptRelationCriteria criteria = new UsrDptRelationCriteria();
criteria.createCriteria().andUsrIdEqualTo(usrid);
UsrDptRelation record = new UsrDptRelation();
record.setDptName(department.getFullName());
record.setDptId(department.getDptId());
record.setUpdateTime(new Date());
this.getUsrDptRelationDAO().updateByExampleSelective(record, criteria);
this.addActionMessage(context, "已经将用户“" + usr.getUserName() + "”归属到新的部门:" + department.getFullName());
}
Aggregations