correcciones
This commit is contained in:
parent
c57f772984
commit
7ab8005967
@ -0,0 +1,85 @@
|
||||
package com.crov.controllers;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.crov.services.UsuarioModelService;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "http://localhost:5173")
|
||||
@RequestMapping("/api/usuariosModel")
|
||||
public class UsuarioModelController {
|
||||
|
||||
@Autowired
|
||||
UsuarioModelService usuarioService;
|
||||
//@Autowired
|
||||
//CorteService corteService;
|
||||
|
||||
PostMapping(value = "/getUsersByEmpresaUserModel", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(code = HttpStatus.OK)
|
||||
public List<UsuarioModel> getUsersByEmpresaUserModel(@RequestBody EmpresaUserModel empresaUserModel) {
|
||||
return usuarioService.getListUsuarioModelByEmpresaUserModel(empresaUserModel);
|
||||
}
|
||||
|
||||
@PostMapping(value = "/save", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(code = HttpStatus.OK)
|
||||
public boolean saveUser(@RequestBody UsuarioModel usuarioModel) {
|
||||
usuarioService.saveUser(usuarioModel);
|
||||
UsuarioModel usuarioModelNuevo = usuarioService.getUsuarioModelByEmpresaUserModelAndIdPuntoVenta(usuarioModel.getEmpresaUserModel(), usuarioModel.getIdPuntoVenta());
|
||||
Utilerias util = new Utilerias();
|
||||
CorteModel corteModel = new CorteModel();
|
||||
corteModel.setComentarios("Corte del nuevo usuario");
|
||||
corteModel.setEmpresaUserModel(usuarioModel.getEmpresaUserModel());
|
||||
corteModel.setEstatus(1);
|
||||
corteModel.setFecha(util.sumarDiasAFecha(new Date(), -30));
|
||||
corteModel.setId(UUID.randomUUID());
|
||||
corteModel.setIdPuntoVenta(1);
|
||||
corteModel.setMontoEsperado(0d);
|
||||
corteModel.setMontoReportado(0d);
|
||||
corteModel.setUsuarioEntrega(usuarioModelNuevo);
|
||||
corteModel.setUsuarioRecibe(usuarioModelNuevo);
|
||||
corteModel.setPrecorte(0);
|
||||
return corteService.save(corteModel);
|
||||
}
|
||||
|
||||
@PostMapping (value ="/sincronizacia-pv",produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE )
|
||||
@ResponseStatus(code =HttpStatus.OK)
|
||||
public Map<Integer, String> sincronizarUsuario(@RequestBody List<UsuarioModel> listUsuarioModel) {
|
||||
Map<Integer, String> map = new HashMap<>();
|
||||
for(int i=0; i<=listUsuarioModel.size()-1;i++) {
|
||||
try {
|
||||
boolean owo = usuarioService.saveUser(listUsuarioModel.get(i));
|
||||
if(owo) {
|
||||
map.put(listUsuarioModel.get(i).getIdPuntoVenta(), "Si");
|
||||
}else {
|
||||
map.put(listUsuarioModel.get(i).getIdPuntoVenta(), "No");
|
||||
}
|
||||
}catch(Exception e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
@PostMapping(value="status", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@ResponseStatus(code = HttpStatus.OK)
|
||||
public boolean status(@RequestBody GenericSearchDTO genericSearchDTO) {
|
||||
UsuarioModel usuarioModel = usuarioService.getUsuarioModelByEmpresaUserModelAndIdPuntoVenta(genericSearchDTO.getEmpresaUserModel(), genericSearchDTO.getIdExtra());
|
||||
usuarioModel.setActivo(genericSearchDTO.getIdExtraa());
|
||||
return usuarioService.saveUser(usuarioModel);
|
||||
}
|
||||
}
|
@ -1,7 +1,5 @@
|
||||
package com.crov.repositories;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
@ -12,7 +10,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import com.crov.models.ActivationKey;
|
||||
|
||||
@Repository
|
||||
public interface ActivationKeyRepository extends JpaRepository<ActivationKey, Long>{
|
||||
public interface ActivationKeyRepository extends JpaRepository<ActivationKey, String>{
|
||||
|
||||
@Query(value="SELECT IF(EXISTS(SELECT ac.activation_code, ac.active_key "
|
||||
+ "FROM activation_key ac WHERE ac.activation_code =:actCode AND active_key = 'Yes'),1,0)AS resul", nativeQuery=true)
|
||||
|
@ -1,13 +1,11 @@
|
||||
package com.crov.repositories;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.crov.models.PersonSoftware;
|
||||
|
||||
@Repository
|
||||
public interface PersonSoftwareRepository extends CrudRepository<PersonSoftware, UUID>{
|
||||
public interface PersonSoftwareRepository extends CrudRepository<PersonSoftware, String>{
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import org.springframework.stereotype.Repository;
|
||||
import com.crov.models.Software;
|
||||
|
||||
@Repository
|
||||
public interface SoftwareRepository extends JpaRepository<Software, Long>{
|
||||
public interface SoftwareRepository extends JpaRepository<Software, String>{
|
||||
|
||||
@Query(value="SELECT IF(EXISTS(SELECT cl.mac FROM customer_license_by_product cl WHERE cl.mac =:vaMac ),1,0 )", nativeQuery=true)
|
||||
int revisarMacExistePreviamente(@Param ("vaMac")String valueMac );
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.crov.repositories;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.crov.models.EmpresaUser;
|
||||
import com.crov.models.UsuarioModel;
|
||||
|
||||
@Repository
|
||||
public interface UsuarioModelRepository extends JpaRepository<UsuarioModel, String>{
|
||||
|
||||
List<UsuarioModel> findByEmpresaUserModel(EmpresaUser empresaUserModel);
|
||||
|
||||
List<UsuarioModel> findByEmpresaUserModelAndActivo(EmpresaUser empresaUserModel, Integer activo);
|
||||
|
||||
UsuarioModel findByEmpresaUserModelAndIdPuntoVenta(EmpresaUser empresaModel, Integer idPuntoVenta);
|
||||
|
||||
Optional<UsuarioModel> findById(String uuid);
|
||||
}
|
36
src/main/java/com/crov/services/UsuarioModelService.java
Normal file
36
src/main/java/com/crov/services/UsuarioModelService.java
Normal file
@ -0,0 +1,36 @@
|
||||
package com.crov.services;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.crov.models.EmpresaUser;
|
||||
import com.crov.models.UsuarioModel;
|
||||
import com.crov.repositories.UsuarioModelRepository;
|
||||
|
||||
@Service
|
||||
public class UsuarioModelService {
|
||||
|
||||
@Autowired
|
||||
UsuarioModelRepository usuarioRepository;
|
||||
|
||||
public List<UsuarioModel> getListUsuarioModelByEmpresaUserModel(EmpresaUser empresaUserModel){
|
||||
return usuarioRepository.findByEmpresaUserModelAndActivo(empresaUserModel,1);
|
||||
}
|
||||
|
||||
public UsuarioModel getUsuarioModelByEmpresaUserModelAndIdPuntoVenta(EmpresaUser empresaModel, Integer idPuntoVenta) {
|
||||
return usuarioRepository.findByEmpresaUserModelAndIdPuntoVenta(empresaModel, idPuntoVenta);
|
||||
}
|
||||
|
||||
|
||||
public Optional<UsuarioModel> findById(String id){
|
||||
return usuarioRepository.findById(id);
|
||||
|
||||
}
|
||||
|
||||
public boolean saveUser(UsuarioModel usuarioModel) {
|
||||
return usuarioRepository.save(usuarioModel) != null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user