Commit c8ecd85f authored by Sridhar Pothanaveni's avatar Sridhar Pothanaveni

Gen AI Hackthon

parent be5cbbb9
package com.nisum.task.controller;
import com.nisum.task.entity.BPN;
import com.nisum.task.service.BPNService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@Slf4j
@RestController
@RequestMapping("/bpn")
public class BPNController {
@Autowired
private BPNService bPNService;
@PostMapping("/createBPN")
public Mono<BPN> saveBPN(@RequestBody BPN bpn) {
log.info("saveBPN {}",bpn);
return bPNService.saveBPN(bpn);
}
@GetMapping("/findById/{bpnID}")
public Mono<BPN> getBPN(@PathVariable String bpnID) {
log.info("getBPN {}",bpnID);
return bPNService.findById(Long.valueOf(bpnID));
}
@GetMapping("/findAll")
public Flux<BPN> findAllBpns() {
log.info("find all");
return bPNService.findAll();
}
@PostMapping("/processBPN")
public Flux<BPN> processBPN(@RequestBody BPN bpn) {
log.info("processBPN {}",bpn);
return bPNService.processBPN(bpn);
}
}
package com.nisum.task.controller;
public class FileUploadController {
}
package com.nisum.task.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.core.mapping.Document;
import java.util.Date;
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Document
@Data
public class BPN {
private ObjectId id;
private String bpn;
private String rog;
private String fac;
private String forceOptCd;
private Date firstEffectiveDate;
private Date lasttEffectiveDate;
private String bpnStatus;
}
package com.nisum.task.repository;
import com.nisum.task.entity.BPN;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface BPNRepository extends ReactiveMongoRepository<BPN,Long> {
}
package com.nisum.task.service;
import com.nisum.task.entity.BPN;
import com.nisum.task.repository.BPNRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.util.Date;
@Service
public class BPNService {
@Autowired
private BPNRepository bpnRepository;
public Mono<BPN> saveBPN(BPN bpn) {
bpn.setBpnStatus("Active");
bpn.setFirstEffectiveDate(new Date());
bpn.setLasttEffectiveDate(new Date());
return bpnRepository.save(bpn);
}
public Mono<BPN> findById(Long bpnId) {
return bpnRepository.findById(bpnId);
}
public Flux<BPN> findAll() {
return bpnRepository.findAll();
}
public Flux<BPN> processBPN(BPN bpn) {
return bpnRepository.findAll();
}
}
......@@ -2,15 +2,15 @@
#spring.data.mongodb.host=localhost
#spring.data.mongodb.host=mongodb+srv://sridharyadav589:9640037146@testcluster.bl9klfi.mongodb.net/test
#database.name= studentDB
#database.host = mongodb://localhost:27017/
database.name= studentDB
database.host = mongodb://localhost:27017/
#database.host = mongodb://localhost:27017/
#spring.main.web-application-type: reactive
#spring.main.allow-bean-definition-overriding=true
database.name= sample_supplies
database.host = mongodb+srv://sridharyadav589:9640037146@testcluster.bl9klfi.mongodb.net/test
#database.name= sample_supplies
#database.host = mongodb+srv://sridharyadav589:9640037146@testcluster.bl9klfi.mongodb.net/test
#springdoc.swagger-ui.path=/swagger-doc/swagger-ui.html
#springdoc.api-docs.path=/swagger-doc/v3/api-docs
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment