Search in sources :

Example 1 with Department

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;
}
Also used : Department(com.qlangtech.tis.manage.biz.dal.pojo.Department) DelegateControl4JsonPostMsgHandler(com.qlangtech.tis.runtime.module.misc.impl.DelegateControl4JsonPostMsgHandler) IControlMsgHandler(com.qlangtech.tis.runtime.module.misc.IControlMsgHandler) Validator(com.qlangtech.tis.plugin.annotation.Validator) Date(java.util.Date)

Example 2 with Department

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);
}
Also used : Department(com.qlangtech.tis.manage.biz.dal.pojo.Department)

Example 3 with 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));
}
Also used : Department(com.qlangtech.tis.manage.biz.dal.pojo.Department) Date(java.util.Date) DepartmentCriteria(com.qlangtech.tis.manage.biz.dal.pojo.DepartmentCriteria) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 4 with Department

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));
        }
    });
}
Also used : Department(com.qlangtech.tis.manage.biz.dal.pojo.Department) Validator(com.qlangtech.tis.plugin.annotation.Validator) DepartmentCriteria(com.qlangtech.tis.manage.biz.dal.pojo.DepartmentCriteria)

Example 5 with Department

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());
}
Also used : Department(com.qlangtech.tis.manage.biz.dal.pojo.Department) UsrDptRelationCriteria(com.qlangtech.tis.manage.biz.dal.pojo.UsrDptRelationCriteria) UsrDptRelation(com.qlangtech.tis.manage.biz.dal.pojo.UsrDptRelation) Func(com.qlangtech.tis.manage.spring.aop.Func)

Aggregations

Department (com.qlangtech.tis.manage.biz.dal.pojo.Department)14 DepartmentCriteria (com.qlangtech.tis.manage.biz.dal.pojo.DepartmentCriteria)5 Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)2 Func (com.qlangtech.tis.manage.spring.aop.Func)2 Validator (com.qlangtech.tis.plugin.annotation.Validator)2 Date (java.util.Date)2 UploadResource (com.qlangtech.tis.manage.biz.dal.pojo.UploadResource)1 UsrDptRelation (com.qlangtech.tis.manage.biz.dal.pojo.UsrDptRelation)1 UsrDptRelationCriteria (com.qlangtech.tis.manage.biz.dal.pojo.UsrDptRelationCriteria)1 AppDomainInfo (com.qlangtech.tis.manage.common.AppDomainInfo)1 Option (com.qlangtech.tis.manage.common.Option)1 Nullable (com.qlangtech.tis.pubhook.common.Nullable)1 IControlMsgHandler (com.qlangtech.tis.runtime.module.misc.IControlMsgHandler)1 DelegateControl4JsonPostMsgHandler (com.qlangtech.tis.runtime.module.misc.impl.DelegateControl4JsonPostMsgHandler)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 JSONTokener (org.json.JSONTokener)1