com.jeesuite.common.util.BeanUtils Java Examples
The following examples show how to use
com.jeesuite.common.util.BeanUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DepartmentController.java From oneplatform with Apache License 2.0 | 6 votes |
@ApiOperation(value = "保存") @RequestMapping(value = "save", method = RequestMethod.POST) public @ResponseBody WrapperResponse<String> addDepartment(@RequestBody DepartmentParam param) { if(param.getCompanyId() == null || param.getCompanyId() == 0){ throw new JeesuiteBaseException(ExceptionCode.REQUEST_PARAM_REQUIRED.code, "请先选择公司"); } DepartmentEntity entity = BeanUtils.copy(param, DepartmentEntity.class); if (param.getId() == null || param.getId() == 0) { entity.setCreatedAt(new Date()); entity.setCreatedBy(LoginContext.getIntFormatUserId()); departmentService.addDepartment(entity); } else { entity.setUpdatedAt(new Date()); entity.setUpdatedBy(LoginContext.getIntFormatUserId()); departmentService.updateDepartment(entity); } return new WrapperResponse<>(); }
Example #2
Source File: EmployeeController.java From oneplatform with Apache License 2.0 | 6 votes |
@ApiOperation(value = "新增") @RequestMapping(value = "add", method = RequestMethod.POST) public @ResponseBody WrapperResponse<String> addEmployee(@RequestBody EmployeeParam param) { if(param.getDepartmentId() == null || param.getDepartmentId() == 0){ throw new JeesuiteBaseException(ExceptionCode.REQUEST_PARAM_REQUIRED.code, "请先选择所在部门"); } if(param.getPositionId() == null || param.getPositionId() == 0){ throw new JeesuiteBaseException(ExceptionCode.REQUEST_PARAM_REQUIRED.code, "请先选择职位"); } EmployeeEntity entity = BeanUtils.copy(param, EmployeeEntity.class); entity.setCreatedAt(new Date()); entity.setCreatedBy(LoginContext.getIntFormatUserId()); employeeService.addEmployee(entity,param.getDepartmentId(),param.getPositionId()); return new WrapperResponse<>(); }
Example #3
Source File: AppAdminController.java From jeesuite-config with Apache License 2.0 | 6 votes |
@RequestMapping(value = "update", method = RequestMethod.POST) public ResponseEntity<WrapperResponseEntity> updateApp(@RequestBody AddOrEditAppRequest addAppRequest){ SecurityUtil.requireSuperAdmin(); AppEntity app = appMapper.selectByPrimaryKey(addAppRequest.getId()); if(app == null){ throw new JeesuiteBaseException(1002, "应用不存在"); } AppEntity appEntity = BeanUtils.copy(addAppRequest, AppEntity.class); if(addAppRequest.getMasterUid() != null && addAppRequest.getMasterUid() > 0 && !addAppRequest.getMasterUid().equals(app.getMasterUid())){ UserEntity master = userMapper.selectByPrimaryKey(addAppRequest.getMasterUid()); appEntity.setMaster(master.getName()); } appMapper.updateByPrimaryKeySelective(appEntity); return new ResponseEntity<WrapperResponseEntity>(new WrapperResponseEntity(true),HttpStatus.OK); }
Example #4
Source File: CompanyController.java From oneplatform with Apache License 2.0 | 6 votes |
@ApiOperation(value = "保存总公司信息") @RequestMapping(value = "save", method = RequestMethod.POST) public @ResponseBody WrapperResponse<String> addCompany(@RequestBody CompanyParam param) { if(param.getBranch()){ AssertUtil.notNull(companyService.findHeadCompany(),"请先保存总公司信息"); } CompanyEntity entity = BeanUtils.copy(param, CompanyEntity.class); if(param.getId() == null || param.getId() == 0){ entity.setCreatedAt(new Date()); entity.setCreatedBy(LoginContext.getIntFormatUserId()); companyService.addCompany(entity); }else{ entity.setUpdatedAt(new Date()); entity.setUpdatedBy(LoginContext.getIntFormatUserId()); companyService.updateCompany(entity); } return new WrapperResponse<>(); }
Example #5
Source File: AppAdminController.java From jeesuite-config with Apache License 2.0 | 6 votes |
@RequestMapping(value = "add", method = RequestMethod.POST) public ResponseEntity<WrapperResponseEntity> addApp(@RequestBody AddOrEditAppRequest addAppRequest){ SecurityUtil.requireSuperAdmin(); if(addAppRequest.getMasterUid() == null || addAppRequest.getMasterUid() == 0){ throw new JeesuiteBaseException(1002, "请选择项目负责人"); } if(appMapper.findByName(addAppRequest.getName()) != null){ throw new JeesuiteBaseException(1002, "应用["+addAppRequest.getName()+"]已存在"); } AppEntity appEntity = BeanUtils.copy(addAppRequest, AppEntity.class); // UserEntity master = userMapper.selectByPrimaryKey(addAppRequest.getMasterUid()); appEntity.setMaster(master.getName()); appMapper.insertSelective(appEntity); return new ResponseEntity<WrapperResponseEntity>(new WrapperResponseEntity(true),HttpStatus.OK); }
Example #6
Source File: CompanyService.java From oneplatform with Apache License 2.0 | 6 votes |
public void addCompany(CompanyEntity entity) { CompanyEntity headCompany = companyMapper.findHeadCompany(); if(headCompany == null){ entity.setIsBranch(false); }else{ entity.setIsBranch(true); CompanyEntity sameNameCompany = companyMapper.findByName(entity.getName()); if(sameNameCompany != null){ if(sameNameCompany.getInActive())throw new JeesuiteBaseException(ExceptionCode.RECORD_EXISTED.code,"该子公司已存在"); BeanUtils.copy(entity, sameNameCompany); sameNameCompany.setInActive(true); companyMapper.updateByPrimaryKeySelective(sameNameCompany); return ; } } companyMapper.insertSelective(entity); }
Example #7
Source File: PermissionService.java From oneplatform with Apache License 2.0 | 6 votes |
@Transactional public void updateResource(Integer currentUserId, UpdateResourceParam param) { //TODO 判重 PermissionResourceEntity entity = permissionResourceMapper.selectByPrimaryKey(param.getId()); AssertUtil.notNull(entity); BeanUtils.copy(param, entity); ModuleEntity module = moduleMapper.selectByPrimaryKey(entity.getId()); entity.buildPermssionCode(module); entity.setUpdatedBy(currentUserId); entity.setUpdatedAt(new Date()); permissionResourceMapper.updateByPrimaryKey(entity); // if(param.getApiIds() != null && !param.getApiIds().isEmpty()){ permissionInternalService.updateSubordinateRelationsByParent(entity.getId(), param.getApiIds(), entity.getPlatformType(), SubRelationType.ApiToMenu); } }
Example #8
Source File: PermissionService.java From oneplatform with Apache License 2.0 | 6 votes |
@Transactional public void updateUserGroup(Integer currentUserId, UpdateUserGroupParam param) { //TODO 判重(平台、公司、部门维度) UserGroupEntity entity = userGroupMapper.selectByPrimaryKey(param.getId()); AssertUtil.notNull(entity); BeanUtils.copy(param, entity); entity.setUpdatedBy(currentUserId); entity.setUpdatedAt(new Date()); userGroupMapper.updateByPrimaryKeySelective(entity); //权限组 permissionInternalService.updateGrantRelations(param.getId(), param.getPermGroupIds(), param.getPlatformType(), GrantRelationType.PermGroupToUserGroup); //额外权限 List<Integer> extSourceIds = new ArrayList<>(); if(param.getExtrMenuIds() != null)extSourceIds.addAll(param.getExtrMenuIds()); if(param.getExtrApiIds() != null)extSourceIds.addAll(param.getExtrApiIds()); permissionInternalService.updateGrantRelations(param.getId(), param.getPermGroupIds(), param.getPlatformType(), GrantRelationType.PermToUserGroup); }
Example #9
Source File: AccountService.java From oneplatform with Apache License 2.0 | 6 votes |
@Transactional public void addAccount(int operUserId, AccountParam param) { AccountEntity existEntity = accountMapper.findByLoginName(param.getMobile()); AssertUtil.isNull(existEntity, "手机号码已存在"); existEntity = accountMapper.findByLoginName(param.getEmail()); AssertUtil.isNull(existEntity, "邮箱已存在"); existEntity = accountMapper.findByLoginName(param.getUsername()); AssertUtil.isNull(existEntity, "用户名已存在"); AccountEntity entity = BeanUtils.copy(param, AccountEntity.class); entity.setEnabled(true); entity.setCreatedAt(new Date()); entity.setCreatedBy(operUserId); entity.setPassword(AccountEntity.encryptPassword(param.getMobile().substring(5))); accountMapper.insertSelective(entity); }
Example #10
Source File: UserInfoController.java From oneplatform with Apache License 2.0 | 5 votes |
@ApiOperation(value = "更新用户") @RequestMapping(value = "update", method = RequestMethod.POST) public @ResponseBody WrapperResponse<String> updateUserInfo(@RequestBody UserInfoParam param) { UserInfoEntity entity = BeanUtils.copy(param, UserInfoEntity.class); //entity.setUpdatedAt(new Date()); //entity.setUpdatedBy(LoginContext.getIntFormatUserId()); userInfoService.updateUserInfo(entity); return new WrapperResponse<>(); }
Example #11
Source File: BeanUtilTest.java From jeesuite-libs with Apache License 2.0 | 5 votes |
public static void main(String[] args) { User user = new User(); user.setName("小伙子"); user.setMobile("13800138000"); user.setFather(new User(1000, "你爹")); BaseUser user2 = BeanUtils.copy(user, BaseUser.class); System.out.println(JsonUtils.toPrettyJson(user2)); }
Example #12
Source File: ConfigAdminController.java From jeesuite-config with Apache License 2.0 | 5 votes |
@RequestMapping(value = "add", method = RequestMethod.POST) @Transactional public ResponseEntity<WrapperResponseEntity> addConfig(@RequestBody AddOrEditConfigRequest addRequest){ if(!addRequest.getGlobal() && addRequest.getAppIds() == null){ throw new JeesuiteBaseException(4001,"非全局绑定应用不能为空"); } if(StringUtils.isBlank(addRequest.getEnv())){ throw new JeesuiteBaseException(4001,"绑定环境profile不能为空"); } if(addRequest.getType().intValue() == 2 && StringUtils.isBlank(addRequest.getName())){ throw new JeesuiteBaseException(4001,"配置项名称不能空"); } if(addRequest.getGlobal()){ SecurityUtil.requireSuperAdmin(); }else{ SecurityUtil.requireAllPermission(addRequest.getEnv(),addRequest.getAppIds(),GrantOperate.RW); } // if(StringUtils.isNotBlank(addRequest.getName()) // && appconfigMapper.findSameByName(addRequest.getEnv(), appId, addRequest.getName()) != null){ // throw new JeesuiteBaseException(4001,"配置名称已经存在"); // } AppconfigEntity entity = BeanUtils.copy(addRequest, AppconfigEntity.class); entity.setAppIds(StringUtils.join(addRequest.getAppIds(),",")); entity.setCreatedBy(SecurityUtil.getLoginUserInfo().getName()); entity.setCreatedAt(new Date()); entity.setUpdatedAt(entity.getCreatedAt()); entity.setUpdatedBy(entity.getCreatedBy()); encryptPropItemIfRequired(entity); // appconfigMapper.insertSelective(entity); return new ResponseEntity<WrapperResponseEntity>(new WrapperResponseEntity(true),HttpStatus.OK); }
Example #13
Source File: PermissionService.java From oneplatform with Apache License 2.0 | 5 votes |
@Transactional public void updatePermGroup(Integer currentUserId, UpdatePermGroupParam param){ PermissionGroupEntity entity = permissionGroupMapper.selectByPrimaryKey(param.getId()); AssertUtil.notNull(entity); BeanUtils.copy(param, entity); entity.setUpdatedBy(currentUserId); entity.setUpdatedAt(new Date()); permissionGroupMapper.updateByPrimaryKeySelective(entity); // permissionInternalService.updateSubordinateRelationsByParent(param.getId(), param.getApiIds(), param.getPlatformType(), SubRelationType.PermToPermGroup); }
Example #14
Source File: PermissionService.java From oneplatform with Apache License 2.0 | 5 votes |
@Transactional public void addResource(Integer currentUserId, AddResourceParam param) { //TODO 判重 PermissionResourceEntity entity = BeanUtils.copy(param, PermissionResourceEntity.class); ModuleEntity module = moduleMapper.selectByPrimaryKey(entity.getId()); entity.buildPermssionCode(module); entity.setCreatedAt(new Date()); entity.setCreatedBy(currentUserId); permissionResourceMapper.insertSelective(entity); // if(param.getApiIds() != null && !param.getApiIds().isEmpty()){ permissionInternalService.updateSubordinateRelationsByParent(entity.getId(), param.getApiIds(), param.getPlatformType(), SubRelationType.ApiToMenu); } }
Example #15
Source File: ArticleController.java From oneplatform with Apache License 2.0 | 5 votes |
@ApiOperation(value = "更新文章") @RequestMapping(value = "update", method = RequestMethod.POST) @ApiPermOptions(perms = PermissionType.Authorized) public @ResponseBody WrapperResponse<String> updateCmsArticle(@RequestBody ArticleParam param) { ArticleEntity entity = BeanUtils.copy(param, ArticleEntity.class); entity.setUpdatedAt(new Date()); entity.setUpdatedBy(LoginContext.getIntFormatUserId()); cmsArticleService.updateCmsArticle(entity); return new WrapperResponse<>(); }
Example #16
Source File: ArticleController.java From oneplatform with Apache License 2.0 | 5 votes |
@ApiOperation(value = "新增文章") @RequestMapping(value = "add", method = RequestMethod.POST) @ApiPermOptions(perms = PermissionType.Authorized) public @ResponseBody WrapperResponse<String> addCmsArticle(@RequestBody ArticleParam param) { ArticleEntity entity = BeanUtils.copy(param, ArticleEntity.class); entity.setCreatedAt(new Date()); entity.setCreatedBy(LoginContext.getIntFormatUserId()); cmsArticleService.addCmsArticle(entity); return new WrapperResponse<>(); }
Example #17
Source File: CompanyService.java From oneplatform with Apache License 2.0 | 5 votes |
public void updateCompany(CompanyEntity entity) { CompanyEntity originEntity = companyMapper.selectByPrimaryKey(entity.getId()); AssertUtil.notNull(originEntity); BeanUtils.copy(entity, originEntity); originEntity.setIsBranch(false); companyMapper.updateByPrimaryKey(originEntity); }
Example #18
Source File: EmployeeController.java From oneplatform with Apache License 2.0 | 5 votes |
@ApiOperation(value = "更新") @RequestMapping(value = "update", method = RequestMethod.POST) public @ResponseBody WrapperResponse<String> updateEmployee(@RequestBody EmployeeParam param) { EmployeeEntity entity = BeanUtils.copy(param, EmployeeEntity.class); entity.setUpdatedAt(new Date()); entity.setUpdatedBy(LoginContext.getIntFormatUserId()); employeeService.updateEmployee(entity); return new WrapperResponse<>(); }
Example #19
Source File: UserInfoController.java From oneplatform with Apache License 2.0 | 5 votes |
@ApiOperation(value = "新增用户") @RequestMapping(value = "add", method = RequestMethod.POST) public @ResponseBody WrapperResponse<String> addUserInfo(@RequestBody UserInfoParam param) { UserInfoEntity entity = BeanUtils.copy(param, UserInfoEntity.class); //entity.setCreatedAt(new Date()); //entity.setCreatedBy(LoginContext.getIntFormatUserId()); userInfoService.addUserInfo(entity); return new WrapperResponse<>(); }
Example #20
Source File: ArticleService.java From oneplatform with Apache License 2.0 | 4 votes |
public void updateCmsArticle(ArticleEntity entity) { ArticleEntity originEntity = cmsArticleMapper.selectByPrimaryKey(entity.getId()); AssertUtil.notNull(originEntity); BeanUtils.copy(entity, originEntity); cmsArticleMapper.updateByPrimaryKey(originEntity); }
Example #21
Source File: CategoryService.java From oneplatform with Apache License 2.0 | 4 votes |
public void addCategory(CategoryParam param){ CategoryEntity entity = BeanUtils.copy(param, CategoryEntity.class); categoryMapper.insertSelective(entity); }
Example #22
Source File: DepartmentService.java From oneplatform with Apache License 2.0 | 4 votes |
public void updateDepartment(DepartmentEntity entity) { DepartmentEntity originEntity = departmentMapper.selectByPrimaryKey(entity.getId()); AssertUtil.notNull(originEntity); BeanUtils.copy(entity, originEntity); departmentMapper.updateByPrimaryKey(originEntity); }
Example #23
Source File: PositionsService.java From oneplatform with Apache License 2.0 | 4 votes |
public void updatePositions(PositionEntity entity) { PositionEntity originEntity = positionsMapper.selectByPrimaryKey(entity.getId()); AssertUtil.notNull(originEntity); BeanUtils.copy(entity, originEntity); positionsMapper.updateByPrimaryKey(originEntity); }
Example #24
Source File: EmployeeService.java From oneplatform with Apache License 2.0 | 4 votes |
public void updateEmployee(EmployeeEntity entity) { EmployeeEntity originEntity = employeeMapper.selectByPrimaryKey(entity.getId()); AssertUtil.notNull(originEntity); BeanUtils.copy(entity, originEntity); employeeMapper.updateByPrimaryKey(originEntity); }
Example #25
Source File: UserInfoService.java From oneplatform with Apache License 2.0 | 4 votes |
public void updateUserInfo(UserInfoEntity entity) { UserInfoEntity originEntity = userInfoMapper.selectByPrimaryKey(entity.getId()); AssertUtil.notNull(originEntity); BeanUtils.copy(entity, originEntity); userInfoMapper.updateByPrimaryKey(originEntity); }
Example #26
Source File: ParameterUtils.java From jeesuite-libs with Apache License 2.0 | 4 votes |
private static String objectToQueryParams(Object param){ Map<String, Object> map = BeanUtils.beanToMap(param); return mapToQueryParams(map); }
Example #27
Source File: ParameterUtils.java From jeesuite-libs with Apache License 2.0 | 4 votes |
public static String mapToQueryParams(Map<String, Object> param){ if(param == null || param.isEmpty())return null; StringBuilder sb = new StringBuilder(); List<String> keys = new ArrayList<>(param.keySet()); Collections.sort(keys); Object value; for (String key : keys) { if(PARAM_SIGN_TYPE.equals(key) || PARAM_SIGN.equals(key))continue; value = param.get(key); if(value == null || StringUtils.isBlank(value.toString()))continue; if(value instanceof Map){ value = mapToQueryParams((Map<String, Object>) value); if(value != null){ value = JSON_PREFIX + value + JSON_SUFFIX; } }else if(value instanceof Iterable) { StringBuilder sb1 = new StringBuilder(); sb1.append(BRACKET_PREFIX); Iterator<?> it = ((Iterable<?>) value).iterator(); while (it.hasNext()) { Object object = it.next(); if(BeanUtils.isSimpleDataType(object)){ sb1.append(object).append(SPLIT_STR); }else{ sb1.append(JSON_PREFIX).append(objectToQueryParams(object)).append(JSON_SUFFIX).append(SPLIT_STR); } } if(sb1.length() == 1){ value = null; } else if(sb1.length() > 0){ sb1.deleteCharAt(sb1.length() - 1); sb1.append(BRACKET_SUFFIX); value = sb1.toString(); } } if(value != null){ sb.append(key).append(EQUALS_STR).append(value).append(CONTACT_STR); } } sb.deleteCharAt(sb.length() - 1); return sb.toString(); }