what is useraccount class used for? - aspnetboilerplate

I am new to aspnetboilerplate.When I read source code,I found UserAccount class which also create a table in database.I found it create after abpuser create,but I could not find any other usage.Does somebody know what is useraccount used for?

UserAccount register all tenant users on a single place so you can access all users on this table (model) without removing any filter. Very good if you have tenant per database approach. One good use is you want unique user email not matter tenant.

Related

Implementing row based access based on role

I have created a table that contains Ticket information, with an id, message body, user id and department id.
I would like to be able to limit access to these tickets, such that only users from the corresponding department can access the relevant tickets, and can not view other department's tickets.
I have attempted to make an updatable view for each department and granting select on this, but it does not work very well.
Is there a simple way to achieve this kind of role based access?

Parse - avoid sharing information in specific column of a class

I've got a question about the best way to allow user's information to be visible between users in certain situations.
I have certain columns in User class which are private to the user.
In some activity i'm pointing to user object as 'postedBy' or something else,In this case the entire data regarding user is getting shared.
My question is how to restrict user to get some columns in User class??
usually if you want to restrict an access in parse it should be done via ACL. In ACL you can create role for users who can read/write to the class.
ACL are executed on a class level and not on a column level. In order to expose part of the fields i think you have 2 options:
Create one to one realtionship from your User class to another Class. the second class will contain all columns that not all users can see and for this class create ACL's with the users/roles that can view this data and when you will execute your query only the users with sufficient permissions will be able to get this data
The second option is when you want to avoid relationships here you can use the select option under query. Select allows you to select specific fields of the class and the query will return only the fields that you specified under the select. here is a code snippet from parse docs which explain how to use select (in JS):
var GameScore = Parse.Object.extend("GameScore");
var query = new Parse.Query(GameScore);
query.select("score", "playerName");
query.find().then(function(results) {
// each of results will only have the selected fields available.
});
Hope its clear now :)

How to create new query method at repository with or without ElasticSearch and Spring Boot?

I have 2 models, one called Employee and another one User,
Employee has one field pointing to User, one to one relationship.
My problem is that i need one query method to find the Employee that has the user with certain id. I need to find the Employee with certain User id.
I know the default query methods: .findOne, .findAll, but i need to create one, alright? how i can do that? i searched a lot but probably i am missing something. I didn't found how to do a query like that.
Thanks

Hibernate: Child table having two different ManyToOne relationships

In the Spring/Hibernate/Java/Tomcat app I'm writing I have a OneToMany relationship between an Organization and its Contacts.
Organization 1:M Contact (has foreign key org_id)
In Organization I have this field:
#OneToMany(mappedBy="organization")
private List<Contact> contacts;
In Contact I have this field:
#ManyToOne
#JoinColumn(name="org_id")
private Organization organization;
All is working OK so far. Now I'm adding the concept of an Offer. The Offer can be made by an Organization, and you speak with the designated Contact for that particular Offer.
Offer has foreign keys for its organization (org_id) and designated contact (contact_id).
So far, the Offer would look like:
#OneToOne
#JoinColumn(...)
private Organization offering_org;
#OneToOne
#JoinColumn(...)
private Contact offering_contact;
Here comes the point of my question. I've already annotated the Contact class for use with Organization. If I try to persist the Offer object in the usual Hibernate way, I'll need to store copies of an Organization object and a Contact object into the Offer object. This seems to conflict with my existing Organization : Contact use of the two Java classes. For example, if I've a 1:1 with Offer, if I put this into the Contact class do I get an optional use of either or a mandatory simultaneous use of both?
Since the Offer is yet another relationship, do I need to write a data transfer object version of Contact for use in the Offer relationship?
Thanks,
Jerome.
Perhaps I do not fully understand the problem but I'd just do something like this:
// contact & organization being already persisted entity objects
Offer offer = new Offer();
offer.setOffering_org(organization);
offer.setOffering_contact(contact);
// Persisting the new Offer object to the database,
// implicitly making the relations.
service.saveObject(offer);
I see no reason to create copy(s) of the organization object?
It just happens to be that the collection of "contacts" in the Organization object can also be a Contact within one or more Offer objects.
I'm thinking that my original question is kind of stupid. What I did try is to put this in Offer.java:
#Column(name="org_id")
private Long orgId = null;
#Column(name="contact_id")
private Long contactId = null;
I fill orgId manually because an offer is always tied to the user's Organization. It is a hidden field in the web page.
I put a SELECT filled with appropriate Contact objects (contact.id, contact.name) in the web page.
When the web page is submitted the Offer's orgId and contactId fields are filled in the #ModelAttribute parameter. This takes me where I want to go.
To address the comments of Mr. mspringer, your example could work (you illustrated a "create new" situation) if I were willing to use an Organization or Contact list in my Offer object. It is also somewhat the topic of my original question. But since I see that I don't really want to play with the expanded objects within Offer, nor do I wish to, I can avoid the topic of my original question.
Thanks to all who looked at my exercise in confusion.

one to many relationship in Entity Framework on the same table

I have two tables, in which one user can have several contacts:
User(UserId, UserName)
Contact(UserId, ContactId)
Suppose I would like to get all the ContactNames from the UserNames in the User Table by the Userid.
Note that the Contact table cannot be seen in the current data context, it has been turned into a many to many relationship
How can I do the query?
What If I need to insert or delete?
I tried the "include" method but it does not work. Do you have any suggestions?
Thank you very much.
var id = 1; // id to find
context.Users
.Where(x=>x.UserId = id)
.SelectMany(x=>x.Users)
.Select(x=>x.UserName)
.ToArray();
After generation from db your model has 2 sub-collections: Users and Users1.
One of it corresponds to users, that are contacts for current user.
Another stores users, that current user is contact for.
You can rename them to represent their meaning to Contacts and ContactsFor via editor.
If you still want to have 2 types instead of Type+(Many-To-Many Ref), then in editor you can delete reference, create new entity Contact, setup all mapping, add references. After all this is done - you will have model look like this:
To Achieve this:
Delete Many-To-Many reference
Crete new Entity Contact
Add properties ContactId and UserId, set StoreGeneratedPattern to none
Add mappings for Contact
Add associations for Contacts and ContactFor
But it's not that easy.

Resources