Datasets:

ArXiv:
License:
File size: 1,767 Bytes
c574d3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model.dao;

import beans.Evidencia;
import beans.Reporte;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import model.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;

/**
 *
 * @author Juan Carlos
 */
public class EvidenciaDAO {
    
    
    public static int agregarImagen(byte[] datos, int idReporte) throws Exception {
        int fa = 0;
        SqlSession conn = null;
        HashMap<String, Object> map = new HashMap<>();
        map.put("foto", datos);
        map.put("idReporte", idReporte);
        System.out.println(datos.length);
        try {
            conn = MyBatisUtils.getSession();
            fa = conn.insert("Evidencia.insertarImagen", map);
            conn.commit();
            if (fa > 0) {
                return fa;
            } else {
                return -3;
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new Exception(ex);
        } finally {
            if (conn != null) {
                conn.close();
            }
        }
    }
    
    public static List<Evidencia> getEvidencias(int idReporte){
        List<Evidencia> list = new ArrayList<>();
        SqlSession conn = null;
        try {
                conn = MyBatisUtils.getSession();
                list = conn.selectList("Evidencia.obtenerFotosReporte", idReporte);
            } catch (Exception ex) {
                ex.printStackTrace();
         }finally{
            if (conn != null){
                conn.close();
            }
        }
        return list;
    }
}