Search in sources :

Example 1 with ExStaffExperience

use of com.github.qinyou.example.model.ExStaffExperience in project my_curd by qinyou.

the class ExStaffController method addAction.

/**
 * 新增 action
 */
@Before(Tx.class)
public void addAction() {
    // 新增主表
    ExStaff exStaff = getBean(ExStaff.class, "exStaff");
    exStaff.setId(IdUtils.id()).setCreater(WebUtils.getSessionUsername(this)).setCreateTime(new Date()).save();
    // 新增 子表
    List<ExStaffEducation> exStaffEducations = getBeans(ExStaffEducation.class, "exStaffEducation");
    exStaffEducations.forEach(item -> item.setId(IdUtils.id()).setExStaffId(exStaff.getId()).setCreateTime(new Date()).setCreater(WebUtils.getSessionUsername(this)));
    Db.batchSave(exStaffEducations, exStaffEducations.size());
    List<ExStaffExperience> exStaffExperiences = getBeans(ExStaffExperience.class, "exStaffExperience");
    exStaffExperiences.forEach(item -> item.setId(IdUtils.id()).setExStaffId(exStaff.getId()).setCreateTime(new Date()).setCreater(WebUtils.getSessionUsername(this)));
    Db.batchSave(exStaffExperiences, exStaffExperiences.size());
    List<ExStaffFamily> exStaffFamilys = getBeans(ExStaffFamily.class, "exStaffFamily");
    exStaffFamilys.forEach(item -> item.setId(IdUtils.id()).setExStaffId(exStaff.getId()).setCreateTime(new Date()).setCreater(WebUtils.getSessionUsername(this)));
    Db.batchSave(exStaffFamilys, exStaffFamilys.size());
    renderSuccess(ADD_SUCCESS);
}
Also used : ExStaffFamily(com.github.qinyou.example.model.ExStaffFamily) ExStaff(com.github.qinyou.example.model.ExStaff) ExStaffExperience(com.github.qinyou.example.model.ExStaffExperience) ExStaffEducation(com.github.qinyou.example.model.ExStaffEducation) Date(java.util.Date) Before(com.jfinal.aop.Before)

Example 2 with ExStaffExperience

use of com.github.qinyou.example.model.ExStaffExperience in project my_curd by qinyou.

the class ExStaffController method newModel.

/**
 * 打开新增或者修改弹出框
 */
public void newModel() {
    String id = getPara("id");
    if (StringUtils.notEmpty(id)) {
        ExStaff exStaff = ExStaff.dao.findById(id);
        setAttr("exStaff", exStaff);
        List<ExStaffEducation> exStaffEducations = ExStaffEducation.dao.find("select * from ex_staff_education where exStaffId = ? order by ID ", id);
        setAttr("exStaffEducations", exStaffEducations);
        List<ExStaffExperience> exStaffExperiences = ExStaffExperience.dao.find("select * from ex_staff_experience where exStaffId = ? order by ID ", id);
        setAttr("exStaffExperiences", exStaffExperiences);
        List<ExStaffFamily> exStaffFamilys = ExStaffFamily.dao.find("select * from ex_staff_family where exStaffId = ? order by ID ", id);
        setAttr("exStaffFamilys", exStaffFamilys);
    }
    render("example/exStaff_form.ftl");
}
Also used : ExStaffFamily(com.github.qinyou.example.model.ExStaffFamily) ExStaff(com.github.qinyou.example.model.ExStaff) ExStaffExperience(com.github.qinyou.example.model.ExStaffExperience) ExStaffEducation(com.github.qinyou.example.model.ExStaffEducation)

Example 3 with ExStaffExperience

use of com.github.qinyou.example.model.ExStaffExperience in project my_curd by qinyou.

the class ExStaffController method updateAction.

/**
 * 修改 action
 */
@SuppressWarnings("Duplicates")
@Before(Tx.class)
public void updateAction() {
    // 修改 主表
    ExStaff exStaff = getBean(ExStaff.class, "exStaff");
    exStaff.setUpdater(WebUtils.getSessionUsername(this)).setUpdateTime(new Date()).update();
    // 新增或修改 子表
    List<ExStaffEducation> exStaffEducations = getBeans(ExStaffEducation.class, "exStaffEducation");
    exStaffEducations.forEach(item -> {
        item.setExStaffId(exStaff.getId());
        if (StringUtils.isEmpty(item.getId())) {
            item.setId(IdUtils.id()).setCreateTime(new Date()).setCreater(WebUtils.getSessionUsername(this)).save();
        } else {
            item.setUpdateTime(new Date()).setUpdater(WebUtils.getSessionUsername(this)).update();
        }
    });
    List<ExStaffExperience> exStaffExperiences = getBeans(ExStaffExperience.class, "exStaffExperience");
    exStaffExperiences.forEach(item -> {
        item.setExStaffId(exStaff.getId());
        if (StringUtils.isEmpty(item.getId())) {
            item.setId(IdUtils.id()).setCreateTime(new Date()).setCreater(WebUtils.getSessionUsername(this)).save();
        } else {
            item.setUpdateTime(new Date()).setUpdater(WebUtils.getSessionUsername(this)).update();
        }
    });
    List<ExStaffFamily> exStaffFamilys = getBeans(ExStaffFamily.class, "exStaffFamily");
    exStaffFamilys.forEach(item -> {
        item.setExStaffId(exStaff.getId());
        if (StringUtils.isEmpty(item.getId())) {
            item.setId(IdUtils.id()).setCreateTime(new Date()).setCreater(WebUtils.getSessionUsername(this)).save();
        } else {
            item.setUpdateTime(new Date()).setUpdater(WebUtils.getSessionUsername(this)).update();
        }
    });
    renderSuccess(UPDATE_SUCCESS);
}
Also used : ExStaffFamily(com.github.qinyou.example.model.ExStaffFamily) ExStaff(com.github.qinyou.example.model.ExStaff) ExStaffExperience(com.github.qinyou.example.model.ExStaffExperience) ExStaffEducation(com.github.qinyou.example.model.ExStaffEducation) Date(java.util.Date) Before(com.jfinal.aop.Before)

Aggregations

ExStaff (com.github.qinyou.example.model.ExStaff)3 ExStaffEducation (com.github.qinyou.example.model.ExStaffEducation)3 ExStaffExperience (com.github.qinyou.example.model.ExStaffExperience)3 ExStaffFamily (com.github.qinyou.example.model.ExStaffFamily)3 Before (com.jfinal.aop.Before)2 Date (java.util.Date)2