Java Code Examples for com.jeesuite.common.util.BeanUtils#copy()

The following examples show how to use com.jeesuite.common.util.BeanUtils#copy() . 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: PermissionService.java    From oneplatform with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: AppAdminController.java    From jeesuite-config with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: DepartmentController.java    From oneplatform with Apache License 2.0 6 votes vote down vote up
@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 4
Source File: EmployeeController.java    From oneplatform with Apache License 2.0 6 votes vote down vote up
@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 5
Source File: PermissionService.java    From oneplatform with Apache License 2.0 6 votes vote down vote up
@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 6
Source File: AccountService.java    From oneplatform with Apache License 2.0 6 votes vote down vote up
@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 7
Source File: CompanyService.java    From oneplatform with Apache License 2.0 6 votes vote down vote up
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 8
Source File: CompanyService.java    From oneplatform with Apache License 2.0 5 votes vote down vote up
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 9
Source File: PermissionService.java    From oneplatform with Apache License 2.0 5 votes vote down vote up
@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 10
Source File: ArticleController.java    From oneplatform with Apache License 2.0 5 votes vote down vote up
@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 11
Source File: ArticleController.java    From oneplatform with Apache License 2.0 5 votes vote down vote up
@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 12
Source File: UserInfoController.java    From oneplatform with Apache License 2.0 5 votes vote down vote up
@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 13
Source File: PermissionService.java    From oneplatform with Apache License 2.0 5 votes vote down vote up
@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: ConfigAdminController.java    From jeesuite-config with Apache License 2.0 5 votes vote down vote up
@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 15
Source File: EmployeeController.java    From oneplatform with Apache License 2.0 5 votes vote down vote up
@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 16
Source File: UserInfoController.java    From oneplatform with Apache License 2.0 5 votes vote down vote up
@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 17
Source File: DepartmentService.java    From oneplatform with Apache License 2.0 4 votes vote down vote up
public void updateDepartment(DepartmentEntity entity) {
	DepartmentEntity originEntity = departmentMapper.selectByPrimaryKey(entity.getId());
	AssertUtil.notNull(originEntity);
	BeanUtils.copy(entity, originEntity);
	departmentMapper.updateByPrimaryKey(originEntity);
}
 
Example 18
Source File: PositionsService.java    From oneplatform with Apache License 2.0 4 votes vote down vote up
public void updatePositions(PositionEntity entity) {
	PositionEntity originEntity = positionsMapper.selectByPrimaryKey(entity.getId());
	AssertUtil.notNull(originEntity);
	BeanUtils.copy(entity, originEntity);
	positionsMapper.updateByPrimaryKey(originEntity);
}
 
Example 19
Source File: ArticleService.java    From oneplatform with Apache License 2.0 4 votes vote down vote up
public void updateCmsArticle(ArticleEntity entity) {
	ArticleEntity originEntity = cmsArticleMapper.selectByPrimaryKey(entity.getId());
	AssertUtil.notNull(originEntity);
	BeanUtils.copy(entity, originEntity);
	cmsArticleMapper.updateByPrimaryKey(originEntity);
}
 
Example 20
Source File: CategoryService.java    From oneplatform with Apache License 2.0 4 votes vote down vote up
public void addCategory(CategoryParam param){
	CategoryEntity entity = BeanUtils.copy(param, CategoryEntity.class); 
	categoryMapper.insertSelective(entity);
}