heheng
2024-11-07 37b0d2560607d1e0bfd5247a59a154704cac60f8
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
package com.gkhy.labRiskManage.domain.basic.repository.jpa;
 
 
import com.gkhy.labRiskManage.domain.basic.entity.BasicExperimentDevice;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
 
import java.util.List;
 
 
/**
 * 基础实验设备
 */
@Repository
public interface BasicExperimentDeviceRepository extends JpaRepository<BasicExperimentDevice, Long>, JpaSpecificationExecutor<BasicExperimentDevice> {
 
    /**
     * 查询设备 - by id
     * */
    @Query(value = "select t from BasicExperimentDevice t where t.id = :id and t.deleteStatus = 0")
    BasicExperimentDevice getDeviceById(Long id);
 
    /**
     * 查询设备 - by deviceCode
     * */
    @Query(value = "select t from BasicExperimentDevice t where t.deviceCode = :deviceCode and t.deleteStatus = 0")
    BasicExperimentDevice getDeviceByCode(String deviceCode);
 
    /**
     * 查询设备 - by deviceName
     * */
    @Query(value = "select t from BasicExperimentDevice t where t.deviceName = :deviceName and t.deleteStatus = 0")
    BasicExperimentDevice getDeviceByName(String deviceName);
 
    /**
     * 基础仪器设备表 - 删除
     * */
    @Query(value = "update BasicExperimentDevice t set t.deleteStatus = 0 where t.id = :id")
    int deleteBasicExperimentDevice(Long id);
 
    /**
     * 基础仪器设备表 - 设备列表 - 查询所有
     * */
    @Query(value = "select t from BasicExperimentDevice t where  t.deleteStatus = 0")
    List<BasicExperimentDevice> listDevice();
 
    /**
     * 基础仪器设备表 - 设备列表 - 查询相关
     * */
    @Query(value = "select t from BasicExperimentDevice t where t.createByUserId = :currentUserId and  t.deleteStatus = 0")
    List<BasicExperimentDevice> listDeviceByUserId(Long currentUserId);
 
    /**
     * 基础仪器设备表 - 通过id列表查询
     * */
    @Query(value = "select t from BasicExperimentDevice t where t.id in (?1) and t.deleteStatus = 0")
    List<BasicExperimentDevice> batchById(List<Long> ids);
}