Advertisement
Guest User

Untitled

a guest
Nov 27th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.16 KB | None | 0 0
  1. ------------------------------------------------------------------------------------------------------------
  2. entities
  3. ------------------------------------------------------------------------------------------------------------
  4. package com.upc.demo.entities;
  5.  
  6. import java.sql.Date;
  7.  
  8. import javax.persistence.Column;
  9. import javax.persistence.Entity;
  10. import javax.persistence.GeneratedValue;
  11. import javax.persistence.GenerationType;
  12. import javax.persistence.Id;
  13. import javax.persistence.JoinColumn;
  14. import javax.persistence.ManyToOne;
  15. import javax.persistence.Table;
  16. import javax.validation.constraints.Size;
  17.  
  18. @Entity
  19. @Table(name="medical_appointment")
  20. public class CitaMedica {
  21.  
  22. @Id
  23. @GeneratedValue(strategy=GenerationType.IDENTITY)
  24. private int id;
  25.  
  26. @Column(name="date", nullable=false)
  27. private Date date;
  28.  
  29. @Column(name="hour", nullable=false)
  30. private int hora;
  31.  
  32. @ManyToOne
  33. @JoinColumn(name="seat_id", nullable=false)
  34. private Sede sedeId;
  35.  
  36. @ManyToOne
  37. @JoinColumn(name="doctor_id", nullable=false)
  38. private Doctor doctorId;
  39.  
  40. @Size(min=2, max=80,message="nombre entre 2 a 80")
  41. @Column(name="patient_name", nullable=false, length=80)
  42. private String patientName;
  43.  
  44. public CitaMedica() { }
  45.  
  46. public int getId() {
  47. return id;
  48. }
  49.  
  50. public void setId(int id) {
  51. this.id = id;
  52. }
  53.  
  54. public Date getDate() {
  55. return date;
  56. }
  57.  
  58. public void setDate(Date date) {
  59. this.date = date;
  60. }
  61.  
  62. public int getHora() {
  63. return hora;
  64. }
  65.  
  66. public void setHora(int hora) {
  67. this.hora = hora;
  68. }
  69.  
  70. public Sede getSedeId() {
  71. return sedeId;
  72. }
  73.  
  74. public void setSedeId(Sede sedeId) {
  75. this.sedeId = sedeId;
  76. }
  77.  
  78. public Doctor getDoctorId() {
  79. return doctorId;
  80. }
  81.  
  82. public void setDoctorId(Doctor doctorId) {
  83. this.doctorId = doctorId;
  84. }
  85.  
  86. public String getPatientName() {
  87. return patientName;
  88. }
  89.  
  90. public void setPatientName(String patientName) {
  91. this.patientName = patientName;
  92. }
  93. }
  94.  
  95. ------------------------------------------------------------------------------------------------------------
  96. package com.upc.demo.entities;
  97.  
  98. import javax.persistence.Column;
  99. import javax.persistence.Entity;
  100. import javax.persistence.GeneratedValue;
  101. import javax.persistence.GenerationType;
  102. import javax.persistence.Id;
  103. import javax.persistence.JoinColumn;
  104. import javax.persistence.ManyToOne;
  105. import javax.persistence.Table;
  106. import javax.validation.constraints.Size;
  107.  
  108. @Entity
  109. @Table(name="doctor")
  110. public class Doctor {
  111.  
  112. @Id
  113. @GeneratedValue(strategy=GenerationType.IDENTITY)
  114. private int id;
  115.  
  116. @Size(min=2,max=80)
  117. @Column(name="name",nullable=false,length=80)
  118. private String name;
  119.  
  120. @Size(min=2,max=80)
  121. @Column(name="last_name",nullable=false,length=80)
  122. private String lastName;
  123.  
  124. @ManyToOne
  125. @JoinColumn(name="speciality_id")
  126. private Especialidad specialityId;
  127.  
  128. public Doctor() { }
  129.  
  130. public int getId() {
  131. return id;
  132. }
  133.  
  134. public void setId(int id) {
  135. this.id = id;
  136. }
  137.  
  138. public String getName() {
  139. return name;
  140. }
  141.  
  142. public void setName(String name) {
  143. this.name = name;
  144. }
  145.  
  146. public String getLastName() {
  147. return lastName;
  148. }
  149.  
  150. public void setLastName(String lastName) {
  151. this.lastName = lastName;
  152. }
  153.  
  154. public Especialidad getSpecialityId() {
  155. return specialityId;
  156. }
  157.  
  158. public void setSpecialityId(Especialidad specialityId) {
  159. this.specialityId = specialityId;
  160. }
  161.  
  162.  
  163. }
  164. ------------------------------------------------------------------------------------------------------------
  165. package com.upc.demo.entities;
  166.  
  167. import javax.persistence.Column;
  168. import javax.persistence.Entity;
  169. import javax.persistence.GeneratedValue;
  170. import javax.persistence.GenerationType;
  171. import javax.persistence.Id;
  172. import javax.persistence.JoinColumn;
  173. import javax.persistence.ManyToOne;
  174. import javax.persistence.Table;
  175. import javax.validation.constraints.Size;
  176.  
  177. @Entity
  178. @Table(name="specialities")
  179. public class Especialidad {
  180.  
  181. @Id
  182. @GeneratedValue(strategy=GenerationType.IDENTITY)
  183. private int id;
  184.  
  185. @Size(min=4, message="min de 4")
  186. @Column(name="name",nullable=false, length=80)
  187. private String name;
  188.  
  189. @ManyToOne
  190. @JoinColumn(name="seat_id")
  191. private Sede sedeId;
  192.  
  193. public Especialidad() { }
  194.  
  195. public int getId() {
  196. return id;
  197. }
  198.  
  199. public void setId(int id) {
  200. this.id = id;
  201. }
  202.  
  203. public String getName() {
  204. return name;
  205. }
  206.  
  207. public void setName(String name) {
  208. this.name = name;
  209. }
  210.  
  211. public Sede getSedeId() {
  212. return sedeId;
  213. }
  214.  
  215. public void setSedeId(Sede sedeId) {
  216. this.sedeId = sedeId;
  217. }
  218.  
  219.  
  220. }
  221. ------------------------------------------------------------------------------------------------------------
  222. package com.upc.demo.entities;
  223.  
  224. import javax.persistence.Column;
  225. import javax.persistence.Entity;
  226. import javax.persistence.GeneratedValue;
  227. import javax.persistence.GenerationType;
  228. import javax.persistence.Id;
  229. import javax.persistence.Table;
  230. import javax.validation.constraints.Size;
  231.  
  232. @Entity
  233. @Table(name = "seats")
  234. public class Sede {
  235.  
  236. @Id
  237. @GeneratedValue(strategy=GenerationType.IDENTITY)
  238. private int id;
  239.  
  240. @Size(min=2, max=50, message="nombre entre 2-50")
  241. @Column(name="name",nullable=false)
  242. private String name;
  243.  
  244. public Sede() { }
  245.  
  246. public int getId() {
  247. return id;
  248. }
  249.  
  250. public void setId(int id) {
  251. this.id = id;
  252. }
  253.  
  254. public String getName() {
  255. return name;
  256. }
  257.  
  258. public void setName(String name) {
  259. this.name = name;
  260. }
  261.  
  262.  
  263. }
  264. ------------------------------------------------------------------------------------------------------------
  265. repository
  266. ------------------------------------------------------------------------------------------------------------
  267.  
  268. package com.upc.demo.repository;
  269.  
  270. import java.util.List;
  271.  
  272. import org.springframework.data.jpa.repository.JpaRepository;
  273. import org.springframework.stereotype.Repository;
  274.  
  275. import com.upc.demo.entities.CitaMedica;
  276.  
  277. @Repository
  278. public interface CitaMedicaRepository extends JpaRepository<CitaMedica, Integer>{
  279.  
  280. List<CitaMedica> findByPatientName(String patientName);
  281. }
  282. ------------------------------------------------------------------------------------------------------------
  283. package com.upc.demo.repository;
  284.  
  285. import java.util.List;
  286.  
  287. import org.springframework.data.jpa.repository.JpaRepository;
  288. import org.springframework.stereotype.Repository;
  289.  
  290. import com.upc.demo.entities.Doctor;
  291. import com.upc.demo.entities.Especialidad;
  292.  
  293. @Repository
  294. public interface DoctorRepository extends JpaRepository<Doctor, Integer>{
  295.  
  296. List<Doctor> findBySpecialityId(Especialidad id);
  297. }
  298. ------------------------------------------------------------------------------------------------------------
  299. package com.upc.demo.repository;
  300.  
  301.  
  302. import java.util.List;
  303.  
  304. import org.springframework.data.jpa.repository.JpaRepository;
  305. import org.springframework.stereotype.Repository;
  306.  
  307. import com.upc.demo.entities.Especialidad;
  308. import com.upc.demo.entities.Sede;
  309.  
  310. @Repository
  311. public interface EspecialidadRepository extends JpaRepository<Especialidad, Integer>{
  312.  
  313. List<Especialidad> findBySedeId(Sede id);
  314. }
  315. ------------------------------------------------------------------------------------------------------------
  316. package com.upc.demo.repository;
  317.  
  318. import org.springframework.data.jpa.repository.JpaRepository;
  319. import org.springframework.stereotype.Repository;
  320.  
  321. import com.upc.demo.entities.Sede;
  322.  
  323. @Repository
  324. public interface SedeRepository extends JpaRepository<Sede, Integer>{
  325.  
  326. }
  327. ------------------------------------------------------------------------------------------------------------
  328. package com.upc.demo.service;
  329.  
  330. import java.util.List;
  331. import java.util.Optional;
  332.  
  333. public interface CrudService<T> {
  334.  
  335. List<T> findAll() throws Exception;
  336.  
  337. T save(T t)throws Exception;
  338.  
  339. T update(T t)throws Exception;
  340.  
  341. Optional<T> findById(Integer id)throws Exception;
  342.  
  343. void deleteById(Integer id)throws Exception;
  344.  
  345. void deleteAll()throws Exception;
  346. }
  347. ------------------------------------------------------------------------------------------------------------
  348. package com.upc.demo.service;
  349.  
  350. import java.util.List;
  351.  
  352. import com.upc.demo.entities.Especialidad;
  353. import com.upc.demo.entities.Sede;
  354.  
  355. public interface EspecialidadService extends CrudService<Especialidad>{
  356. List<Especialidad> findBySedeId(Sede id);
  357. }
  358. ------------------------------------------------------------------------------------------------------------
  359. package com.upc.demo.service;
  360.  
  361. import com.upc.demo.entities.Sede;
  362.  
  363. public interface SedeService extends CrudService<Sede>{
  364.  
  365. }
  366. ------------------------------------------------------------------------------------------------------------
  367. service.implementation
  368. ------------------------------------------------------------------------------------------------------------
  369. package com.upc.demo.service.implementation;
  370.  
  371. import java.util.List;
  372. import java.util.Optional;
  373.  
  374. import org.springframework.beans.factory.annotation.Autowired;
  375. import org.springframework.stereotype.Service;
  376. import org.springframework.transaction.annotation.Transactional;
  377.  
  378. import com.upc.demo.entities.Especialidad;
  379. import com.upc.demo.entities.Sede;
  380. import com.upc.demo.repository.EspecialidadRepository;
  381. import com.upc.demo.service.EspecialidadService;
  382.  
  383. @Service
  384. public class EspecialidadServiceImplementation implements EspecialidadService {
  385.  
  386. @Autowired
  387. private EspecialidadRepository especialidadRepository;
  388.  
  389. @Transactional(readOnly=true)
  390. @Override
  391. public List<Especialidad> findAll() throws Exception {
  392. // TODO Auto-generated method stub
  393. return especialidadRepository.findAll();
  394. }
  395.  
  396. @Transactional
  397. @Override
  398. public Especialidad save(Especialidad t) throws Exception {
  399. // TODO Auto-generated method stub
  400. return especialidadRepository.save(t);
  401. }
  402.  
  403. @Transactional
  404. @Override
  405. public Especialidad update(Especialidad t) throws Exception {
  406. // TODO Auto-generated method stub
  407. return especialidadRepository.save(t);
  408. }
  409.  
  410. @Transactional(readOnly=true)
  411. @Override
  412. public Optional<Especialidad> findById(Integer id) throws Exception {
  413. // TODO Auto-generated method stub
  414. return especialidadRepository.findById(id);
  415. }
  416.  
  417. @Transactional
  418. @Override
  419. public void deleteById(Integer id) throws Exception {
  420. // TODO Auto-generated method stub
  421. especialidadRepository.deleteById(id);
  422. }
  423.  
  424. @Transactional
  425. @Override
  426. public void deleteAll() throws Exception {
  427. // TODO Auto-generated method stub
  428. especialidadRepository.deleteAll();
  429. }
  430.  
  431. @Transactional
  432. @Override
  433. public List<Especialidad> findBySedeId(Sede id) {
  434. // TODO Auto-generated method stub
  435. return especialidadRepository.findBySedeId(id);
  436. }
  437.  
  438. }
  439.  
  440. ------------------------------------------------------------------------------------------------------------
  441. package com.upc.demo.service.implementation;
  442.  
  443. import java.util.List;
  444. import java.util.Optional;
  445.  
  446. import org.springframework.beans.factory.annotation.Autowired;
  447. import org.springframework.stereotype.Service;
  448. import org.springframework.transaction.annotation.Transactional;
  449.  
  450. import com.upc.demo.entities.Sede;
  451. import com.upc.demo.repository.SedeRepository;
  452. import com.upc.demo.service.SedeService;
  453.  
  454. @Service
  455. public class SedeServiceImplementation implements SedeService {
  456.  
  457. @Autowired
  458. private SedeRepository sedeRepository;
  459.  
  460. @Transactional(readOnly=true)
  461. @Override
  462. public List<Sede> findAll() throws Exception {
  463. // TODO Auto-generated method stub
  464. return sedeRepository.findAll();
  465. }
  466.  
  467. @Transactional
  468. @Override
  469. public Sede save(Sede t) throws Exception {
  470. // TODO Auto-generated method stub
  471. return sedeRepository.save(t);
  472. }
  473.  
  474. @Transactional
  475. @Override
  476. public Sede update(Sede t) throws Exception {
  477. // TODO Auto-generated method stub
  478. return sedeRepository.save(t);
  479. }
  480.  
  481. @Transactional(readOnly=true)
  482. @Override
  483. public Optional<Sede> findById(Integer id) throws Exception {
  484. // TODO Auto-generated method stub
  485. return sedeRepository.findById(id);
  486. }
  487.  
  488. @Transactional
  489. @Override
  490. public void deleteById(Integer id) throws Exception {
  491. // TODO Auto-generated method stub
  492. sedeRepository.deleteById(id);
  493. }
  494.  
  495. @Transactional
  496. @Override
  497. public void deleteAll() throws Exception {
  498. // TODO Auto-generated method stub
  499. sedeRepository.deleteAll();
  500. }
  501.  
  502. }
  503.  
  504. ------------------------------------------------------------------------------------------------------------
  505. controller
  506. ------------------------------------------------------------------------------------------------------------
  507. package com.upc.demo.controller;
  508.  
  509. import java.net.URI;
  510. import java.util.ArrayList;
  511. import java.util.List;
  512.  
  513. import javax.validation.Valid;
  514.  
  515. import org.springframework.beans.factory.annotation.Autowired;
  516. import org.springframework.http.HttpStatus;
  517. import org.springframework.http.MediaType;
  518. import org.springframework.http.ResponseEntity;
  519. import org.springframework.web.bind.annotation.GetMapping;
  520. import org.springframework.web.bind.annotation.PathVariable;
  521. import org.springframework.web.bind.annotation.PostMapping;
  522. import org.springframework.web.bind.annotation.RequestBody;
  523. import org.springframework.web.bind.annotation.RequestMapping;
  524. import org.springframework.web.bind.annotation.RestController;
  525. import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
  526. import com.upc.demo.entities.Especialidad;
  527. import com.upc.demo.entities.Sede;
  528. import com.upc.demo.service.EspecialidadService;
  529.  
  530. import io.swagger.annotations.Api;
  531. import io.swagger.annotations.ApiOperation;
  532.  
  533. @RestController
  534. @Api(value="Rest de especialidades")
  535. @RequestMapping("/api/especialidades")
  536. public class EspecialidadController {
  537.  
  538. @Autowired
  539. private EspecialidadService especialidadService;
  540.  
  541. @ApiOperation("devuelve las especialidades")
  542. @GetMapping(produces=MediaType.APPLICATION_JSON_VALUE)
  543. public ResponseEntity<List<Especialidad>> fetchPatients(){
  544. List<Especialidad> patients;
  545. try {
  546. patients = especialidadService.findAll();
  547. return new ResponseEntity<List<Especialidad>>(patients, HttpStatus.OK);
  548. } catch (Exception e) {
  549. e.printStackTrace();
  550. return new ResponseEntity<List<Especialidad>>(HttpStatus.INTERNAL_SERVER_ERROR);
  551. }
  552. }
  553.  
  554. @ApiOperation("devuelve un paciente por sede")
  555. @GetMapping(value = "/sedes/{id}", produces=MediaType.APPLICATION_JSON_VALUE)
  556. public ResponseEntity<List<Especialidad>> fetchPatientByDni(@PathVariable("id") int id){
  557. try {
  558. List<Especialidad> paseos = new ArrayList<>();
  559. Sede sede = new Sede();
  560. sede.setId(id);
  561. paseos = especialidadService.findBySedeId(sede);
  562. return new ResponseEntity<List<Especialidad>>(paseos, HttpStatus.OK);
  563. } catch (Exception e) {
  564. return new ResponseEntity<List<Especialidad>>(HttpStatus.INTERNAL_SERVER_ERROR);
  565. }
  566. }
  567.  
  568. @ApiOperation("guarda paciente")
  569. @PostMapping(produces=MediaType.APPLICATION_JSON_VALUE, consumes=MediaType.APPLICATION_JSON_VALUE)
  570. public ResponseEntity<Object> savePatient(@Valid @RequestBody Especialidad patient){
  571. Especialidad pat = new Especialidad();
  572. try {
  573. pat = especialidadService.save(patient);
  574. URI location = ServletUriComponentsBuilder
  575. .fromCurrentRequest()
  576. .path("/{id}")
  577. .buildAndExpand(pat.getId())
  578. .toUri();
  579. return ResponseEntity.created(location).build();
  580. } catch (Exception e) {
  581. // TODO Auto-generated catch block
  582. e.printStackTrace();
  583. return new ResponseEntity<Object>(HttpStatus.INTERNAL_SERVER_ERROR);
  584. }
  585. }
  586. }
  587.  
  588. ------------------------------------------------------------------------------------------------------------
  589. package com.upc.demo.controller;
  590.  
  591. import java.net.URI;
  592. import java.util.List;
  593. import java.util.Optional;
  594.  
  595. import javax.validation.Valid;
  596.  
  597. import org.springframework.beans.factory.annotation.Autowired;
  598. import org.springframework.http.HttpStatus;
  599. import org.springframework.http.MediaType;
  600. import org.springframework.http.ResponseEntity;
  601. import org.springframework.web.bind.annotation.DeleteMapping;
  602. import org.springframework.web.bind.annotation.GetMapping;
  603. import org.springframework.web.bind.annotation.PathVariable;
  604. import org.springframework.web.bind.annotation.PostMapping;
  605. import org.springframework.web.bind.annotation.PutMapping;
  606. import org.springframework.web.bind.annotation.RequestBody;
  607. import org.springframework.web.bind.annotation.RequestMapping;
  608. import org.springframework.web.bind.annotation.RestController;
  609. import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
  610. import com.upc.demo.entities.Sede;
  611. import com.upc.demo.service.SedeService;
  612.  
  613. import io.swagger.annotations.Api;
  614. import io.swagger.annotations.ApiOperation;
  615.  
  616. @RestController
  617. @Api(value="Rest de sedes")
  618. @RequestMapping("/api/sedes")
  619. public class SedeController {
  620.  
  621. @Autowired
  622. private SedeService sedeService;
  623.  
  624. @ApiOperation("devuelve las sedes")
  625. @GetMapping(produces=MediaType.APPLICATION_JSON_VALUE)
  626. public ResponseEntity<List<Sede>> fetchPatients(){
  627. List<Sede> patients;
  628. try {
  629. patients = sedeService.findAll();
  630. return new ResponseEntity<List<Sede>>(patients, HttpStatus.OK);
  631. } catch (Exception e) {
  632. e.printStackTrace();
  633. return new ResponseEntity<List<Sede>>(HttpStatus.INTERNAL_SERVER_ERROR);
  634. }
  635. }
  636.  
  637. @ApiOperation("devuelve una sede")
  638. @GetMapping(value = "/{id}", produces=MediaType.APPLICATION_JSON_VALUE)
  639. public ResponseEntity<Sede> fetchPatient(@PathVariable("id") Integer id){
  640. Optional<Sede> patient;
  641. try {
  642. patient = sedeService.findById(id);
  643. return new ResponseEntity<Sede>(patient.get(), HttpStatus.OK);
  644. } catch (Exception e) {
  645. e.printStackTrace();
  646. return new ResponseEntity<Sede>(HttpStatus.INTERNAL_SERVER_ERROR);
  647. }
  648. }
  649.  
  650. @ApiOperation("guarda sede")
  651. @PostMapping(produces=MediaType.APPLICATION_JSON_VALUE, consumes=MediaType.APPLICATION_JSON_VALUE)
  652. public ResponseEntity<Object> savePatient(@Valid @RequestBody Sede patient){
  653. Sede pat = new Sede();
  654. try {
  655. pat = sedeService.save(patient);
  656. URI location = ServletUriComponentsBuilder
  657. .fromCurrentRequest()
  658. .path("/{id}")
  659. .buildAndExpand(pat.getId())
  660. .toUri();
  661. return ResponseEntity.created(location).build();
  662. } catch (Exception e) {
  663. // TODO Auto-generated catch block
  664. e.printStackTrace();
  665. return new ResponseEntity<Object>(HttpStatus.INTERNAL_SERVER_ERROR);
  666. }
  667. }
  668.  
  669. @ApiOperation("actualiza una sede")
  670. @PutMapping(produces=MediaType.APPLICATION_JSON_VALUE, consumes=MediaType.APPLICATION_JSON_VALUE)
  671. public ResponseEntity<Object> updatePatient(@Valid @RequestBody Sede patient){
  672. try {
  673. sedeService.update(patient);
  674. return new ResponseEntity<Object>(HttpStatus.OK);
  675. } catch (Exception e) {
  676. // TODO Auto-generated catch block
  677. e.printStackTrace();
  678. return new ResponseEntity<Object>(HttpStatus.INTERNAL_SERVER_ERROR);
  679. }
  680. }
  681.  
  682. @ApiOperation("elimina una sede")
  683. @DeleteMapping(value = "/{id}", produces=MediaType.APPLICATION_JSON_VALUE)
  684. public ResponseEntity<String> deletePatient(@PathVariable("id") Integer id){
  685. Optional<Sede> patient;
  686.  
  687. try {
  688. patient = sedeService.findById(id);
  689. if (!patient.isPresent()) {
  690. return new ResponseEntity<String>(HttpStatus.NOT_FOUND);
  691. }
  692. else {
  693. sedeService.deleteById(id);
  694. return new ResponseEntity<String>("Se elimino la sede", HttpStatus.OK);
  695. }
  696. } catch (Exception e) {
  697. e.printStackTrace();
  698. return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
  699. }
  700. }
  701.  
  702. @ApiOperation("elimina todas las sdes")
  703. @DeleteMapping(produces=MediaType.APPLICATION_JSON_VALUE)
  704. public ResponseEntity<String> deleteAllPatients(){
  705. try {
  706. sedeService.deleteAll();
  707. return new ResponseEntity<String>("Se elimino todas las sedes", HttpStatus.OK);
  708. } catch (Exception e) {
  709. e.printStackTrace();
  710. return new ResponseEntity<String>(HttpStatus.INTERNAL_SERVER_ERROR);
  711. }
  712. }
  713. }
  714.  
  715. ------------------------------------------------------------------------------------------------------------
  716. config
  717. ------------------------------------------------------------------------------------------------------------
  718. package com.upc.demo.config;
  719.  
  720. import java.util.ArrayList;
  721.  
  722. import org.springframework.context.annotation.Bean;
  723. import org.springframework.context.annotation.Configuration;
  724.  
  725. import springfox.documentation.service.ApiInfo;
  726. import springfox.documentation.service.VendorExtension;
  727. import springfox.documentation.spi.DocumentationType;
  728. import springfox.documentation.spring.web.plugins.Docket;
  729. import springfox.documentation.swagger2.annotations.EnableSwagger2;
  730.  
  731. @Configuration
  732. @EnableSwagger2
  733. public class SwaggerConfig {
  734.  
  735. public static final springfox.documentation.service.Contact DEFAULT_CONTACT = new springfox.documentation.service.Contact("Karique", "http://github.com/karique01",
  736. "kariquekeiter@gmail.com");
  737. @SuppressWarnings("rawtypes")
  738. public static final ApiInfo DEFAULT_API_INFO = new ApiInfo("Farma Api Documentation", "Farma Api Documentation", "1.0",
  739. "PREMIUM", DEFAULT_CONTACT, "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0",
  740. new ArrayList<VendorExtension>());
  741.  
  742.  
  743. @Bean
  744. public Docket api() {
  745. return new Docket(DocumentationType.SWAGGER_2).apiInfo(DEFAULT_API_INFO);
  746.  
  747. }
  748. }
  749. ------------------------------------------------------------------------------------------------------------
  750. application.yml
  751. ------------------------------------------------------------------------------------------------------------
  752. spring:
  753. datasource:
  754. driver-class-name: org.postgresql.Driver
  755. password: admin
  756. url: jdbc:postgresql://localhost/primi
  757. username: postgres
  758. jpa:
  759. database: POSTGRESQL
  760. hibernate:
  761. ddl-auto: update
  762. show-sql: 'false'
  763. properties.hibernate.temp.use_jdbc_metadata_defaults: false
  764. server:
  765. port: 9099
  766.  
  767. ------------------------------------------------------------------------------------------------------------
  768. pom.xml
  769. ------------------------------------------------------------------------------------------------------------
  770. <?xml version="1.0" encoding="UTF-8"?>
  771. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  772. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  773. <modelVersion>4.0.0</modelVersion>
  774.  
  775. <groupId>com.upc</groupId>
  776. <artifactId>primi</artifactId>
  777. <version>0.0.1-SNAPSHOT</version>
  778. <packaging>jar</packaging>
  779.  
  780. <name>primi</name>
  781. <description>Pet walk api rest</description>
  782.  
  783. <parent>
  784. <groupId>org.springframework.boot</groupId>
  785. <artifactId>spring-boot-starter-parent</artifactId>
  786. <version>2.1.0.RELEASE</version>
  787. <relativePath/> <!-- lookup parent from repository -->
  788. </parent>
  789.  
  790. <properties>
  791. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  792. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  793. <java.version>1.8</java.version>
  794. </properties>
  795.  
  796. <dependencies>
  797. <dependency>
  798. <groupId>org.springframework.boot</groupId>
  799. <artifactId>spring-boot-starter-data-jpa</artifactId>
  800. </dependency>
  801. <dependency>
  802. <groupId>org.springframework.boot</groupId>
  803. <artifactId>spring-boot-starter-web</artifactId>
  804. </dependency>
  805.  
  806. <dependency>
  807. <groupId>org.springframework.boot</groupId>
  808. <artifactId>spring-boot-devtools</artifactId>
  809. <scope>runtime</scope>
  810. </dependency>
  811. <dependency>
  812. <groupId>org.postgresql</groupId>
  813. <artifactId>postgresql</artifactId>
  814. <scope>runtime</scope>
  815. </dependency>
  816. <dependency>
  817. <groupId>org.springframework.boot</groupId>
  818. <artifactId>spring-boot-starter-test</artifactId>
  819. <scope>test</scope>
  820. </dependency>
  821.  
  822. <dependency>
  823. <groupId>io.springfox</groupId>
  824. <artifactId>springfox-swagger2</artifactId>
  825. <version>2.9.2</version>
  826. </dependency>
  827. <dependency>
  828. <groupId>io.springfox</groupId>
  829. <artifactId>springfox-swagger-ui</artifactId>
  830. <version>2.9.2</version>
  831. </dependency>
  832. </dependencies>
  833.  
  834. <build>
  835. <plugins>
  836. <plugin>
  837. <groupId>org.springframework.boot</groupId>
  838. <artifactId>spring-boot-maven-plugin</artifactId>
  839. </plugin>
  840. </plugins>
  841. </build>
  842.  
  843.  
  844. </project>
  845. ------------------------------------------------------------------------------------------------------------
  846. dependencias iniciales
  847. DevTools
  848. JPA
  849. PostgreSql
  850. Web
  851. ------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement