use of com.github.qinyou.example.model.ExStaffFamily 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);
}
use of com.github.qinyou.example.model.ExStaffFamily 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");
}
use of com.github.qinyou.example.model.ExStaffFamily 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);
}
Aggregations