Labels: oa uml class requirement Design
1. Tomorrow's Mid-Autumn Festival is full of hardships. I have been alone, but fortunately I am not alone with the OA project. I will continue to take my notes and continue with yesterday's.
2. the SSH environment and SSH integration have been set up in the notes yesterday. What we need to do today is Design and Analysis of entity classes, first, we will divide the resource structure into a config folder to place all the configuration files. As mentioned above, note that you need to place it in the class path, that is, directly right-click the project name to create sourcefolder, create the corresponding JSP storage page, style storage style, script storage script language, etc.
3. design entity classes based on project requirements. Here I use the staruml tool to draw a UML diagram, the specific design ideas are as follows (entity design is very important because it includes the associations between attributes and tables). We start from system management, including user management and department management, job Management. The specific design is as follows:
Note that the association relationship is very important, because you need to set it when writing HBM files.
4. After the object class is designed, write the domain object code as follows based on the diagram. Pay attention to the set attributes:
User
package com.icss.oa.domain;import java.util.HashSet;import java.util.Set;public class User {private long id;private Department department;private Set<Role> roles =new HashSet<Role>();private String loginName;private String password;private String gender;private String phoneNumber;private String email;private String descrition;public long getId() {return id;}public void setId(long id) {this.id = id;}public Department getDepartment() {return department;}public void setDepartment(Department department) {this.department = department;}public Set<Role> getRoles() {return roles;}public void setRoles(Set<Role> roles) {this.roles = roles;}public String getLoginName() {return loginName;}public void setLoginName(String loginName) {this.loginName = loginName;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public String getGender() {return gender;}public void setGender(String gender) {this.gender = gender;}public String getPhoneNumber() {return phoneNumber;}public void setPhoneNumber(String phoneNumber) {this.phoneNumber = phoneNumber;}public String getEmail() {return email;}public void setEmail(String email) {this.email = email;}public String getDescrition() {return descrition;}public void setDescrition(String descrition) {this.descrition = descrition;}}Department
package com.icss.oa.domain;import java.util.HashSet;import java.util.Set;public class Department { private long id; private Set<User> users =new HashSet<User>(); private Department parent; private Set<Department> children; private String name; private String description; public long getId() {return id;}public void setId(long id) {this.id = id;}public Set<User> getUsers() {return users;}public void setUsers(Set<User> users) {this.users = users;}public Department getParent() {return parent;}public void setParent(Department parent) {this.parent = parent;}public Set<Department> getChildren() {return children;}public void setChildren(Set<Department> children) {this.children = children;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getDescription() {return description;}public void setDescription(String description) {this.description = description;} }Role
package com.icss.oa.domain;import java.util.HashSet;import java.util.Set;public class Role { private long id;private String name;private String description;private Set<User> users = new HashSet<User>();public long getId() {return id;}public void setId(long id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getDescription() {return description;}public void setDescription(String description) {this.description = description;}public Set<User> getUsers() {return users;}public void setUsers(Set<User> users) {this.users = users;}}
5. generate an HBM File Based on the object class. Pay attention to the association relationship.
User. HBM, XML
<? XML version = "1.0"?> <! Doctype hibernate-mapping public "-// hibernate/hibernate DTD ing DTD 3.0 // en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
Department. HBM. xml
<? XML version = "1.0"?> <! Doctype hibernate-mapping public "-// hibernate/hibernate DTD ing DTD 3.0 // en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> Role. HBM. xml
<? XML version = "1.0"?> <! Doctype hibernate-mapping public "-// hibernate/hibernate DTD ing DTD 3.0 // en" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
6. test. If the above Code is correct, springtest in the test folder will be generated in the database and the following results will be obtained:
7. design the Action Service Dao layer tomorrow
Design of object classes in project OA