当前位置: 首页 > news >正文

做网站去哪里接单作网站流程

做网站去哪里接单,作网站流程,手机怎么编辑网页,wordpress 子主题1 安装插件 我这边使用的是IDEA#xff0c;需要先按照Graphql插件#xff0c;步骤如下#xff1a; #xff08;1#xff09;打开插件管理 在IDEA中#xff0c;打开主菜单#xff0c;选择 File - Settings (或者使用快捷键 Ctrl Alt S …1 安装插件 我这边使用的是IDEA需要先按照Graphql插件步骤如下 1打开插件管理 在IDEA中打开主菜单选择 File - Settings (或者使用快捷键 Ctrl Alt S 或 Cmd ,)然后在弹出的对话框中选择 Plugins。 2搜索GraphQL插件 在插件管理器中你会看到一个搜索框。在搜索框中输入 GraphQL 或者其他相关的关键词然后按下回车键或者点击搜索图标。 3安装插件 4重启IDEA 安装完成以后重启IDEA 2 新建数据库 脚本如下: CREATE DATABASE IF NOT EXISTS BOOK_API_DATA; USE BOOK_API_DATA;CREATE TABLE IF NOT EXISTS Book (id int(20) NOT NULL AUTO_INCREMENT,name varchar(255) DEFAULT NULL,pageCount varchar(255) DEFAULT NULL,PRIMARY KEY (id),UNIQUE KEY Index_name (name)) ENGINEInnoDB AUTO_INCREMENT235 DEFAULT CHARSETutf8;CREATE TABLE Author (id INT(20) NOT NULL AUTO_INCREMENT,firstName VARCHAR(255) NULL DEFAULT NULL COLLATE utf8_general_ci,lastName VARCHAR(255) NULL DEFAULT NULL COLLATE utf8_general_ci,bookId INT(20) NULL DEFAULT NULL,PRIMARY KEY (id) USING BTREE,UNIQUE INDEX Index_name (firstName) USING BTREE,INDEX FK_Author_Book (bookId) USING BTREE,CONSTRAINT FK_Author_Book FOREIGN KEY (bookId) REFERENCES BOOK_API_DATA.Book (id) ON UPDATE CASCADE ON DELETE CASCADE )COLLATEutf8_general_ci ENGINEInnoDB AUTO_INCREMENT6 ;INSERT INTO Book (id, name, pageCount) VALUES (1, the golden ticket, 255); INSERT INTO Book (id, name, pageCount) VALUES (2, coding game, 300);INSERT INTO Author (id, firstName, LastName, bookId) VALUES (4, Brendon, Bouchard, 1); INSERT INTO Author (id, firstName, LastName, bookId) VALUES (5, John, Doe, 2);3 代码实现 下面实现一个简单的查询 3.1 引入依赖 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-graphql/artifactIdversion3.3.0/version/dependency 完整pom文件如下 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdorg.example/groupIdartifactIdspringbootgraphql/artifactIdversion1.0-SNAPSHOT/versionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.7.5/versionrelativePath //parentpropertiesjava.version1.8/java.version !-- kotlin.version1.1.16/kotlin.version--/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-data-jpa/artifactId/dependencydependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-graphql/artifactIdversion3.3.0/version/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scopeexclusionsexclusiongroupIdorg.junit.vintage/groupIdartifactIdjunit-vintage-engine/artifactId/exclusion/exclusions/dependencydependencygroupIdcom.google.guava/groupIdartifactIdguava/artifactIdversion26.0-jre/version/dependency/dependenciesbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactIdconfigurationexcludesexcludegroupIdorg.projectlombok/groupIdartifactIdlombok/artifactId/exclude/excludes/configuration/plugin/plugins/build/project 3.2 新建实体类 新建Author实体类 package com.example.demo.model;import javax.persistence.*;Entity Table(name Author, schema BOOK_API_DATA) public class Author {IdGeneratedValue(strategy GenerationType.AUTO)Integer id;Column(name firstname)String firstName;Column(name lastname)String lastName;Column(name bookid)Integer bookId;public Author(Integer id, String firstName, String lastName, Integer bookId) {this.id id;this.firstName firstName;this.lastName lastName;this.bookId bookId;}public Author() {}public Integer getId() {return id;}public String getFirstName() {return firstName;}public String getLastName() {return lastName;}public void setId(Integer id) {this.id id;}public void setFirstName(String firstName) {this.firstName firstName;}public void setLastName(String lastName) {this.lastName lastName;}public Integer getBookId() {return bookId;}public void setBookId(Integer bookId) {this.bookId bookId;} } 新建Book实体类 package com.example.demo.model;import javax.persistence.*;Entity Table(name Book, schema BOOK_API_DATA) public class Book {IdGeneratedValue(strategy GenerationType.AUTO)private Integer id;private String name;Column(name pagecount)private String pageCount;public Book(Integer id, String name, String pageCount) {this.id id;this.name name;this.pageCount pageCount;}public Book() {}public Integer getId() {return id;}public void setId(Integer id) {this.id id;}public String getName() {return name;}public void setName(String name) {this.name name;}public String getPageCount() {return pageCount;}public void setPageCount(String pageCount) {this.pageCount pageCount;} }新建输入AuthorInput实体 package com.example.demo.model.Input;public class AuthorInput {String firstName;String lastName;Integer bookId;public String getFirstName() {return firstName;}public String getLastName() {return lastName;}public void setFirstName(String firstName) {this.firstName firstName;}public void setLastName(String lastName) {this.lastName lastName;}public Integer getBookId() {return bookId;}public void setBookId(Integer bookId) {this.bookId bookId;} }3.3 新建repository类 新建AuthorRepository类 package com.example.demo.repository;import com.example.demo.model.Author; import org.springframework.data.repository.CrudRepository;public interface AuthorRepository extends CrudRepositoryAuthor, Integer {Author findAuthorByBookId(Integer bookId); }新建BookRepository类 package com.example.demo.repository;import com.example.demo.model.Book; import org.springframework.data.repository.CrudRepository;public interface BookRepository extends CrudRepositoryBook, Integer {Book findBookByName(String name); }3.4 新建Service层 package com.example.demo.service;import com.example.demo.model.Author; import com.example.demo.repository.AuthorRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;Service public class AuthorSevice {Autowiredprivate AuthorRepository authorRepository;public void addAuthon(Author author) {authorRepository.save(author);}public Author queryAuthorByBookId(int bookid) {Author author authorRepository.findAuthorByBookId(bookid);return author;}}3.5 新建控制器 package com.example.demo.controller;import com.example.demo.model.Author; import com.example.demo.model.Input.AuthorInput; import com.example.demo.service.AuthorSevice; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.graphql.data.method.annotation.Argument; import org.springframework.graphql.data.method.annotation.MutationMapping; import org.springframework.graphql.data.method.annotation.QueryMapping; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.RestController;CrossOrigin RestController public class AuthorController {Autowiredprivate AuthorSevice authorSevice;/*** 经典 hollo graphql*/QueryMappingpublic String hello(){return hello graphql;}QueryMappingpublic Author getAuthorBybookId(Argument int bookid) {System.out.println(bookid:bookid);return authorSevice.queryAuthorByBookId(bookid);}MutationMappingpublic Author createUser(Argument AuthorInput authorInput) {Author author new Author();BeanUtils.copyProperties(authorInput,author);authorSevice.addAuthon(author);return author;} }3.6 新建graphql文件 在resource文件中新建graphql文件 编写root.graphql文件 schema {query: Querymutation: Mutation } type Mutation{ } type Query{ } 编写books.graphql文件 extend type Query {hello:StringgetAuthorBybookId(bookid:Int): Author }extend type Mutation {createUser(authorInput: AuthorInput):Author }input AuthorInput {firstName: StringlastName: StringbookId: Int }type Author {id: IntfirstName: StringlastName: StringbookId: Int }type Book {id: Intname: StringpageCount: Stringauthor: Author } 3.7 编写yml配置文件 spring:jpa:hibernate:use-new-id-generator-mappings: falsegraphql:graphiql:enabled: truewebsocket:path: /graphqlschema:printer:enabled: truelocations: classpath:/graphql #test.graphql文件位置file-extensions: .graphqldatasource:url: jdbc:mysql://192.168.222.156:3306/book_api_data?useUnicodetruecharacterEncodingutf-8useSSLfalsepassword: 123456username: root server:port: 8088 3.8 编写启动类 package com.example.demo;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;SpringBootApplication public class graphqlApplication {public static void main(String[] args) {SpringApplication.run(graphqlApplication.class,args);} }4 启动测试 启动后访问http://localhost:8088/graphiql?path/graphqlwsPath/graphql 测试查询功能 测试新增功能
http://www.hyszgw.com/news/94011/

相关文章:

  • 免费安全网站大全入口wordpress主页居中
  • 用阿里云和大淘客做网站什么是网络营销成败的关键
  • 廊坊市建设局官方网站北京市建设工程信息网告知性备案
  • 站长之家官网入口现在做网站开发
  • 无锡正规网站建设结婚网站模板
  • 电子商务网站的建设与规划书国家企业信用公示信息系统
  • 马鞍山网站建设 明达logo设计说明
  • 畜牧企业网站模板能查个人信息的网站
  • 做普通网站公司吗企业创建网站的途径都有啥
  • 小城镇建设网站参考文献搭建网站的流程
  • 郑州计算机网站公司做百度推广送网站
  • 南京手机网站开发南通网站
  • 做机器人的网站有人上相亲网站做传销燕窝
  • 室内设计师培训班费用seo应该如何做
  • 数据库支持的网站怎么做免费高清视频素材app哪里找
  • 企业手机端网站模板下载库尔勒网站建设电话
  • 网站报纸什么软件做深圳最便宜的物流公司
  • 广州网站建设大公司去生活服务性的网站做php好吗
  • visio画网站开发类图代理国外网站
  • 网页设计建网站流程做网站用笔记本做服务器
  • 成都网站设计公司官网wordpress去除顶部工具栏
  • 南京个人网站建设模板杭州室内设计设计公司前十排名
  • 网站标题用什么符号分开怀柔网站制作
  • 做网站的过程中有哪些问题网站改版提升总结
  • 建设网站增城哈尔滨餐饮网站建设
  • 网站首页 栏目页 内容页深圳龙华区简介
  • 厚街做网站重庆工程建设信息查询
  • 上海做网站高端个人网站建设的论文
  • 保定网站建设方案优化易语言网站开发教程
  • 网站给我做坏了怎么办语言免费网站建设