diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java new file mode 100644 index 0000000..a76886e --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java @@ -0,0 +1,73 @@ +package com.casic.PgInterface.patroler.domain; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/3/19. + */ +@Entity +@Table(name = "PG_ROLE") +@SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) +public class PgRole implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String role; + private int active; + private PgAuthority pgAuthorityId; + private List pgUsers; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "ROLE") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "AUTHORITYID") + public PgAuthority getPgAuthorityId() { + return pgAuthorityId; + } + + public void setPgAuthorityId(PgAuthority pgAuthorityId) { + this.pgAuthorityId = pgAuthorityId; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") + public List getPgUsers() { + return pgUsers; + } + + public void setPgUsers(List pgUsers) { + this.pgUsers = pgUsers; + } + +} \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java new file mode 100644 index 0000000..a76886e --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java @@ -0,0 +1,73 @@ +package com.casic.PgInterface.patroler.domain; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/3/19. + */ +@Entity +@Table(name = "PG_ROLE") +@SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) +public class PgRole implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String role; + private int active; + private PgAuthority pgAuthorityId; + private List pgUsers; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "ROLE") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "AUTHORITYID") + public PgAuthority getPgAuthorityId() { + return pgAuthorityId; + } + + public void setPgAuthorityId(PgAuthority pgAuthorityId) { + this.pgAuthorityId = pgAuthorityId; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") + public List getPgUsers() { + return pgUsers; + } + + public void setPgUsers(List pgUsers) { + this.pgUsers = pgUsers; + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java index 85301a9..b68a985 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java @@ -1,6 +1,8 @@ package com.casic.PgInterface.patroler.domain; import com.casic.PgInterface.devTable.domain.PgAlarm; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; @@ -22,6 +24,7 @@ private String post;//职务 private String phoneNumber;//电话 private int active;//状态位 + private PgRole pgRoleId;//权限 private List pgAlarms; private List pgLogs; @@ -89,6 +92,17 @@ this.active = active; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "ROLEID") + public PgRole getPgRoleId() { + return pgRoleId; + } + + public void setPgRoleId(PgRole pgRoleId) { + this.pgRoleId = pgRoleId; + } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "patrolerId") public List getPgAlarms() { return pgAlarms; @@ -106,4 +120,4 @@ public void setPgLogs(List pgLogs) { this.pgLogs = pgLogs; } -} +} \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java new file mode 100644 index 0000000..a76886e --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java @@ -0,0 +1,73 @@ +package com.casic.PgInterface.patroler.domain; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/3/19. + */ +@Entity +@Table(name = "PG_ROLE") +@SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) +public class PgRole implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String role; + private int active; + private PgAuthority pgAuthorityId; + private List pgUsers; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "ROLE") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "AUTHORITYID") + public PgAuthority getPgAuthorityId() { + return pgAuthorityId; + } + + public void setPgAuthorityId(PgAuthority pgAuthorityId) { + this.pgAuthorityId = pgAuthorityId; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") + public List getPgUsers() { + return pgUsers; + } + + public void setPgUsers(List pgUsers) { + this.pgUsers = pgUsers; + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java index 85301a9..b68a985 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java @@ -1,6 +1,8 @@ package com.casic.PgInterface.patroler.domain; import com.casic.PgInterface.devTable.domain.PgAlarm; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; @@ -22,6 +24,7 @@ private String post;//职务 private String phoneNumber;//电话 private int active;//状态位 + private PgRole pgRoleId;//权限 private List pgAlarms; private List pgLogs; @@ -89,6 +92,17 @@ this.active = active; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "ROLEID") + public PgRole getPgRoleId() { + return pgRoleId; + } + + public void setPgRoleId(PgRole pgRoleId) { + this.pgRoleId = pgRoleId; + } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "patrolerId") public List getPgAlarms() { return pgAlarms; @@ -106,4 +120,4 @@ public void setPgLogs(List pgLogs) { this.pgLogs = pgLogs; } -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java new file mode 100644 index 0000000..2468612 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java @@ -0,0 +1,48 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAuthority; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ + +public class PgAuthorityDto implements Serializable { + + private String id; + private String authority; + private String concent; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + public PgAuthorityDto(PgAuthority pgAuthority) + { + this.setId(String.valueOf(pgAuthority.getId())); + this.setAuthority(pgAuthority.getAuthority()); + this.setConcent(pgAuthority.getConcent()); + } + +} diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java new file mode 100644 index 0000000..a76886e --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java @@ -0,0 +1,73 @@ +package com.casic.PgInterface.patroler.domain; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/3/19. + */ +@Entity +@Table(name = "PG_ROLE") +@SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) +public class PgRole implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String role; + private int active; + private PgAuthority pgAuthorityId; + private List pgUsers; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "ROLE") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "AUTHORITYID") + public PgAuthority getPgAuthorityId() { + return pgAuthorityId; + } + + public void setPgAuthorityId(PgAuthority pgAuthorityId) { + this.pgAuthorityId = pgAuthorityId; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") + public List getPgUsers() { + return pgUsers; + } + + public void setPgUsers(List pgUsers) { + this.pgUsers = pgUsers; + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java index 85301a9..b68a985 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java @@ -1,6 +1,8 @@ package com.casic.PgInterface.patroler.domain; import com.casic.PgInterface.devTable.domain.PgAlarm; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; @@ -22,6 +24,7 @@ private String post;//职务 private String phoneNumber;//电话 private int active;//状态位 + private PgRole pgRoleId;//权限 private List pgAlarms; private List pgLogs; @@ -89,6 +92,17 @@ this.active = active; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "ROLEID") + public PgRole getPgRoleId() { + return pgRoleId; + } + + public void setPgRoleId(PgRole pgRoleId) { + this.pgRoleId = pgRoleId; + } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "patrolerId") public List getPgAlarms() { return pgAlarms; @@ -106,4 +120,4 @@ public void setPgLogs(List pgLogs) { this.pgLogs = pgLogs; } -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java new file mode 100644 index 0000000..2468612 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java @@ -0,0 +1,48 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAuthority; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ + +public class PgAuthorityDto implements Serializable { + + private String id; + private String authority; + private String concent; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + public PgAuthorityDto(PgAuthority pgAuthority) + { + this.setId(String.valueOf(pgAuthority.getId())); + this.setAuthority(pgAuthority.getAuthority()); + this.setConcent(pgAuthority.getConcent()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java index 602d295..620bbf3 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java @@ -73,7 +73,7 @@ this.setBeginTime(sdf.format(pgMaintain.getBeginTime())); this.setTimeLimt(pgMaintain.getTimeLimt()); this.setDescribe(pgMaintain.getDescribe()); - this.setActive(pgMaintain.getActive()); + this.setActive(String.valueOf(pgMaintain.getActive())); } } diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java new file mode 100644 index 0000000..a76886e --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java @@ -0,0 +1,73 @@ +package com.casic.PgInterface.patroler.domain; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/3/19. + */ +@Entity +@Table(name = "PG_ROLE") +@SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) +public class PgRole implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String role; + private int active; + private PgAuthority pgAuthorityId; + private List pgUsers; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "ROLE") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "AUTHORITYID") + public PgAuthority getPgAuthorityId() { + return pgAuthorityId; + } + + public void setPgAuthorityId(PgAuthority pgAuthorityId) { + this.pgAuthorityId = pgAuthorityId; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") + public List getPgUsers() { + return pgUsers; + } + + public void setPgUsers(List pgUsers) { + this.pgUsers = pgUsers; + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java index 85301a9..b68a985 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java @@ -1,6 +1,8 @@ package com.casic.PgInterface.patroler.domain; import com.casic.PgInterface.devTable.domain.PgAlarm; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; @@ -22,6 +24,7 @@ private String post;//职务 private String phoneNumber;//电话 private int active;//状态位 + private PgRole pgRoleId;//权限 private List pgAlarms; private List pgLogs; @@ -89,6 +92,17 @@ this.active = active; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "ROLEID") + public PgRole getPgRoleId() { + return pgRoleId; + } + + public void setPgRoleId(PgRole pgRoleId) { + this.pgRoleId = pgRoleId; + } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "patrolerId") public List getPgAlarms() { return pgAlarms; @@ -106,4 +120,4 @@ public void setPgLogs(List pgLogs) { this.pgLogs = pgLogs; } -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java new file mode 100644 index 0000000..2468612 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java @@ -0,0 +1,48 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAuthority; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ + +public class PgAuthorityDto implements Serializable { + + private String id; + private String authority; + private String concent; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + public PgAuthorityDto(PgAuthority pgAuthority) + { + this.setId(String.valueOf(pgAuthority.getId())); + this.setAuthority(pgAuthority.getAuthority()); + this.setConcent(pgAuthority.getConcent()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java index 602d295..620bbf3 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java @@ -73,7 +73,7 @@ this.setBeginTime(sdf.format(pgMaintain.getBeginTime())); this.setTimeLimt(pgMaintain.getTimeLimt()); this.setDescribe(pgMaintain.getDescribe()); - this.setActive(pgMaintain.getActive()); + this.setActive(String.valueOf(pgMaintain.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java index 65ae5b3..39fd3c5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java @@ -74,7 +74,7 @@ this.setBeginTime(sdf.format(pgPatrol.getBeginTime())); this.setTimeLimt(pgPatrol.getTimeLimt()); this.setDescribe(pgPatrol.getDescribe()); - this.setActive(pgPatrol.getActive()); + this.setActive(String.valueOf(pgPatrol.getActive())); } } diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java new file mode 100644 index 0000000..a76886e --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java @@ -0,0 +1,73 @@ +package com.casic.PgInterface.patroler.domain; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/3/19. + */ +@Entity +@Table(name = "PG_ROLE") +@SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) +public class PgRole implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String role; + private int active; + private PgAuthority pgAuthorityId; + private List pgUsers; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "ROLE") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "AUTHORITYID") + public PgAuthority getPgAuthorityId() { + return pgAuthorityId; + } + + public void setPgAuthorityId(PgAuthority pgAuthorityId) { + this.pgAuthorityId = pgAuthorityId; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") + public List getPgUsers() { + return pgUsers; + } + + public void setPgUsers(List pgUsers) { + this.pgUsers = pgUsers; + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java index 85301a9..b68a985 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java @@ -1,6 +1,8 @@ package com.casic.PgInterface.patroler.domain; import com.casic.PgInterface.devTable.domain.PgAlarm; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; @@ -22,6 +24,7 @@ private String post;//职务 private String phoneNumber;//电话 private int active;//状态位 + private PgRole pgRoleId;//权限 private List pgAlarms; private List pgLogs; @@ -89,6 +92,17 @@ this.active = active; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "ROLEID") + public PgRole getPgRoleId() { + return pgRoleId; + } + + public void setPgRoleId(PgRole pgRoleId) { + this.pgRoleId = pgRoleId; + } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "patrolerId") public List getPgAlarms() { return pgAlarms; @@ -106,4 +120,4 @@ public void setPgLogs(List pgLogs) { this.pgLogs = pgLogs; } -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java new file mode 100644 index 0000000..2468612 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java @@ -0,0 +1,48 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAuthority; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ + +public class PgAuthorityDto implements Serializable { + + private String id; + private String authority; + private String concent; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + public PgAuthorityDto(PgAuthority pgAuthority) + { + this.setId(String.valueOf(pgAuthority.getId())); + this.setAuthority(pgAuthority.getAuthority()); + this.setConcent(pgAuthority.getConcent()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java index 602d295..620bbf3 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java @@ -73,7 +73,7 @@ this.setBeginTime(sdf.format(pgMaintain.getBeginTime())); this.setTimeLimt(pgMaintain.getTimeLimt()); this.setDescribe(pgMaintain.getDescribe()); - this.setActive(pgMaintain.getActive()); + this.setActive(String.valueOf(pgMaintain.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java index 65ae5b3..39fd3c5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java @@ -74,7 +74,7 @@ this.setBeginTime(sdf.format(pgPatrol.getBeginTime())); this.setTimeLimt(pgPatrol.getTimeLimt()); this.setDescribe(pgPatrol.getDescribe()); - this.setActive(pgPatrol.getActive()); + this.setActive(String.valueOf(pgPatrol.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java new file mode 100644 index 0000000..7c7e004 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgRole; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ +public class PgRoleDto implements Serializable { + + private String id; + private String role; + private String active; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgRoleDto(PgRole pgRole) + { + this.setId(String.valueOf(pgRole.getId())); + this.setRole(pgRole.getRole()); + this.setActive(String.valueOf(pgRole.getActive())); + } +} diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java new file mode 100644 index 0000000..a76886e --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java @@ -0,0 +1,73 @@ +package com.casic.PgInterface.patroler.domain; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/3/19. + */ +@Entity +@Table(name = "PG_ROLE") +@SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) +public class PgRole implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String role; + private int active; + private PgAuthority pgAuthorityId; + private List pgUsers; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "ROLE") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "AUTHORITYID") + public PgAuthority getPgAuthorityId() { + return pgAuthorityId; + } + + public void setPgAuthorityId(PgAuthority pgAuthorityId) { + this.pgAuthorityId = pgAuthorityId; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") + public List getPgUsers() { + return pgUsers; + } + + public void setPgUsers(List pgUsers) { + this.pgUsers = pgUsers; + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java index 85301a9..b68a985 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java @@ -1,6 +1,8 @@ package com.casic.PgInterface.patroler.domain; import com.casic.PgInterface.devTable.domain.PgAlarm; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; @@ -22,6 +24,7 @@ private String post;//职务 private String phoneNumber;//电话 private int active;//状态位 + private PgRole pgRoleId;//权限 private List pgAlarms; private List pgLogs; @@ -89,6 +92,17 @@ this.active = active; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "ROLEID") + public PgRole getPgRoleId() { + return pgRoleId; + } + + public void setPgRoleId(PgRole pgRoleId) { + this.pgRoleId = pgRoleId; + } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "patrolerId") public List getPgAlarms() { return pgAlarms; @@ -106,4 +120,4 @@ public void setPgLogs(List pgLogs) { this.pgLogs = pgLogs; } -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java new file mode 100644 index 0000000..2468612 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java @@ -0,0 +1,48 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAuthority; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ + +public class PgAuthorityDto implements Serializable { + + private String id; + private String authority; + private String concent; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + public PgAuthorityDto(PgAuthority pgAuthority) + { + this.setId(String.valueOf(pgAuthority.getId())); + this.setAuthority(pgAuthority.getAuthority()); + this.setConcent(pgAuthority.getConcent()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java index 602d295..620bbf3 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java @@ -73,7 +73,7 @@ this.setBeginTime(sdf.format(pgMaintain.getBeginTime())); this.setTimeLimt(pgMaintain.getTimeLimt()); this.setDescribe(pgMaintain.getDescribe()); - this.setActive(pgMaintain.getActive()); + this.setActive(String.valueOf(pgMaintain.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java index 65ae5b3..39fd3c5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java @@ -74,7 +74,7 @@ this.setBeginTime(sdf.format(pgPatrol.getBeginTime())); this.setTimeLimt(pgPatrol.getTimeLimt()); this.setDescribe(pgPatrol.getDescribe()); - this.setActive(pgPatrol.getActive()); + this.setActive(String.valueOf(pgPatrol.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java new file mode 100644 index 0000000..7c7e004 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgRole; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ +public class PgRoleDto implements Serializable { + + private String id; + private String role; + private String active; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgRoleDto(PgRole pgRole) + { + this.setId(String.valueOf(pgRole.getId())); + this.setRole(pgRole.getRole()); + this.setActive(String.valueOf(pgRole.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java new file mode 100644 index 0000000..12f92a9 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.dto.PgAuthorityDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgAuthorityManager extends HibernateEntityDao{ + + public PgAuthority getAuthorityByAuthority(String authority) { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("authority", authority)); + criteria.add(Restrictions.eq("active", 1)); + List pgAuthorityList = criteria.list(); + + if (pgAuthorityList == null || pgAuthorityList.size() == 0) + return null; + else + return pgAuthorityList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getAuthorityList() + { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgAuthorityList = criteria.list(); + List pgAuthorityDtoList=new ArrayList(); + for(PgAuthority pgAuthority : pgAuthorityList) + { + pgAuthorityDtoList.add(new PgAuthorityDto(pgAuthority)); + } + + return pgAuthorityDtoList; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + +} diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java new file mode 100644 index 0000000..a76886e --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java @@ -0,0 +1,73 @@ +package com.casic.PgInterface.patroler.domain; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/3/19. + */ +@Entity +@Table(name = "PG_ROLE") +@SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) +public class PgRole implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String role; + private int active; + private PgAuthority pgAuthorityId; + private List pgUsers; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "ROLE") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "AUTHORITYID") + public PgAuthority getPgAuthorityId() { + return pgAuthorityId; + } + + public void setPgAuthorityId(PgAuthority pgAuthorityId) { + this.pgAuthorityId = pgAuthorityId; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") + public List getPgUsers() { + return pgUsers; + } + + public void setPgUsers(List pgUsers) { + this.pgUsers = pgUsers; + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java index 85301a9..b68a985 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java @@ -1,6 +1,8 @@ package com.casic.PgInterface.patroler.domain; import com.casic.PgInterface.devTable.domain.PgAlarm; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; @@ -22,6 +24,7 @@ private String post;//职务 private String phoneNumber;//电话 private int active;//状态位 + private PgRole pgRoleId;//权限 private List pgAlarms; private List pgLogs; @@ -89,6 +92,17 @@ this.active = active; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "ROLEID") + public PgRole getPgRoleId() { + return pgRoleId; + } + + public void setPgRoleId(PgRole pgRoleId) { + this.pgRoleId = pgRoleId; + } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "patrolerId") public List getPgAlarms() { return pgAlarms; @@ -106,4 +120,4 @@ public void setPgLogs(List pgLogs) { this.pgLogs = pgLogs; } -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java new file mode 100644 index 0000000..2468612 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java @@ -0,0 +1,48 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAuthority; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ + +public class PgAuthorityDto implements Serializable { + + private String id; + private String authority; + private String concent; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + public PgAuthorityDto(PgAuthority pgAuthority) + { + this.setId(String.valueOf(pgAuthority.getId())); + this.setAuthority(pgAuthority.getAuthority()); + this.setConcent(pgAuthority.getConcent()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java index 602d295..620bbf3 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java @@ -73,7 +73,7 @@ this.setBeginTime(sdf.format(pgMaintain.getBeginTime())); this.setTimeLimt(pgMaintain.getTimeLimt()); this.setDescribe(pgMaintain.getDescribe()); - this.setActive(pgMaintain.getActive()); + this.setActive(String.valueOf(pgMaintain.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java index 65ae5b3..39fd3c5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java @@ -74,7 +74,7 @@ this.setBeginTime(sdf.format(pgPatrol.getBeginTime())); this.setTimeLimt(pgPatrol.getTimeLimt()); this.setDescribe(pgPatrol.getDescribe()); - this.setActive(pgPatrol.getActive()); + this.setActive(String.valueOf(pgPatrol.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java new file mode 100644 index 0000000..7c7e004 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgRole; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ +public class PgRoleDto implements Serializable { + + private String id; + private String role; + private String active; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgRoleDto(PgRole pgRole) + { + this.setId(String.valueOf(pgRole.getId())); + this.setRole(pgRole.getRole()); + this.setActive(String.valueOf(pgRole.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java new file mode 100644 index 0000000..12f92a9 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.dto.PgAuthorityDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgAuthorityManager extends HibernateEntityDao{ + + public PgAuthority getAuthorityByAuthority(String authority) { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("authority", authority)); + criteria.add(Restrictions.eq("active", 1)); + List pgAuthorityList = criteria.list(); + + if (pgAuthorityList == null || pgAuthorityList.size() == 0) + return null; + else + return pgAuthorityList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getAuthorityList() + { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgAuthorityList = criteria.list(); + List pgAuthorityDtoList=new ArrayList(); + for(PgAuthority pgAuthority : pgAuthorityList) + { + pgAuthorityDtoList.add(new PgAuthorityDto(pgAuthority)); + } + + return pgAuthorityDtoList; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java new file mode 100644 index 0000000..66b272b --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgRole; +import com.casic.PgInterface.patroler.dto.PgRoleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgRoleManager extends HibernateEntityDao { + + public PgRole getPgRoleByRole(String role) { + try { + Criteria criteria = createCriteria(PgRole.class); + criteria.add(Restrictions.eq("role", role)); + criteria.add(Restrictions.eq("active", 1)); + List pgRoleList = criteria.list(); + + if (pgRoleList == null || pgRoleList.size() == 0) + return null; + else + return pgRoleList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getPgRoleDtoList() { + try { + Criteria criteria = createCriteria(PgRole.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgRoleList=criteria.list(); + List pgRoleDtoList=new ArrayList(); + for(PgRole pgRole:pgRoleList) + { + pgRoleDtoList.add(new PgRoleDto(pgRole)); + } + return pgRoleDtoList; + } + catch(Exception e) + { + e.printStackTrace(); + return null; + } + } + +} diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java new file mode 100644 index 0000000..a76886e --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java @@ -0,0 +1,73 @@ +package com.casic.PgInterface.patroler.domain; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/3/19. + */ +@Entity +@Table(name = "PG_ROLE") +@SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) +public class PgRole implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String role; + private int active; + private PgAuthority pgAuthorityId; + private List pgUsers; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "ROLE") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "AUTHORITYID") + public PgAuthority getPgAuthorityId() { + return pgAuthorityId; + } + + public void setPgAuthorityId(PgAuthority pgAuthorityId) { + this.pgAuthorityId = pgAuthorityId; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") + public List getPgUsers() { + return pgUsers; + } + + public void setPgUsers(List pgUsers) { + this.pgUsers = pgUsers; + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java index 85301a9..b68a985 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java @@ -1,6 +1,8 @@ package com.casic.PgInterface.patroler.domain; import com.casic.PgInterface.devTable.domain.PgAlarm; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; @@ -22,6 +24,7 @@ private String post;//职务 private String phoneNumber;//电话 private int active;//状态位 + private PgRole pgRoleId;//权限 private List pgAlarms; private List pgLogs; @@ -89,6 +92,17 @@ this.active = active; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "ROLEID") + public PgRole getPgRoleId() { + return pgRoleId; + } + + public void setPgRoleId(PgRole pgRoleId) { + this.pgRoleId = pgRoleId; + } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "patrolerId") public List getPgAlarms() { return pgAlarms; @@ -106,4 +120,4 @@ public void setPgLogs(List pgLogs) { this.pgLogs = pgLogs; } -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java new file mode 100644 index 0000000..2468612 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java @@ -0,0 +1,48 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAuthority; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ + +public class PgAuthorityDto implements Serializable { + + private String id; + private String authority; + private String concent; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + public PgAuthorityDto(PgAuthority pgAuthority) + { + this.setId(String.valueOf(pgAuthority.getId())); + this.setAuthority(pgAuthority.getAuthority()); + this.setConcent(pgAuthority.getConcent()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java index 602d295..620bbf3 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java @@ -73,7 +73,7 @@ this.setBeginTime(sdf.format(pgMaintain.getBeginTime())); this.setTimeLimt(pgMaintain.getTimeLimt()); this.setDescribe(pgMaintain.getDescribe()); - this.setActive(pgMaintain.getActive()); + this.setActive(String.valueOf(pgMaintain.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java index 65ae5b3..39fd3c5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java @@ -74,7 +74,7 @@ this.setBeginTime(sdf.format(pgPatrol.getBeginTime())); this.setTimeLimt(pgPatrol.getTimeLimt()); this.setDescribe(pgPatrol.getDescribe()); - this.setActive(pgPatrol.getActive()); + this.setActive(String.valueOf(pgPatrol.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java new file mode 100644 index 0000000..7c7e004 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgRole; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ +public class PgRoleDto implements Serializable { + + private String id; + private String role; + private String active; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgRoleDto(PgRole pgRole) + { + this.setId(String.valueOf(pgRole.getId())); + this.setRole(pgRole.getRole()); + this.setActive(String.valueOf(pgRole.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java new file mode 100644 index 0000000..12f92a9 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.dto.PgAuthorityDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgAuthorityManager extends HibernateEntityDao{ + + public PgAuthority getAuthorityByAuthority(String authority) { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("authority", authority)); + criteria.add(Restrictions.eq("active", 1)); + List pgAuthorityList = criteria.list(); + + if (pgAuthorityList == null || pgAuthorityList.size() == 0) + return null; + else + return pgAuthorityList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getAuthorityList() + { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgAuthorityList = criteria.list(); + List pgAuthorityDtoList=new ArrayList(); + for(PgAuthority pgAuthority : pgAuthorityList) + { + pgAuthorityDtoList.add(new PgAuthorityDto(pgAuthority)); + } + + return pgAuthorityDtoList; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java new file mode 100644 index 0000000..66b272b --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgRole; +import com.casic.PgInterface.patroler.dto.PgRoleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgRoleManager extends HibernateEntityDao { + + public PgRole getPgRoleByRole(String role) { + try { + Criteria criteria = createCriteria(PgRole.class); + criteria.add(Restrictions.eq("role", role)); + criteria.add(Restrictions.eq("active", 1)); + List pgRoleList = criteria.list(); + + if (pgRoleList == null || pgRoleList.size() == 0) + return null; + else + return pgRoleList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getPgRoleDtoList() { + try { + Criteria criteria = createCriteria(PgRole.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgRoleList=criteria.list(); + List pgRoleDtoList=new ArrayList(); + for(PgRole pgRole:pgRoleList) + { + pgRoleDtoList.add(new PgRoleDto(pgRole)); + } + return pgRoleDtoList; + } + catch(Exception e) + { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index f28ebdf..d9914a8 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -91,7 +91,8 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("devType") String devType, + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("devType") String devType, @FormParam("highValue") String highValue, @FormParam("lowValue") String lowValue, @FormParam("unit") String unit) throws Exception { @@ -102,7 +103,7 @@ PgAlarmRule pgAlarmRule = null; try { - pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + pgAlarmRule = pgAlarmRuleManager.get(Long.valueOf(id)); if (pgAlarmRule == null) { msg = "不存在报警阈值记录"; result = "false"; diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java new file mode 100644 index 0000000..a76886e --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java @@ -0,0 +1,73 @@ +package com.casic.PgInterface.patroler.domain; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/3/19. + */ +@Entity +@Table(name = "PG_ROLE") +@SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) +public class PgRole implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String role; + private int active; + private PgAuthority pgAuthorityId; + private List pgUsers; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "ROLE") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "AUTHORITYID") + public PgAuthority getPgAuthorityId() { + return pgAuthorityId; + } + + public void setPgAuthorityId(PgAuthority pgAuthorityId) { + this.pgAuthorityId = pgAuthorityId; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") + public List getPgUsers() { + return pgUsers; + } + + public void setPgUsers(List pgUsers) { + this.pgUsers = pgUsers; + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java index 85301a9..b68a985 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java @@ -1,6 +1,8 @@ package com.casic.PgInterface.patroler.domain; import com.casic.PgInterface.devTable.domain.PgAlarm; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; @@ -22,6 +24,7 @@ private String post;//职务 private String phoneNumber;//电话 private int active;//状态位 + private PgRole pgRoleId;//权限 private List pgAlarms; private List pgLogs; @@ -89,6 +92,17 @@ this.active = active; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "ROLEID") + public PgRole getPgRoleId() { + return pgRoleId; + } + + public void setPgRoleId(PgRole pgRoleId) { + this.pgRoleId = pgRoleId; + } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "patrolerId") public List getPgAlarms() { return pgAlarms; @@ -106,4 +120,4 @@ public void setPgLogs(List pgLogs) { this.pgLogs = pgLogs; } -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java new file mode 100644 index 0000000..2468612 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java @@ -0,0 +1,48 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAuthority; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ + +public class PgAuthorityDto implements Serializable { + + private String id; + private String authority; + private String concent; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + public PgAuthorityDto(PgAuthority pgAuthority) + { + this.setId(String.valueOf(pgAuthority.getId())); + this.setAuthority(pgAuthority.getAuthority()); + this.setConcent(pgAuthority.getConcent()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java index 602d295..620bbf3 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java @@ -73,7 +73,7 @@ this.setBeginTime(sdf.format(pgMaintain.getBeginTime())); this.setTimeLimt(pgMaintain.getTimeLimt()); this.setDescribe(pgMaintain.getDescribe()); - this.setActive(pgMaintain.getActive()); + this.setActive(String.valueOf(pgMaintain.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java index 65ae5b3..39fd3c5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java @@ -74,7 +74,7 @@ this.setBeginTime(sdf.format(pgPatrol.getBeginTime())); this.setTimeLimt(pgPatrol.getTimeLimt()); this.setDescribe(pgPatrol.getDescribe()); - this.setActive(pgPatrol.getActive()); + this.setActive(String.valueOf(pgPatrol.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java new file mode 100644 index 0000000..7c7e004 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgRole; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ +public class PgRoleDto implements Serializable { + + private String id; + private String role; + private String active; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgRoleDto(PgRole pgRole) + { + this.setId(String.valueOf(pgRole.getId())); + this.setRole(pgRole.getRole()); + this.setActive(String.valueOf(pgRole.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java new file mode 100644 index 0000000..12f92a9 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.dto.PgAuthorityDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgAuthorityManager extends HibernateEntityDao{ + + public PgAuthority getAuthorityByAuthority(String authority) { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("authority", authority)); + criteria.add(Restrictions.eq("active", 1)); + List pgAuthorityList = criteria.list(); + + if (pgAuthorityList == null || pgAuthorityList.size() == 0) + return null; + else + return pgAuthorityList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getAuthorityList() + { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgAuthorityList = criteria.list(); + List pgAuthorityDtoList=new ArrayList(); + for(PgAuthority pgAuthority : pgAuthorityList) + { + pgAuthorityDtoList.add(new PgAuthorityDto(pgAuthority)); + } + + return pgAuthorityDtoList; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java new file mode 100644 index 0000000..66b272b --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgRole; +import com.casic.PgInterface.patroler.dto.PgRoleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgRoleManager extends HibernateEntityDao { + + public PgRole getPgRoleByRole(String role) { + try { + Criteria criteria = createCriteria(PgRole.class); + criteria.add(Restrictions.eq("role", role)); + criteria.add(Restrictions.eq("active", 1)); + List pgRoleList = criteria.list(); + + if (pgRoleList == null || pgRoleList.size() == 0) + return null; + else + return pgRoleList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getPgRoleDtoList() { + try { + Criteria criteria = createCriteria(PgRole.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgRoleList=criteria.list(); + List pgRoleDtoList=new ArrayList(); + for(PgRole pgRole:pgRoleList) + { + pgRoleDtoList.add(new PgRoleDto(pgRole)); + } + return pgRoleDtoList; + } + catch(Exception e) + { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index f28ebdf..d9914a8 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -91,7 +91,8 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("devType") String devType, + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("devType") String devType, @FormParam("highValue") String highValue, @FormParam("lowValue") String lowValue, @FormParam("unit") String unit) throws Exception { @@ -102,7 +103,7 @@ PgAlarmRule pgAlarmRule = null; try { - pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + pgAlarmRule = pgAlarmRuleManager.get(Long.valueOf(id)); if (pgAlarmRule == null) { msg = "不存在报警阈值记录"; result = "false"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java b/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java new file mode 100644 index 0000000..9f8f5f7 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java @@ -0,0 +1,167 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.dto.PgAuthorityDto; +import com.casic.PgInterface.patroler.manager.PgAuthorityManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by yxw on 2018/3/30. + */ +@Component +@Path("pgAuthority") +public class PgAuthorityRs { + private static Logger logger = LoggerFactory.getLogger(PgAuthority.class); + + private PgAuthorityManager pgAuthorityManager; + + @Resource + public void setPgAuthorityManager(PgAuthorityManager pgAuthorityManager) { + this.pgAuthorityManager = pgAuthorityManager; + } + + /** + * 新增权限 + */ + @POST + @Path("addAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map addAuthority(@FormParam("authority") String authority, + @FormParam("concent") String concent) throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try{ + PgAuthority pgAuthority=new PgAuthority(); + + pgAuthority.setAuthority(authority); + pgAuthority.setConcent(concent); + pgAuthority.setActive(1); + + pgAuthorityManager.save(pgAuthority); + msg="用户权限保存成功"; + result="true"; + } + catch(Exception e) { + e.printStackTrace(); + msg = "新增权限失败"; + result = "false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + /* + *编辑角权限信息 + */ + @POST + @Path("editAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map editAuthority(@FormParam("id") String id, + @FormParam("authority") String authority, + @FormParam("concent") String concent) throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + try { + PgAuthority pgAuthority=pgAuthorityManager.get(Long.valueOf(id)); + pgAuthority.setAuthority(authority); + pgAuthority.setConcent(concent); + + pgAuthorityManager.save(pgAuthority); + msg="权限保存成功"; + result="true"; + } + catch(Exception e) + { + e.printStackTrace(); + msg="权限编辑失败"; + result="false"; + } + + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + /** + * 删除信息 + */ + @POST + @Path("deleteAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map deleteAuthority(@FormParam("id") String id)throws Exception { + + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try { + PgAuthority pgAuthority= pgAuthorityManager.get(Long.valueOf(id)); + if(pgAuthority==null) { + msg = "不存在该权限信息"; + result="false"; + } + else + { + pgAuthority.setActive(0); + pgAuthorityManager.save(pgAuthority); + msg="删除权限成功"; + result="true"; + } + }catch(Exception e){ + e.printStackTrace(); + msg="删除权限失败"; + result="false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + return resultMap; + } + + /* +* 获取权限信息 + */ + @POST + @Path("getAuthorityList") + @Produces(MediaType.APPLICATION_JSON) + public Map getAuthorityList() { + Map resultMap = new HashMap(); + String msg = ""; + List pgAuthorityDtoList = new ArrayList(); + try { + pgAuthorityDtoList = pgAuthorityManager.getAuthorityList(); + if (pgAuthorityDtoList == null) + msg = "不存在权限信息"; + else + msg = "权限信息获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "权限信息获取是失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAuthorityDtoList); + return resultMap; + } + + + + +} diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java new file mode 100644 index 0000000..a76886e --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java @@ -0,0 +1,73 @@ +package com.casic.PgInterface.patroler.domain; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/3/19. + */ +@Entity +@Table(name = "PG_ROLE") +@SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) +public class PgRole implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String role; + private int active; + private PgAuthority pgAuthorityId; + private List pgUsers; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "ROLE") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "AUTHORITYID") + public PgAuthority getPgAuthorityId() { + return pgAuthorityId; + } + + public void setPgAuthorityId(PgAuthority pgAuthorityId) { + this.pgAuthorityId = pgAuthorityId; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") + public List getPgUsers() { + return pgUsers; + } + + public void setPgUsers(List pgUsers) { + this.pgUsers = pgUsers; + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java index 85301a9..b68a985 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java @@ -1,6 +1,8 @@ package com.casic.PgInterface.patroler.domain; import com.casic.PgInterface.devTable.domain.PgAlarm; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; @@ -22,6 +24,7 @@ private String post;//职务 private String phoneNumber;//电话 private int active;//状态位 + private PgRole pgRoleId;//权限 private List pgAlarms; private List pgLogs; @@ -89,6 +92,17 @@ this.active = active; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "ROLEID") + public PgRole getPgRoleId() { + return pgRoleId; + } + + public void setPgRoleId(PgRole pgRoleId) { + this.pgRoleId = pgRoleId; + } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "patrolerId") public List getPgAlarms() { return pgAlarms; @@ -106,4 +120,4 @@ public void setPgLogs(List pgLogs) { this.pgLogs = pgLogs; } -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java new file mode 100644 index 0000000..2468612 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java @@ -0,0 +1,48 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAuthority; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ + +public class PgAuthorityDto implements Serializable { + + private String id; + private String authority; + private String concent; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + public PgAuthorityDto(PgAuthority pgAuthority) + { + this.setId(String.valueOf(pgAuthority.getId())); + this.setAuthority(pgAuthority.getAuthority()); + this.setConcent(pgAuthority.getConcent()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java index 602d295..620bbf3 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java @@ -73,7 +73,7 @@ this.setBeginTime(sdf.format(pgMaintain.getBeginTime())); this.setTimeLimt(pgMaintain.getTimeLimt()); this.setDescribe(pgMaintain.getDescribe()); - this.setActive(pgMaintain.getActive()); + this.setActive(String.valueOf(pgMaintain.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java index 65ae5b3..39fd3c5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java @@ -74,7 +74,7 @@ this.setBeginTime(sdf.format(pgPatrol.getBeginTime())); this.setTimeLimt(pgPatrol.getTimeLimt()); this.setDescribe(pgPatrol.getDescribe()); - this.setActive(pgPatrol.getActive()); + this.setActive(String.valueOf(pgPatrol.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java new file mode 100644 index 0000000..7c7e004 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgRole; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ +public class PgRoleDto implements Serializable { + + private String id; + private String role; + private String active; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgRoleDto(PgRole pgRole) + { + this.setId(String.valueOf(pgRole.getId())); + this.setRole(pgRole.getRole()); + this.setActive(String.valueOf(pgRole.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java new file mode 100644 index 0000000..12f92a9 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.dto.PgAuthorityDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgAuthorityManager extends HibernateEntityDao{ + + public PgAuthority getAuthorityByAuthority(String authority) { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("authority", authority)); + criteria.add(Restrictions.eq("active", 1)); + List pgAuthorityList = criteria.list(); + + if (pgAuthorityList == null || pgAuthorityList.size() == 0) + return null; + else + return pgAuthorityList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getAuthorityList() + { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgAuthorityList = criteria.list(); + List pgAuthorityDtoList=new ArrayList(); + for(PgAuthority pgAuthority : pgAuthorityList) + { + pgAuthorityDtoList.add(new PgAuthorityDto(pgAuthority)); + } + + return pgAuthorityDtoList; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java new file mode 100644 index 0000000..66b272b --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgRole; +import com.casic.PgInterface.patroler.dto.PgRoleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgRoleManager extends HibernateEntityDao { + + public PgRole getPgRoleByRole(String role) { + try { + Criteria criteria = createCriteria(PgRole.class); + criteria.add(Restrictions.eq("role", role)); + criteria.add(Restrictions.eq("active", 1)); + List pgRoleList = criteria.list(); + + if (pgRoleList == null || pgRoleList.size() == 0) + return null; + else + return pgRoleList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getPgRoleDtoList() { + try { + Criteria criteria = createCriteria(PgRole.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgRoleList=criteria.list(); + List pgRoleDtoList=new ArrayList(); + for(PgRole pgRole:pgRoleList) + { + pgRoleDtoList.add(new PgRoleDto(pgRole)); + } + return pgRoleDtoList; + } + catch(Exception e) + { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index f28ebdf..d9914a8 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -91,7 +91,8 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("devType") String devType, + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("devType") String devType, @FormParam("highValue") String highValue, @FormParam("lowValue") String lowValue, @FormParam("unit") String unit) throws Exception { @@ -102,7 +103,7 @@ PgAlarmRule pgAlarmRule = null; try { - pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + pgAlarmRule = pgAlarmRuleManager.get(Long.valueOf(id)); if (pgAlarmRule == null) { msg = "不存在报警阈值记录"; result = "false"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java b/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java new file mode 100644 index 0000000..9f8f5f7 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java @@ -0,0 +1,167 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.dto.PgAuthorityDto; +import com.casic.PgInterface.patroler.manager.PgAuthorityManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by yxw on 2018/3/30. + */ +@Component +@Path("pgAuthority") +public class PgAuthorityRs { + private static Logger logger = LoggerFactory.getLogger(PgAuthority.class); + + private PgAuthorityManager pgAuthorityManager; + + @Resource + public void setPgAuthorityManager(PgAuthorityManager pgAuthorityManager) { + this.pgAuthorityManager = pgAuthorityManager; + } + + /** + * 新增权限 + */ + @POST + @Path("addAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map addAuthority(@FormParam("authority") String authority, + @FormParam("concent") String concent) throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try{ + PgAuthority pgAuthority=new PgAuthority(); + + pgAuthority.setAuthority(authority); + pgAuthority.setConcent(concent); + pgAuthority.setActive(1); + + pgAuthorityManager.save(pgAuthority); + msg="用户权限保存成功"; + result="true"; + } + catch(Exception e) { + e.printStackTrace(); + msg = "新增权限失败"; + result = "false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + /* + *编辑角权限信息 + */ + @POST + @Path("editAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map editAuthority(@FormParam("id") String id, + @FormParam("authority") String authority, + @FormParam("concent") String concent) throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + try { + PgAuthority pgAuthority=pgAuthorityManager.get(Long.valueOf(id)); + pgAuthority.setAuthority(authority); + pgAuthority.setConcent(concent); + + pgAuthorityManager.save(pgAuthority); + msg="权限保存成功"; + result="true"; + } + catch(Exception e) + { + e.printStackTrace(); + msg="权限编辑失败"; + result="false"; + } + + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + /** + * 删除信息 + */ + @POST + @Path("deleteAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map deleteAuthority(@FormParam("id") String id)throws Exception { + + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try { + PgAuthority pgAuthority= pgAuthorityManager.get(Long.valueOf(id)); + if(pgAuthority==null) { + msg = "不存在该权限信息"; + result="false"; + } + else + { + pgAuthority.setActive(0); + pgAuthorityManager.save(pgAuthority); + msg="删除权限成功"; + result="true"; + } + }catch(Exception e){ + e.printStackTrace(); + msg="删除权限失败"; + result="false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + return resultMap; + } + + /* +* 获取权限信息 + */ + @POST + @Path("getAuthorityList") + @Produces(MediaType.APPLICATION_JSON) + public Map getAuthorityList() { + Map resultMap = new HashMap(); + String msg = ""; + List pgAuthorityDtoList = new ArrayList(); + try { + pgAuthorityDtoList = pgAuthorityManager.getAuthorityList(); + if (pgAuthorityDtoList == null) + msg = "不存在权限信息"; + else + msg = "权限信息获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "权限信息获取是失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAuthorityDtoList); + return resultMap; + } + + + + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java b/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java index 1843bdf..a310aeb 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java @@ -54,7 +54,7 @@ pgMaintain.setBeginTime(sdf.parse(beginTime)); pgMaintain.setTimeLimt(timeLimt); pgMaintain.setDescribe(describe); - pgMaintain.setActive("1"); + pgMaintain.setActive(1); pgMaintainManager.save(pgMaintain); result = "true"; @@ -86,7 +86,7 @@ String result = ""; String msg = ""; try { - PgMaintain pgMaintain = pgMaintainManager.get(id); + PgMaintain pgMaintain = pgMaintainManager.get(Long.valueOf(id)); pgMaintain.setMainTainer(mainTainer); pgMaintain.setBeginTime(sdf.parse(beginTime)); diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java new file mode 100644 index 0000000..a76886e --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java @@ -0,0 +1,73 @@ +package com.casic.PgInterface.patroler.domain; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/3/19. + */ +@Entity +@Table(name = "PG_ROLE") +@SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) +public class PgRole implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String role; + private int active; + private PgAuthority pgAuthorityId; + private List pgUsers; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "ROLE") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "AUTHORITYID") + public PgAuthority getPgAuthorityId() { + return pgAuthorityId; + } + + public void setPgAuthorityId(PgAuthority pgAuthorityId) { + this.pgAuthorityId = pgAuthorityId; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") + public List getPgUsers() { + return pgUsers; + } + + public void setPgUsers(List pgUsers) { + this.pgUsers = pgUsers; + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java index 85301a9..b68a985 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java @@ -1,6 +1,8 @@ package com.casic.PgInterface.patroler.domain; import com.casic.PgInterface.devTable.domain.PgAlarm; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; @@ -22,6 +24,7 @@ private String post;//职务 private String phoneNumber;//电话 private int active;//状态位 + private PgRole pgRoleId;//权限 private List pgAlarms; private List pgLogs; @@ -89,6 +92,17 @@ this.active = active; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "ROLEID") + public PgRole getPgRoleId() { + return pgRoleId; + } + + public void setPgRoleId(PgRole pgRoleId) { + this.pgRoleId = pgRoleId; + } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "patrolerId") public List getPgAlarms() { return pgAlarms; @@ -106,4 +120,4 @@ public void setPgLogs(List pgLogs) { this.pgLogs = pgLogs; } -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java new file mode 100644 index 0000000..2468612 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java @@ -0,0 +1,48 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAuthority; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ + +public class PgAuthorityDto implements Serializable { + + private String id; + private String authority; + private String concent; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + public PgAuthorityDto(PgAuthority pgAuthority) + { + this.setId(String.valueOf(pgAuthority.getId())); + this.setAuthority(pgAuthority.getAuthority()); + this.setConcent(pgAuthority.getConcent()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java index 602d295..620bbf3 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java @@ -73,7 +73,7 @@ this.setBeginTime(sdf.format(pgMaintain.getBeginTime())); this.setTimeLimt(pgMaintain.getTimeLimt()); this.setDescribe(pgMaintain.getDescribe()); - this.setActive(pgMaintain.getActive()); + this.setActive(String.valueOf(pgMaintain.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java index 65ae5b3..39fd3c5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java @@ -74,7 +74,7 @@ this.setBeginTime(sdf.format(pgPatrol.getBeginTime())); this.setTimeLimt(pgPatrol.getTimeLimt()); this.setDescribe(pgPatrol.getDescribe()); - this.setActive(pgPatrol.getActive()); + this.setActive(String.valueOf(pgPatrol.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java new file mode 100644 index 0000000..7c7e004 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgRole; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ +public class PgRoleDto implements Serializable { + + private String id; + private String role; + private String active; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgRoleDto(PgRole pgRole) + { + this.setId(String.valueOf(pgRole.getId())); + this.setRole(pgRole.getRole()); + this.setActive(String.valueOf(pgRole.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java new file mode 100644 index 0000000..12f92a9 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.dto.PgAuthorityDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgAuthorityManager extends HibernateEntityDao{ + + public PgAuthority getAuthorityByAuthority(String authority) { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("authority", authority)); + criteria.add(Restrictions.eq("active", 1)); + List pgAuthorityList = criteria.list(); + + if (pgAuthorityList == null || pgAuthorityList.size() == 0) + return null; + else + return pgAuthorityList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getAuthorityList() + { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgAuthorityList = criteria.list(); + List pgAuthorityDtoList=new ArrayList(); + for(PgAuthority pgAuthority : pgAuthorityList) + { + pgAuthorityDtoList.add(new PgAuthorityDto(pgAuthority)); + } + + return pgAuthorityDtoList; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java new file mode 100644 index 0000000..66b272b --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgRole; +import com.casic.PgInterface.patroler.dto.PgRoleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgRoleManager extends HibernateEntityDao { + + public PgRole getPgRoleByRole(String role) { + try { + Criteria criteria = createCriteria(PgRole.class); + criteria.add(Restrictions.eq("role", role)); + criteria.add(Restrictions.eq("active", 1)); + List pgRoleList = criteria.list(); + + if (pgRoleList == null || pgRoleList.size() == 0) + return null; + else + return pgRoleList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getPgRoleDtoList() { + try { + Criteria criteria = createCriteria(PgRole.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgRoleList=criteria.list(); + List pgRoleDtoList=new ArrayList(); + for(PgRole pgRole:pgRoleList) + { + pgRoleDtoList.add(new PgRoleDto(pgRole)); + } + return pgRoleDtoList; + } + catch(Exception e) + { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index f28ebdf..d9914a8 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -91,7 +91,8 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("devType") String devType, + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("devType") String devType, @FormParam("highValue") String highValue, @FormParam("lowValue") String lowValue, @FormParam("unit") String unit) throws Exception { @@ -102,7 +103,7 @@ PgAlarmRule pgAlarmRule = null; try { - pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + pgAlarmRule = pgAlarmRuleManager.get(Long.valueOf(id)); if (pgAlarmRule == null) { msg = "不存在报警阈值记录"; result = "false"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java b/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java new file mode 100644 index 0000000..9f8f5f7 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java @@ -0,0 +1,167 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.dto.PgAuthorityDto; +import com.casic.PgInterface.patroler.manager.PgAuthorityManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by yxw on 2018/3/30. + */ +@Component +@Path("pgAuthority") +public class PgAuthorityRs { + private static Logger logger = LoggerFactory.getLogger(PgAuthority.class); + + private PgAuthorityManager pgAuthorityManager; + + @Resource + public void setPgAuthorityManager(PgAuthorityManager pgAuthorityManager) { + this.pgAuthorityManager = pgAuthorityManager; + } + + /** + * 新增权限 + */ + @POST + @Path("addAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map addAuthority(@FormParam("authority") String authority, + @FormParam("concent") String concent) throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try{ + PgAuthority pgAuthority=new PgAuthority(); + + pgAuthority.setAuthority(authority); + pgAuthority.setConcent(concent); + pgAuthority.setActive(1); + + pgAuthorityManager.save(pgAuthority); + msg="用户权限保存成功"; + result="true"; + } + catch(Exception e) { + e.printStackTrace(); + msg = "新增权限失败"; + result = "false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + /* + *编辑角权限信息 + */ + @POST + @Path("editAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map editAuthority(@FormParam("id") String id, + @FormParam("authority") String authority, + @FormParam("concent") String concent) throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + try { + PgAuthority pgAuthority=pgAuthorityManager.get(Long.valueOf(id)); + pgAuthority.setAuthority(authority); + pgAuthority.setConcent(concent); + + pgAuthorityManager.save(pgAuthority); + msg="权限保存成功"; + result="true"; + } + catch(Exception e) + { + e.printStackTrace(); + msg="权限编辑失败"; + result="false"; + } + + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + /** + * 删除信息 + */ + @POST + @Path("deleteAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map deleteAuthority(@FormParam("id") String id)throws Exception { + + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try { + PgAuthority pgAuthority= pgAuthorityManager.get(Long.valueOf(id)); + if(pgAuthority==null) { + msg = "不存在该权限信息"; + result="false"; + } + else + { + pgAuthority.setActive(0); + pgAuthorityManager.save(pgAuthority); + msg="删除权限成功"; + result="true"; + } + }catch(Exception e){ + e.printStackTrace(); + msg="删除权限失败"; + result="false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + return resultMap; + } + + /* +* 获取权限信息 + */ + @POST + @Path("getAuthorityList") + @Produces(MediaType.APPLICATION_JSON) + public Map getAuthorityList() { + Map resultMap = new HashMap(); + String msg = ""; + List pgAuthorityDtoList = new ArrayList(); + try { + pgAuthorityDtoList = pgAuthorityManager.getAuthorityList(); + if (pgAuthorityDtoList == null) + msg = "不存在权限信息"; + else + msg = "权限信息获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "权限信息获取是失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAuthorityDtoList); + return resultMap; + } + + + + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java b/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java index 1843bdf..a310aeb 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java @@ -54,7 +54,7 @@ pgMaintain.setBeginTime(sdf.parse(beginTime)); pgMaintain.setTimeLimt(timeLimt); pgMaintain.setDescribe(describe); - pgMaintain.setActive("1"); + pgMaintain.setActive(1); pgMaintainManager.save(pgMaintain); result = "true"; @@ -86,7 +86,7 @@ String result = ""; String msg = ""; try { - PgMaintain pgMaintain = pgMaintainManager.get(id); + PgMaintain pgMaintain = pgMaintainManager.get(Long.valueOf(id)); pgMaintain.setMainTainer(mainTainer); pgMaintain.setBeginTime(sdf.parse(beginTime)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgPatrolRs.java b/src/main/java/com/casic/PgInterface/rs/PgPatrolRs.java index 8bd163b..65864cd 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPatrolRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPatrolRs.java @@ -86,7 +86,7 @@ String result = ""; String msg = ""; try { - PgPatrol pgPatrol = pgPatrolManager.get(id); + PgPatrol pgPatrol = pgPatrolManager.get(Long.valueOf(id)); pgPatrol.setPatroler(patroler); pgPatrol.setBeginTime(sdf.parse(beginTime)); diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java new file mode 100644 index 0000000..a76886e --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java @@ -0,0 +1,73 @@ +package com.casic.PgInterface.patroler.domain; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/3/19. + */ +@Entity +@Table(name = "PG_ROLE") +@SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) +public class PgRole implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String role; + private int active; + private PgAuthority pgAuthorityId; + private List pgUsers; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "ROLE") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "AUTHORITYID") + public PgAuthority getPgAuthorityId() { + return pgAuthorityId; + } + + public void setPgAuthorityId(PgAuthority pgAuthorityId) { + this.pgAuthorityId = pgAuthorityId; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") + public List getPgUsers() { + return pgUsers; + } + + public void setPgUsers(List pgUsers) { + this.pgUsers = pgUsers; + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java index 85301a9..b68a985 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java @@ -1,6 +1,8 @@ package com.casic.PgInterface.patroler.domain; import com.casic.PgInterface.devTable.domain.PgAlarm; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; @@ -22,6 +24,7 @@ private String post;//职务 private String phoneNumber;//电话 private int active;//状态位 + private PgRole pgRoleId;//权限 private List pgAlarms; private List pgLogs; @@ -89,6 +92,17 @@ this.active = active; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "ROLEID") + public PgRole getPgRoleId() { + return pgRoleId; + } + + public void setPgRoleId(PgRole pgRoleId) { + this.pgRoleId = pgRoleId; + } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "patrolerId") public List getPgAlarms() { return pgAlarms; @@ -106,4 +120,4 @@ public void setPgLogs(List pgLogs) { this.pgLogs = pgLogs; } -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java new file mode 100644 index 0000000..2468612 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java @@ -0,0 +1,48 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAuthority; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ + +public class PgAuthorityDto implements Serializable { + + private String id; + private String authority; + private String concent; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + public PgAuthorityDto(PgAuthority pgAuthority) + { + this.setId(String.valueOf(pgAuthority.getId())); + this.setAuthority(pgAuthority.getAuthority()); + this.setConcent(pgAuthority.getConcent()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java index 602d295..620bbf3 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java @@ -73,7 +73,7 @@ this.setBeginTime(sdf.format(pgMaintain.getBeginTime())); this.setTimeLimt(pgMaintain.getTimeLimt()); this.setDescribe(pgMaintain.getDescribe()); - this.setActive(pgMaintain.getActive()); + this.setActive(String.valueOf(pgMaintain.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java index 65ae5b3..39fd3c5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java @@ -74,7 +74,7 @@ this.setBeginTime(sdf.format(pgPatrol.getBeginTime())); this.setTimeLimt(pgPatrol.getTimeLimt()); this.setDescribe(pgPatrol.getDescribe()); - this.setActive(pgPatrol.getActive()); + this.setActive(String.valueOf(pgPatrol.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java new file mode 100644 index 0000000..7c7e004 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgRole; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ +public class PgRoleDto implements Serializable { + + private String id; + private String role; + private String active; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgRoleDto(PgRole pgRole) + { + this.setId(String.valueOf(pgRole.getId())); + this.setRole(pgRole.getRole()); + this.setActive(String.valueOf(pgRole.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java new file mode 100644 index 0000000..12f92a9 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.dto.PgAuthorityDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgAuthorityManager extends HibernateEntityDao{ + + public PgAuthority getAuthorityByAuthority(String authority) { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("authority", authority)); + criteria.add(Restrictions.eq("active", 1)); + List pgAuthorityList = criteria.list(); + + if (pgAuthorityList == null || pgAuthorityList.size() == 0) + return null; + else + return pgAuthorityList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getAuthorityList() + { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgAuthorityList = criteria.list(); + List pgAuthorityDtoList=new ArrayList(); + for(PgAuthority pgAuthority : pgAuthorityList) + { + pgAuthorityDtoList.add(new PgAuthorityDto(pgAuthority)); + } + + return pgAuthorityDtoList; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java new file mode 100644 index 0000000..66b272b --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgRole; +import com.casic.PgInterface.patroler.dto.PgRoleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgRoleManager extends HibernateEntityDao { + + public PgRole getPgRoleByRole(String role) { + try { + Criteria criteria = createCriteria(PgRole.class); + criteria.add(Restrictions.eq("role", role)); + criteria.add(Restrictions.eq("active", 1)); + List pgRoleList = criteria.list(); + + if (pgRoleList == null || pgRoleList.size() == 0) + return null; + else + return pgRoleList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getPgRoleDtoList() { + try { + Criteria criteria = createCriteria(PgRole.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgRoleList=criteria.list(); + List pgRoleDtoList=new ArrayList(); + for(PgRole pgRole:pgRoleList) + { + pgRoleDtoList.add(new PgRoleDto(pgRole)); + } + return pgRoleDtoList; + } + catch(Exception e) + { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index f28ebdf..d9914a8 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -91,7 +91,8 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("devType") String devType, + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("devType") String devType, @FormParam("highValue") String highValue, @FormParam("lowValue") String lowValue, @FormParam("unit") String unit) throws Exception { @@ -102,7 +103,7 @@ PgAlarmRule pgAlarmRule = null; try { - pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + pgAlarmRule = pgAlarmRuleManager.get(Long.valueOf(id)); if (pgAlarmRule == null) { msg = "不存在报警阈值记录"; result = "false"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java b/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java new file mode 100644 index 0000000..9f8f5f7 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java @@ -0,0 +1,167 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.dto.PgAuthorityDto; +import com.casic.PgInterface.patroler.manager.PgAuthorityManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by yxw on 2018/3/30. + */ +@Component +@Path("pgAuthority") +public class PgAuthorityRs { + private static Logger logger = LoggerFactory.getLogger(PgAuthority.class); + + private PgAuthorityManager pgAuthorityManager; + + @Resource + public void setPgAuthorityManager(PgAuthorityManager pgAuthorityManager) { + this.pgAuthorityManager = pgAuthorityManager; + } + + /** + * 新增权限 + */ + @POST + @Path("addAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map addAuthority(@FormParam("authority") String authority, + @FormParam("concent") String concent) throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try{ + PgAuthority pgAuthority=new PgAuthority(); + + pgAuthority.setAuthority(authority); + pgAuthority.setConcent(concent); + pgAuthority.setActive(1); + + pgAuthorityManager.save(pgAuthority); + msg="用户权限保存成功"; + result="true"; + } + catch(Exception e) { + e.printStackTrace(); + msg = "新增权限失败"; + result = "false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + /* + *编辑角权限信息 + */ + @POST + @Path("editAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map editAuthority(@FormParam("id") String id, + @FormParam("authority") String authority, + @FormParam("concent") String concent) throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + try { + PgAuthority pgAuthority=pgAuthorityManager.get(Long.valueOf(id)); + pgAuthority.setAuthority(authority); + pgAuthority.setConcent(concent); + + pgAuthorityManager.save(pgAuthority); + msg="权限保存成功"; + result="true"; + } + catch(Exception e) + { + e.printStackTrace(); + msg="权限编辑失败"; + result="false"; + } + + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + /** + * 删除信息 + */ + @POST + @Path("deleteAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map deleteAuthority(@FormParam("id") String id)throws Exception { + + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try { + PgAuthority pgAuthority= pgAuthorityManager.get(Long.valueOf(id)); + if(pgAuthority==null) { + msg = "不存在该权限信息"; + result="false"; + } + else + { + pgAuthority.setActive(0); + pgAuthorityManager.save(pgAuthority); + msg="删除权限成功"; + result="true"; + } + }catch(Exception e){ + e.printStackTrace(); + msg="删除权限失败"; + result="false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + return resultMap; + } + + /* +* 获取权限信息 + */ + @POST + @Path("getAuthorityList") + @Produces(MediaType.APPLICATION_JSON) + public Map getAuthorityList() { + Map resultMap = new HashMap(); + String msg = ""; + List pgAuthorityDtoList = new ArrayList(); + try { + pgAuthorityDtoList = pgAuthorityManager.getAuthorityList(); + if (pgAuthorityDtoList == null) + msg = "不存在权限信息"; + else + msg = "权限信息获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "权限信息获取是失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAuthorityDtoList); + return resultMap; + } + + + + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java b/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java index 1843bdf..a310aeb 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java @@ -54,7 +54,7 @@ pgMaintain.setBeginTime(sdf.parse(beginTime)); pgMaintain.setTimeLimt(timeLimt); pgMaintain.setDescribe(describe); - pgMaintain.setActive("1"); + pgMaintain.setActive(1); pgMaintainManager.save(pgMaintain); result = "true"; @@ -86,7 +86,7 @@ String result = ""; String msg = ""; try { - PgMaintain pgMaintain = pgMaintainManager.get(id); + PgMaintain pgMaintain = pgMaintainManager.get(Long.valueOf(id)); pgMaintain.setMainTainer(mainTainer); pgMaintain.setBeginTime(sdf.parse(beginTime)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgPatrolRs.java b/src/main/java/com/casic/PgInterface/rs/PgPatrolRs.java index 8bd163b..65864cd 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPatrolRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPatrolRs.java @@ -86,7 +86,7 @@ String result = ""; String msg = ""; try { - PgPatrol pgPatrol = pgPatrolManager.get(id); + PgPatrol pgPatrol = pgPatrolManager.get(Long.valueOf(id)); pgPatrol.setPatroler(patroler); pgPatrol.setBeginTime(sdf.parse(beginTime)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgRoleRs.java b/src/main/java/com/casic/PgInterface/rs/PgRoleRs.java new file mode 100644 index 0000000..6603907 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgRoleRs.java @@ -0,0 +1,176 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.domain.PgRole; +import com.casic.PgInterface.patroler.dto.PgRoleDto; +import com.casic.PgInterface.patroler.manager.PgAuthorityManager; +import com.casic.PgInterface.patroler.manager.PgRoleManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by yxw on 2018/3/30. + */ +@Component +@Path("pgRole") +public class PgRoleRs { + + private static Logger logger = LoggerFactory.getLogger(PgRole.class); + + private PgRoleManager pgRoleManager; + + private PgAuthorityManager pgAuthorityManager; + + @Resource + public void setPgRoleManager(PgRoleManager pgRoleManager) { + this.pgRoleManager = pgRoleManager; + } + + @Resource + public void setPgAuthorityManager(PgAuthorityManager pgAuthorityManager) { + this.pgAuthorityManager = pgAuthorityManager; + } + + /* + * 获取角色信息 + */ + @POST + @Path("getRoleList") + @Produces(MediaType.APPLICATION_JSON) + public Map getRoleList() { + Map resultMap = new HashMap(); + String msg = ""; + List pgRoleDtoList = new ArrayList(); + try { + pgRoleDtoList = pgRoleManager.getPgRoleDtoList(); + if (pgRoleDtoList == null) + msg = "不存在角色信息"; + else + msg = "角色信息获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "角色信息获取是失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgRoleDtoList); + return resultMap; + } + + /** + * 新增角色 + */ + @POST + @Path("addRole") + @Produces(MediaType.APPLICATION_JSON) + public Map addRole(@FormParam("role") String role, + @FormParam("authority") String authority) throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try{ + PgAuthority pgAuthority=pgAuthorityManager.getAuthorityByAuthority(authority); + PgRole pgRole=new PgRole(); + pgRole.setRole(role); + pgRole.setPgAuthorityId(pgAuthority); + pgRole.setActive(1); + + pgRoleManager.save(pgRole); + msg="用户角色保存成功"; + result="true"; + } + catch(Exception e) { + e.printStackTrace(); + msg = "新增角色失败"; + result = "false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + /* + *编辑角色信息 + */ + @POST + @Path("editRole") + @Produces(MediaType.APPLICATION_JSON) + public Map editRole(@FormParam("id") String id, + @FormParam("role") String role, + @FormParam("authority") String authority) throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + try { + PgRole pgRole = pgRoleManager.get(Long.valueOf(id)); + + PgAuthority pgAuthority = pgAuthorityManager.getAuthorityByAuthority(authority); + pgRole.setRole(role); + pgRole.setPgAuthorityId(pgAuthority); + pgRoleManager.save(pgRole); + + msg="角色保存成功"; + result="true"; + } + catch(Exception e) + { + e.printStackTrace(); + msg="角色编辑失败"; + result="false"; + } + + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + /** + * 删除信息 + */ + @POST + @Path("deleteRole") + @Produces(MediaType.APPLICATION_JSON) + public Map deleteRole(@FormParam("id") String id)throws Exception { + + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try { + PgRole pgRole= pgRoleManager.get(Long.valueOf(id)); + if(pgRole==null) { + msg = "不存在该角色信息"; + result="false"; + } + else + { + pgRole.setActive(0); + pgRoleManager.save(pgRole); + msg="删除角色成功"; + result="true"; + } + }catch(Exception e){ + e.printStackTrace(); + msg="删除角色失败"; + result="false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + return resultMap; + } + +} diff --git a/.idea/workspace.xml b/.idea/workspace.xml index f2db547..6b88684 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,23 @@ - - - + + + + + + + + + + + + + + + + + @@ -47,10 +61,6 @@ @@ -291,8 +310,34 @@ - @@ -1149,7 +1006,7 @@ - + @@ -1206,11 +1063,12 @@ - - @@ -1218,144 +1076,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1398,14 +1118,6 @@ - - - - - - - - @@ -1414,16 +1126,6 @@ - - - - - - - - - - @@ -1432,33 +1134,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1475,80 +1150,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1568,14 +1169,6 @@ - - - - - - - - @@ -1591,50 +1184,21 @@ - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -1672,16 +1236,6 @@ - - - - - - - - - - @@ -1697,23 +1251,7 @@ - - - - - - - - - - - - - - - - - + @@ -1726,10 +1264,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -1738,13 +1342,261 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java index 21e6c47..ea7ba63 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgAuthority.java @@ -1,8 +1,67 @@ package com.casic.PgInterface.patroler.domain; +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + /** - * Created by yxw on 2018/3/19. + * Created by yxw on 2018/3/30. */ -public class PgAuthority { +@Entity +@Table(name = "PG_AUTHORITY") +@SequenceGenerator(name = "SEQ_PG_AUTHORITY_ID", sequenceName = "SEQ_PG_AUTHORITY_ID",allocationSize=1,initialValue=1) +public class PgAuthority implements Serializable { + private static final long serialVersionUID = 1L; + private long id; + private String authority; + private String concent; + private int active; + private List pgRoles; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_AUTHORITY_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "AUTHORITY") + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Column(name = "CONCENT") + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgAuthorityId") + public List getPgRoles() { + return pgRoles; + } + + public void setPgRoles(List pgRoles) { + this.pgRoles = pgRoles; + } } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java index efd87d9..4e962d5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgMaintain.java @@ -17,7 +17,7 @@ private Date beginTime;//开始时间 private String timeLimt;//计划工期 private String describe;//任务描述 - private String active;//状态位 + private int active;//状态位 @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_MAINTAIN_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java index 7ce01a5..27fbf99 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgPatrol.java @@ -17,7 +17,7 @@ private Date beginTime; private String timeLimt; private String describe; - private String active; + private int active; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PATROL_ID") @@ -66,12 +66,11 @@ } @Column(name = "ACTIVE") - public String getActive() { + public int getActive() { return active; } - public void setActive(String active) { + public void setActive(int active) { this.active = active; } - } diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java new file mode 100644 index 0000000..a76886e --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgRole.java @@ -0,0 +1,73 @@ +package com.casic.PgInterface.patroler.domain; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.io.Serializable; +import java.util.List; + +/** + * Created by yxw on 2018/3/19. + */ +@Entity +@Table(name = "PG_ROLE") +@SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) +public class PgRole implements Serializable { + + private static final long serialVersionUID = 1L; + private long id; + private String role; + private int active; + private PgAuthority pgAuthorityId; + private List pgUsers; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + @Column(name = "ROLE") + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + @Column(name = "ACTIVE") + public int getActive() { + return active; + } + + public void setActive(int active) { + this.active = active; + } + + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "AUTHORITYID") + public PgAuthority getPgAuthorityId() { + return pgAuthorityId; + } + + public void setPgAuthorityId(PgAuthority pgAuthorityId) { + this.pgAuthorityId = pgAuthorityId; + } + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") + public List getPgUsers() { + return pgUsers; + } + + public void setPgUsers(List pgUsers) { + this.pgUsers = pgUsers; + } + +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java index 85301a9..b68a985 100644 --- a/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java +++ b/src/main/java/com/casic/PgInterface/patroler/domain/PgUser.java @@ -1,6 +1,8 @@ package com.casic.PgInterface.patroler.domain; import com.casic.PgInterface.devTable.domain.PgAlarm; +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; import javax.persistence.*; import java.io.Serializable; @@ -22,6 +24,7 @@ private String post;//职务 private String phoneNumber;//电话 private int active;//状态位 + private PgRole pgRoleId;//权限 private List pgAlarms; private List pgLogs; @@ -89,6 +92,17 @@ this.active = active; } + @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST}) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "ROLEID") + public PgRole getPgRoleId() { + return pgRoleId; + } + + public void setPgRoleId(PgRole pgRoleId) { + this.pgRoleId = pgRoleId; + } + @OneToMany(fetch = FetchType.LAZY, mappedBy = "patrolerId") public List getPgAlarms() { return pgAlarms; @@ -106,4 +120,4 @@ public void setPgLogs(List pgLogs) { this.pgLogs = pgLogs; } -} +} \ No newline at end of file diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java new file mode 100644 index 0000000..2468612 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgAuthorityDto.java @@ -0,0 +1,48 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgAuthority; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ + +public class PgAuthorityDto implements Serializable { + + private String id; + private String authority; + private String concent; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAuthority() { + return authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + public String getConcent() { + return concent; + } + + public void setConcent(String concent) { + this.concent = concent; + } + + public PgAuthorityDto(PgAuthority pgAuthority) + { + this.setId(String.valueOf(pgAuthority.getId())); + this.setAuthority(pgAuthority.getAuthority()); + this.setConcent(pgAuthority.getConcent()); + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java index 602d295..620bbf3 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgMaintainDto.java @@ -73,7 +73,7 @@ this.setBeginTime(sdf.format(pgMaintain.getBeginTime())); this.setTimeLimt(pgMaintain.getTimeLimt()); this.setDescribe(pgMaintain.getDescribe()); - this.setActive(pgMaintain.getActive()); + this.setActive(String.valueOf(pgMaintain.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java index 65ae5b3..39fd3c5 100644 --- a/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgPatrolDto.java @@ -74,7 +74,7 @@ this.setBeginTime(sdf.format(pgPatrol.getBeginTime())); this.setTimeLimt(pgPatrol.getTimeLimt()); this.setDescribe(pgPatrol.getDescribe()); - this.setActive(pgPatrol.getActive()); + this.setActive(String.valueOf(pgPatrol.getActive())); } } diff --git a/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java new file mode 100644 index 0000000..7c7e004 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/dto/PgRoleDto.java @@ -0,0 +1,46 @@ +package com.casic.PgInterface.patroler.dto; + +import com.casic.PgInterface.patroler.domain.PgRole; + +import java.io.Serializable; + +/** + * Created by yxw on 2018/3/30. + */ +public class PgRoleDto implements Serializable { + + private String id; + private String role; + private String active; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getActive() { + return active; + } + + public void setActive(String active) { + this.active = active; + } + + public PgRoleDto(PgRole pgRole) + { + this.setId(String.valueOf(pgRole.getId())); + this.setRole(pgRole.getRole()); + this.setActive(String.valueOf(pgRole.getActive())); + } +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java new file mode 100644 index 0000000..12f92a9 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgAuthorityManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.dto.PgAuthorityDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgAuthorityManager extends HibernateEntityDao{ + + public PgAuthority getAuthorityByAuthority(String authority) { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("authority", authority)); + criteria.add(Restrictions.eq("active", 1)); + List pgAuthorityList = criteria.list(); + + if (pgAuthorityList == null || pgAuthorityList.size() == 0) + return null; + else + return pgAuthorityList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getAuthorityList() + { + try { + Criteria criteria = createCriteria(PgAuthority.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgAuthorityList = criteria.list(); + List pgAuthorityDtoList=new ArrayList(); + for(PgAuthority pgAuthority : pgAuthorityList) + { + pgAuthorityDtoList.add(new PgAuthorityDto(pgAuthority)); + } + + return pgAuthorityDtoList; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java b/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java new file mode 100644 index 0000000..66b272b --- /dev/null +++ b/src/main/java/com/casic/PgInterface/patroler/manager/PgRoleManager.java @@ -0,0 +1,56 @@ +package com.casic.PgInterface.patroler.manager; + +import com.casic.PgInterface.core.hibernate.HibernateEntityDao; +import com.casic.PgInterface.patroler.domain.PgRole; +import com.casic.PgInterface.patroler.dto.PgRoleDto; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by yxw on 2018/3/30. + */ +@Service +public class PgRoleManager extends HibernateEntityDao { + + public PgRole getPgRoleByRole(String role) { + try { + Criteria criteria = createCriteria(PgRole.class); + criteria.add(Restrictions.eq("role", role)); + criteria.add(Restrictions.eq("active", 1)); + List pgRoleList = criteria.list(); + + if (pgRoleList == null || pgRoleList.size() == 0) + return null; + else + return pgRoleList.get(0); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + public List getPgRoleDtoList() { + try { + Criteria criteria = createCriteria(PgRole.class); + criteria.add(Restrictions.eq("active", 1)); + + List pgRoleList=criteria.list(); + List pgRoleDtoList=new ArrayList(); + for(PgRole pgRole:pgRoleList) + { + pgRoleDtoList.add(new PgRoleDto(pgRole)); + } + return pgRoleDtoList; + } + catch(Exception e) + { + e.printStackTrace(); + return null; + } + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java index f28ebdf..d9914a8 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgAlarmRuleRs.java @@ -91,7 +91,8 @@ @POST @Path("editAlarmRule") @Produces(MediaType.APPLICATION_JSON) - public Map editAlarmRule(@FormParam("devType") String devType, + public Map editAlarmRule(@FormParam("id") String id, + @FormParam("devType") String devType, @FormParam("highValue") String highValue, @FormParam("lowValue") String lowValue, @FormParam("unit") String unit) throws Exception { @@ -102,7 +103,7 @@ PgAlarmRule pgAlarmRule = null; try { - pgAlarmRule = pgAlarmRuleManager.getAlarmRuleBydevType(devType); + pgAlarmRule = pgAlarmRuleManager.get(Long.valueOf(id)); if (pgAlarmRule == null) { msg = "不存在报警阈值记录"; result = "false"; diff --git a/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java b/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java new file mode 100644 index 0000000..9f8f5f7 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgAuthorityRs.java @@ -0,0 +1,167 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.dto.PgAuthorityDto; +import com.casic.PgInterface.patroler.manager.PgAuthorityManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by yxw on 2018/3/30. + */ +@Component +@Path("pgAuthority") +public class PgAuthorityRs { + private static Logger logger = LoggerFactory.getLogger(PgAuthority.class); + + private PgAuthorityManager pgAuthorityManager; + + @Resource + public void setPgAuthorityManager(PgAuthorityManager pgAuthorityManager) { + this.pgAuthorityManager = pgAuthorityManager; + } + + /** + * 新增权限 + */ + @POST + @Path("addAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map addAuthority(@FormParam("authority") String authority, + @FormParam("concent") String concent) throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try{ + PgAuthority pgAuthority=new PgAuthority(); + + pgAuthority.setAuthority(authority); + pgAuthority.setConcent(concent); + pgAuthority.setActive(1); + + pgAuthorityManager.save(pgAuthority); + msg="用户权限保存成功"; + result="true"; + } + catch(Exception e) { + e.printStackTrace(); + msg = "新增权限失败"; + result = "false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + /* + *编辑角权限信息 + */ + @POST + @Path("editAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map editAuthority(@FormParam("id") String id, + @FormParam("authority") String authority, + @FormParam("concent") String concent) throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + try { + PgAuthority pgAuthority=pgAuthorityManager.get(Long.valueOf(id)); + pgAuthority.setAuthority(authority); + pgAuthority.setConcent(concent); + + pgAuthorityManager.save(pgAuthority); + msg="权限保存成功"; + result="true"; + } + catch(Exception e) + { + e.printStackTrace(); + msg="权限编辑失败"; + result="false"; + } + + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + /** + * 删除信息 + */ + @POST + @Path("deleteAuthority") + @Produces(MediaType.APPLICATION_JSON) + public Map deleteAuthority(@FormParam("id") String id)throws Exception { + + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try { + PgAuthority pgAuthority= pgAuthorityManager.get(Long.valueOf(id)); + if(pgAuthority==null) { + msg = "不存在该权限信息"; + result="false"; + } + else + { + pgAuthority.setActive(0); + pgAuthorityManager.save(pgAuthority); + msg="删除权限成功"; + result="true"; + } + }catch(Exception e){ + e.printStackTrace(); + msg="删除权限失败"; + result="false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + return resultMap; + } + + /* +* 获取权限信息 + */ + @POST + @Path("getAuthorityList") + @Produces(MediaType.APPLICATION_JSON) + public Map getAuthorityList() { + Map resultMap = new HashMap(); + String msg = ""; + List pgAuthorityDtoList = new ArrayList(); + try { + pgAuthorityDtoList = pgAuthorityManager.getAuthorityList(); + if (pgAuthorityDtoList == null) + msg = "不存在权限信息"; + else + msg = "权限信息获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "权限信息获取是失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgAuthorityDtoList); + return resultMap; + } + + + + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java b/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java index 1843bdf..a310aeb 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgMaintainRs.java @@ -54,7 +54,7 @@ pgMaintain.setBeginTime(sdf.parse(beginTime)); pgMaintain.setTimeLimt(timeLimt); pgMaintain.setDescribe(describe); - pgMaintain.setActive("1"); + pgMaintain.setActive(1); pgMaintainManager.save(pgMaintain); result = "true"; @@ -86,7 +86,7 @@ String result = ""; String msg = ""; try { - PgMaintain pgMaintain = pgMaintainManager.get(id); + PgMaintain pgMaintain = pgMaintainManager.get(Long.valueOf(id)); pgMaintain.setMainTainer(mainTainer); pgMaintain.setBeginTime(sdf.parse(beginTime)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgPatrolRs.java b/src/main/java/com/casic/PgInterface/rs/PgPatrolRs.java index 8bd163b..65864cd 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgPatrolRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgPatrolRs.java @@ -86,7 +86,7 @@ String result = ""; String msg = ""; try { - PgPatrol pgPatrol = pgPatrolManager.get(id); + PgPatrol pgPatrol = pgPatrolManager.get(Long.valueOf(id)); pgPatrol.setPatroler(patroler); pgPatrol.setBeginTime(sdf.parse(beginTime)); diff --git a/src/main/java/com/casic/PgInterface/rs/PgRoleRs.java b/src/main/java/com/casic/PgInterface/rs/PgRoleRs.java new file mode 100644 index 0000000..6603907 --- /dev/null +++ b/src/main/java/com/casic/PgInterface/rs/PgRoleRs.java @@ -0,0 +1,176 @@ +package com.casic.PgInterface.rs; + +import com.casic.PgInterface.patroler.domain.PgAuthority; +import com.casic.PgInterface.patroler.domain.PgRole; +import com.casic.PgInterface.patroler.dto.PgRoleDto; +import com.casic.PgInterface.patroler.manager.PgAuthorityManager; +import com.casic.PgInterface.patroler.manager.PgRoleManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.ws.rs.FormParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Created by yxw on 2018/3/30. + */ +@Component +@Path("pgRole") +public class PgRoleRs { + + private static Logger logger = LoggerFactory.getLogger(PgRole.class); + + private PgRoleManager pgRoleManager; + + private PgAuthorityManager pgAuthorityManager; + + @Resource + public void setPgRoleManager(PgRoleManager pgRoleManager) { + this.pgRoleManager = pgRoleManager; + } + + @Resource + public void setPgAuthorityManager(PgAuthorityManager pgAuthorityManager) { + this.pgAuthorityManager = pgAuthorityManager; + } + + /* + * 获取角色信息 + */ + @POST + @Path("getRoleList") + @Produces(MediaType.APPLICATION_JSON) + public Map getRoleList() { + Map resultMap = new HashMap(); + String msg = ""; + List pgRoleDtoList = new ArrayList(); + try { + pgRoleDtoList = pgRoleManager.getPgRoleDtoList(); + if (pgRoleDtoList == null) + msg = "不存在角色信息"; + else + msg = "角色信息获取成功"; + } catch (Exception e) { + e.printStackTrace(); + msg = "角色信息获取是失败"; + } + resultMap.put("msg", msg); + resultMap.put("result", pgRoleDtoList); + return resultMap; + } + + /** + * 新增角色 + */ + @POST + @Path("addRole") + @Produces(MediaType.APPLICATION_JSON) + public Map addRole(@FormParam("role") String role, + @FormParam("authority") String authority) throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + + try{ + PgAuthority pgAuthority=pgAuthorityManager.getAuthorityByAuthority(authority); + PgRole pgRole=new PgRole(); + pgRole.setRole(role); + pgRole.setPgAuthorityId(pgAuthority); + pgRole.setActive(1); + + pgRoleManager.save(pgRole); + msg="用户角色保存成功"; + result="true"; + } + catch(Exception e) { + e.printStackTrace(); + msg = "新增角色失败"; + result = "false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + /* + *编辑角色信息 + */ + @POST + @Path("editRole") + @Produces(MediaType.APPLICATION_JSON) + public Map editRole(@FormParam("id") String id, + @FormParam("role") String role, + @FormParam("authority") String authority) throws Exception{ + Map resultMap = new HashMap(); + String result = ""; + String msg = ""; + try { + PgRole pgRole = pgRoleManager.get(Long.valueOf(id)); + + PgAuthority pgAuthority = pgAuthorityManager.getAuthorityByAuthority(authority); + pgRole.setRole(role); + pgRole.setPgAuthorityId(pgAuthority); + pgRoleManager.save(pgRole); + + msg="角色保存成功"; + result="true"; + } + catch(Exception e) + { + e.printStackTrace(); + msg="角色编辑失败"; + result="false"; + } + + resultMap.put("msg",msg); + resultMap.put("result",result); + + return resultMap; + } + + /** + * 删除信息 + */ + @POST + @Path("deleteRole") + @Produces(MediaType.APPLICATION_JSON) + public Map deleteRole(@FormParam("id") String id)throws Exception { + + Map resultMap = new HashMap(); + String msg=""; + String result="false"; + + try { + PgRole pgRole= pgRoleManager.get(Long.valueOf(id)); + if(pgRole==null) { + msg = "不存在该角色信息"; + result="false"; + } + else + { + pgRole.setActive(0); + pgRoleManager.save(pgRole); + msg="删除角色成功"; + result="true"; + } + }catch(Exception e){ + e.printStackTrace(); + msg="删除角色失败"; + result="false"; + } + resultMap.put("msg",msg); + resultMap.put("result",result); + return resultMap; + } + +} diff --git a/src/main/java/com/casic/PgInterface/rs/PgUserRs.java b/src/main/java/com/casic/PgInterface/rs/PgUserRs.java index 7f0c8d5..612597e 100644 --- a/src/main/java/com/casic/PgInterface/rs/PgUserRs.java +++ b/src/main/java/com/casic/PgInterface/rs/PgUserRs.java @@ -1,7 +1,9 @@ package com.casic.PgInterface.rs; +import com.casic.PgInterface.patroler.domain.PgRole; import com.casic.PgInterface.patroler.domain.PgUser; import com.casic.PgInterface.patroler.dto.PgUserDto; +import com.casic.PgInterface.patroler.manager.PgRoleManager; import com.casic.PgInterface.patroler.manager.PgUserManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -29,11 +31,18 @@ private PgUserManager pgUserManager; + private PgRoleManager pgRoleManager; + @Resource public void setPgUserManager(PgUserManager pgUserManager) { this.pgUserManager = pgUserManager; } + @Resource + public void setPgRoleManager(PgRoleManager pgRoleManager) { + this.pgRoleManager = pgRoleManager; + } + /** * 显示人员列表 */ @@ -69,12 +78,14 @@ @FormParam("password") String password, @FormParam("department") String department, @FormParam("post") String post, - @FormParam("phoneNumber") String phoneNumber)throws Exception { + @FormParam("phoneNumber") String phoneNumber, + @FormParam("role") String role)throws Exception { Map resultMap = new HashMap(); String result = ""; String msg = ""; try { + PgRole pgRole=pgRoleManager.getPgRoleByRole(role); if (pgUserManager.userNameIsExits(userName)) { result = "false"; @@ -88,6 +99,7 @@ pgUser.setDepartment(department); pgUser.setPost(post); pgUser.setPhoneNumber(phoneNumber); + pgUser.setPgRoleId(pgRole); pgUser.setActive(1); logger.info("成功保存"); @@ -117,7 +129,8 @@ @FormParam("password") String password, @FormParam("department") String department, @FormParam("post") String post, - @FormParam("phoneNumber") String phoneNumber) throws Exception { + @FormParam("phoneNumber") String phoneNumber, + @FormParam("role") String role) throws Exception { Map resultMap = new HashMap(); String result = ""; @@ -129,12 +142,15 @@ msg = "用户名已经存在!"; } else { */ + PgRole pgRole=pgRoleManager.getPgRoleByRole(role); + PgUser pgUser = pgUserManager.get(Long.valueOf(id)); pgUser.setUserName(userName); pgUser.setPassword(password); pgUser.setDepartment(department); pgUser.setPost(post); pgUser.setPhoneNumber(phoneNumber); + pgUser.setPgRoleId(pgRole); pgUserManager.save(pgUser); result = "true"; msg = "编辑成功";