Search in sources :

Example 1 with Preparation

use of com.cas.sim.tis.entity.Preparation in project TeachingInSimulation by ScOrPiOzzy.

the class PreparationServiceImpl method findPreparationByTaskIdAndCreator.

@Override
public Preparation findPreparationByTaskIdAndCreator(Integer cid, int creator) {
    Condition condition = new Condition(Preparation.class);
    Criteria criteria = condition.createCriteria();
    criteria.andEqualTo("catalogId", cid);
    criteria.andEqualTo("creator", creator);
    criteria.andEqualTo("del", 0);
    List<Preparation> preparations = findByCondition(condition);
    if (preparations.size() == 1) {
        return preparations.get(0);
    } else if (preparations.size() == 0) {
        return null;
    } else {
        LOG.warn("关联编号{},创建人{}的有效备课信息应仅有一条!", cid, creator);
        return preparations.get(0);
    }
}
Also used : Condition(tk.mybatis.mapper.entity.Condition) Preparation(com.cas.sim.tis.entity.Preparation) Criteria(tk.mybatis.mapper.entity.Example.Criteria)

Example 2 with Preparation

use of com.cas.sim.tis.entity.Preparation in project TeachingInSimulation by ScOrPiOzzy.

the class PreparationDetail method loadPreparation.

private void loadPreparation() {
    int cid = task.getId();
    int role = Session.get(Session.KEY_LOGIN_ROLE);
    int creator = Session.get(Session.KEY_LOGIN_ID);
    if (RoleConst.STUDENT == role) {
        User user = SpringUtil.getBean(UserAction.class).findUserByID(creator);
        creator = user.getTeacherId();
    }
    // 查询是否存在自定义备课内容
    preparation = SpringUtil.getBean(PreparationAction.class).findPreparationByTaskIdAndCreator(cid, creator);
    // 查询是否存在模版备课内容
    if (preparation == null) {
        // XXX 暂时规定默认备课模版创建人编号为0
        preparation = SpringUtil.getBean(PreparationAction.class).findPreparationByTaskIdAndCreator(cid, 0);
    }
    if (preparation == null && RoleConst.TEACHER == role) {
        preparation = new Preparation();
        preparation.setCatalogId(cid);
        preparation.setCreator(creator);
        preparation = SpringUtil.getBean(PreparationAction.class).addPreparation(preparation);
    }
}
Also used : UserAction(com.cas.sim.tis.action.UserAction) User(com.cas.sim.tis.entity.User) Preparation(com.cas.sim.tis.entity.Preparation)

Aggregations

Preparation (com.cas.sim.tis.entity.Preparation)2 UserAction (com.cas.sim.tis.action.UserAction)1 User (com.cas.sim.tis.entity.User)1 Condition (tk.mybatis.mapper.entity.Condition)1 Criteria (tk.mybatis.mapper.entity.Example.Criteria)1