新增房源服务实现之新增房源RESTful接口的开发
生活随笔
收集整理的這篇文章主要介紹了
新增房源服务实现之新增房源RESTful接口的开发
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>learn-haoke-manage</artifactId><groupId>cn.learn.haoke.manage</groupId><version>1.0-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>learn-haoke-manage-api-server</artifactId><dependencies><!-- springboot的web支持 --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>cn.learn.haoke.manage</groupId><artifactId>learn-haoke-manage-dubbo-server-house-resources-dubbo-interface</artifactId><version>1.0-SNAPSHOT</version></dependency></dependencies></project>
package cn.learn.haoke.dubbo.api.service;import cn.learn.haoke.dubbo.server.api.ApiHouseResourcesService;
import cn.learn.haoke.dubbo.server.pojo.HouseResources;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Service;@Service
public class HouseResourcesService {@Reference(version = "1.0.0")private ApiHouseResourcesService apiHouseResourcesService;public boolean save(HouseResources houseResources) {int result =this.apiHouseResourcesService.saveHouseResources(houseResources);return result == 1;}
}
package cn.learn.haoke.dubbo.api.controller;import cn.learn.haoke.dubbo.api.service.HouseResourcesService;
import cn.learn.haoke.dubbo.server.pojo.HouseResources;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;@Controller
@RequestMapping("house/resources")
public class HouseResourcesController {@Autowiredprivate HouseResourcesService houseResourcesService;/*** 新增房源** @param houseResources json數(shù)據(jù)* @return*/@PostMapping@ResponseBodypublic ResponseEntity<Void> save(@RequestBody HouseResources houseResources) {try {boolean bool = this.houseResourcesService.save(houseResources);if (bool) {return ResponseEntity.status(HttpStatus.CREATED).build();}} catch (Exception e) {e.printStackTrace();}return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();}/*** test** @return*/@GetMapping@ResponseBodypublic ResponseEntity<String> get() {return ResponseEntity.ok("ok");}
}
package cn.learn.haoke.dubbo.api;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
public class DubboApiApplication {public static void main(String[] args) {SpringApplication.run(DubboApiApplication.class, args);}
}
# Spring boot application
spring.application.name = learn-haoke-manage-api-server
server.port = 18080
#logging.level.root=DEBUG# 應(yīng)用名稱
dubbo.application.name = dubbo-consumer-haoke-manage# zk注冊(cè)中心
dubbo.registry.address = zookeeper://localhost:2181
dubbo.registry.client = zkclient
?
總結(jié)
以上是生活随笔為你收集整理的新增房源服务实现之新增房源RESTful接口的开发的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 新增房源服务实现之AutoGenerat
- 下一篇: 图片存储解决方案的分析