/** * 添加用户 用户标识: 2 -系统用户 1 -一般用户 0 -冻结用户 -1 -删除用户 系统用户和删除用户不在查询中显示其信息 * * @param dto */ public void insertUser(IBaseDTO dto) { // TODO 需要写出方法的具体实现 SysUser su = (SysUser) createPoByDTO(dto); SysUserInfo sui = (SysUserInfo) createSUIByDTO(dto); sui.setSysUser(su); dao.saveEntity(su); dao.saveEntity(sui); }
private SysUserInfo createSUIByDTO(IBaseDTO dto) { SysUserInfo sui = new SysUserInfo(); sui.setUserId( null != dto.get("userId") && !"".equals("userId") ? dto.get("userId").toString() : ""); sui.setRealName(null != dto.get("realName") ? dto.get("realName").toString() : ""); sui.setSexId(null != dto.get("sexId") ? dto.get("sexId").toString() : "1"); sui.setIdentityKind(null != dto.get("identityKind") ? dto.get("identityKind").toString() : ""); sui.setIdentityCard(null != dto.get("identityCard") ? dto.get("identityCard").toString() : ""); // TimeUtil a; sui.setBirthday( null != dto.get("birthday") && !"".equals(dto.get("birthday").toString()) ? TimeUtil.getTimeByStr(dto.get("birthday").toString(), "yyyy-MM-dd") : new Date()); // sui.setCountryId(null !=dto.get("countryId")?dto.get("countryId").toString():""); // sui.setProvinceId(null !=dto.get("provinceId")?dto.get("provinceId").toString():""); // sui.setQq(null !=dto.get("qq")?dto.get("qq").toString():""); // sui.setBloodType(null !=dto.get("bloodType")?dto.get("bloodType").toString():""); // sui.setAddress(null !=dto.get("address")?dto.get("address").toString():""); // sui.setPostalcode(null !=dto.get("postalcode")?dto.get("postalcode").toString():""); // sui.setMobile(null !=dto.get("mobile")?dto.get("mobile").toString():""); // sui.setFinishSchool(null !=dto.get("finishSchool")?dto.get("finishSchool").toString():""); // sui.setSpeciality(null !=dto.get("speciality")?dto.get("speciality").toString():""); // sui.setWorkId(null !=dto.get("workId")?dto.get("workId").toString():""); // sui.setHomepage(null !=dto.get("homepage")?dto.get("homepage").toString():""); return sui; }
private IBaseDTO createDTOByPo(SysUserInfo sui, IBaseDTO dto) { if (null != sui) { dto.set("realName", sui.getRealName()); dto.set("sexId", sui.getSexId()); dto.set("identityKind", sui.getIdentityKind()); dto.set("identityCard", sui.getIdentityCard()); dto.set( "birthday", null != sui.getBirthday() ? TimeUtil.getTheTimeStr(sui.getBirthday(), "yyyy-MM-dd") : "0000-00-00"); dto.set("countryId", sui.getCountryId()); dto.set("provinceId", sui.getProvinceId()); dto.set("qq", sui.getQq()); dto.set("bloodType", sui.getBloodType()); dto.set("address", sui.getAddress()); dto.set("postalcode", sui.getPostalcode()); dto.set("mobile", sui.getMobile()); dto.set("finishSchool", sui.getFinishSchool()); dto.set("speciality", sui.getSpeciality()); dto.set("workId", sui.getWorkId()); dto.set("homepage", sui.getHomepage()); } return dto; }