Created
April 25, 2020 13:00
-
-
Save chongma/c37600b95993107213f64ff25a2493cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package uk.me.kissy.database.entities.jpa.sales; | |
| import java.io.Serializable; | |
| import java.util.List; | |
| import javax.persistence.CascadeType; | |
| import javax.persistence.Entity; | |
| import javax.persistence.GeneratedValue; | |
| import javax.persistence.GenerationType; | |
| import javax.persistence.Id; | |
| import javax.persistence.ManyToOne; | |
| import javax.persistence.OneToMany; | |
| import javax.persistence.OrderColumn; | |
| import javax.persistence.Table; | |
| import javax.persistence.Version; | |
| @Entity | |
| @Table(name = "sales_rule") | |
| public class Rule implements Serializable { | |
| private static final long serialVersionUID = 1L; | |
| @Id | |
| @GeneratedValue(strategy = GenerationType.AUTO) | |
| private Long id; | |
| @Version | |
| private Long version; | |
| @ManyToOne | |
| private Section section; | |
| private Integer orderid; | |
| @OneToMany(mappedBy = "rule", cascade = CascadeType.ALL, orphanRemoval = true) | |
| @OrderColumn(name = "orderid") | |
| private List<Action> actions; | |
| @OneToMany(mappedBy = "rule", cascade = CascadeType.ALL, orphanRemoval = true) | |
| private List<Condition> conditions; | |
| public List<Action> getActions() { | |
| return actions; | |
| } | |
| public void setActions(List<Action> actions) { | |
| this.actions = actions; | |
| } | |
| public List<Condition> getConditions() { | |
| return conditions; | |
| } | |
| public void setConditions(List<Condition> conditions) { | |
| this.conditions = conditions; | |
| } | |
| public Long getId() { | |
| return id; | |
| } | |
| public void setId(Long id) { | |
| this.id = id; | |
| } | |
| public Long getVersion() { | |
| return version; | |
| } | |
| public void setVersion(Long version) { | |
| this.version = version; | |
| } | |
| public Section getSection() { | |
| return section; | |
| } | |
| public void setSection(Section section) { | |
| this.section = section; | |
| } | |
| public Integer getOrderid() { | |
| return orderid; | |
| } | |
| public void setOrderid(Integer orderid) { | |
| this.orderid = orderid; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package uk.me.kissy.database.entities.jpa.sales; | |
| import java.io.Serializable; | |
| import java.util.List; | |
| import javax.persistence.CascadeType; | |
| import javax.persistence.Entity; | |
| import javax.persistence.GeneratedValue; | |
| import javax.persistence.Id; | |
| import javax.persistence.ManyToOne; | |
| import javax.persistence.OneToMany; | |
| import javax.persistence.OrderColumn; | |
| import javax.persistence.Table; | |
| import javax.persistence.Transient; | |
| import javax.persistence.Version; | |
| @Entity | |
| @Table(name = "sales_section") | |
| public class Section implements Serializable { | |
| private static final long serialVersionUID = 1L; | |
| @Id | |
| @GeneratedValue | |
| private Long id; | |
| @Version | |
| private Long version; | |
| @ManyToOne | |
| private QuoteScript quoteScript; | |
| private String xmlTag; | |
| private Integer orderid; | |
| @OneToMany(mappedBy = "section", cascade = CascadeType.ALL, orphanRemoval = true) | |
| @OrderColumn(name = "orderid") | |
| private List<Rule> rules; | |
| @Transient | |
| private Promotion promotion; | |
| public String getXmlTag() { | |
| return xmlTag; | |
| } | |
| public void setXmlTag(String xmlTag) { | |
| this.xmlTag = xmlTag; | |
| } | |
| public Promotion getPromotion() { | |
| return promotion; | |
| } | |
| public void setPromotion(Promotion promotion) { | |
| this.promotion = promotion; | |
| } | |
| public Long getId() { | |
| return id; | |
| } | |
| public void setId(Long id) { | |
| this.id = id; | |
| } | |
| public Long getVersion() { | |
| return version; | |
| } | |
| public void setVersion(Long version) { | |
| this.version = version; | |
| } | |
| public List<Rule> getRules() { | |
| return rules; | |
| } | |
| public void setRules(List<Rule> rules) { | |
| this.rules = rules; | |
| } | |
| public QuoteScript getQuoteScript() { | |
| return quoteScript; | |
| } | |
| public void setQuoteScript(QuoteScript quoteScript) { | |
| this.quoteScript = quoteScript; | |
| } | |
| public Integer getOrderid() { | |
| return orderid; | |
| } | |
| public void setOrderid(Integer orderid) { | |
| this.orderid = orderid; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package uk.me.kissy.api.services.cors.admin; | |
| import static java.util.stream.Collectors.toList; | |
| import javax.inject.Inject; | |
| import javax.servlet.http.HttpServletRequest; | |
| import javax.ws.rs.GET; | |
| import uk.me.kissy.database.entities.jpa.sales.Rule; | |
| import uk.me.kissy.database.entities.jpa.sales.Section; | |
| @Path("/sales") | |
| public class SalesService { | |
| @Path("/sections/{id}/rules") | |
| @GET | |
| public Response selectSectionRules(@PathParam("id") Long id) { | |
| Section item = sectionDb.select(id); | |
| if (item != null) { | |
| List<uk.me.kissy.database.entities.other.sales.quote.Rule> list_ = quoteScriptMapper | |
| .convertRules(item.getRules()); | |
| return Response.ok(list_).build(); | |
| } | |
| return Response.status(commonStatus).build(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment