SHARE
TWEET

Untitled

a guest Jun 25th, 2019 410 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE TABLE `tbl_user` (
  2.     `user_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
  3.     `name` VARCHAR(100) DEFAULT NULL,
  4.     `email` VARCHAR(255) DEFAULT NULL,
  5.     `contact` VARCHAR(15) NOT NULL,
  6.     `category` ENUM('general', 'star', 'gold', 'platinum') NOT NULL,
  7.     PRIMARY KEY (`user_id`),
  8.     UNIQUE KEY (`email`),
  9.     UNIQUE KEY (`contact`)
  10. );
  11.  
  12. CREATE TABLE `tbl_bonus` (
  13.     `bonus_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
  14.     `user_id` BIGINT(20) NOT NULL,
  15.     `point` INT(5) NOT NULL,
  16.     `used_point` INT(5) DEFAULT NULL,
  17.     `status` ENUM('unused', 'used') NOT NULL,
  18.     PRIMARY KEY (`bonus_id`),
  19.     FOREIGN KEY (`user_id`)
  20.         REFERENCES tbl_user (user_id)
  21. );
  22.      
  23. @Table(name = "tbl_bonus")
  24. public class Bonus {
  25.  
  26.     @Id
  27.     @GeneratedValue(strategy = GenerationType.IDENTITY)
  28.     @Column(name = "bonus_id")
  29.     long bonusId;
  30.  
  31.     @ManyToOne
  32.     User user;
  33.  
  34.     @Column(name = "point")
  35.     int point;
  36.  
  37.     @Column(name = "used_point")
  38.     int usedPoint;
  39.  
  40.     @Column(name = "status")
  41.     String status;
  42.  
  43.     public long getBonusId() {
  44.         return bonusId;
  45.     }
  46.  
  47.     public void setBonusId(long bonusId) {
  48.         this.bonusId = bonusId;
  49.     }
  50.  
  51.     public User getUser() {
  52.         return user;
  53.     }
  54.  
  55.     public void setUser(User user) {
  56.         this.user = user;
  57.     }
  58.  
  59.     public int getPoint() {
  60.         return point;
  61.     }
  62.  
  63.     public void setPoint(int point) {
  64.         this.point = point;
  65.     }
  66.  
  67.     public int getUsedPoint() {
  68.         return usedPoint;
  69.     }
  70.  
  71.     public void setUsedPoint(int usedPoint) {
  72.         this.usedPoint = usedPoint;
  73.     }
  74.  
  75.     public String getStatus() {
  76.         return status;
  77.     }
  78.  
  79.     public void setStatus(String status) {
  80.         this.status = status;
  81.     }
  82.  
  83.     public Bonus() {
  84.     }
  85.  
  86. }
  87.      
  88. @Repository
  89. public interface BonusRepository extends JpaRepository<Bonus, Long> {
  90. }
  91.      
  92. @Service
  93. public class BonusService {
  94.  
  95.     @Autowired
  96.     BonusRepository bonusRepository;
  97.  
  98.  
  99.     public Bonus addBonus(Bonus bonus) {
  100.         return bonusRepository.save(bonus);
  101.     }
  102. }
  103.      
  104. localhost:8080/api/bonus/add
  105.      
  106. {
  107.     "userId": "1",
  108.     "point": "10",
  109.     "usedPoint": "4",
  110.     "status": "unused"
  111. }
  112.      
  113. {
  114.     "timestamp": "2019-04-28T07:24:25.160+0000",
  115.     "status": 500,
  116.     "error": "Internal Server Error",
  117.     "message": "Missing URI template variable 'user_id' for method parameter of type long",
  118.     "trace": "org.springframework.web.bind.MissingPathVariableException: Missing URI template variable 'user_id' for method parameter of type longrntat org.springframework.web.servlet.mvc.method.annotation.PathVariableMethodArgumentResolver.handleMissingValue(PathVariableMethodArgumentResolver.java:101)rntat org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.handleMissingValue(AbstractNamedValueMethodArgumentResolver.java:221)rntat org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:113)rntat org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:126)rntat org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:166)rntat org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)rntat org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)rntat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:892)rntat org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797)rntat org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)rntat org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)rntat org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)rntat org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)rntat org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)rntat javax.servlet.http.HttpServlet.service(HttpServlet.java:660)rntat org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)rntat javax.servlet.http.HttpServlet.service(HttpServlet.java:741)rntat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)rntat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)rntat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)rntat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)rntat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)rntat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)rntat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)rntat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)rntat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)rntat org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)rntat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)rntat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)rntat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)rntat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)rntat org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)rntat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)rntat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)rntat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)rntat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)rntat org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)rntat org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)rntat org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)rntat org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)rntat org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)rntat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)rntat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)rntat org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)rntat java.lang.Thread.run(Thread.java:748)rn",
  119.     "path": "/api/bonus/add"
  120. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top