chengf
2025-12-10 ee89a5cfa50980f1f2f2fa84bb69741b161670b5
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
package com.java110.job.dao.impl;
 
import com.java110.dto.msg.MaintenancePaymentPo;
import com.java110.job.dao.IMaintenancePaymentService;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 维修资金支取信息表Service实现(SqlSessionTemplate版)
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class MaintenancePaymentServiceImpl implements IMaintenancePaymentService {
 
    // 注入MyBatis SqlSessionTemplate(核心)
    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;
 
    /**
     * 单条新增:对应XML中的SQL ID
     */
    @Override
    public int saveMaintenancePayment(MaintenancePaymentPo maintenancePaymentPo) {
        // 调用格式:sqlSessionTemplate.insert("XML命名空间.SQL ID", 参数)
        return sqlSessionTemplate.insert(
                "MaintenancePaymentMapper.insertMaintenancePayment",
                maintenancePaymentPo
        );
    }
 
    /**
     * 批量新增:参数封装为Map(兼容XML的foreach)
     */
    @Override
    public int batchSaveMaintenancePayment(List<MaintenancePaymentPo> poList) {
        Map<String, Object> paramMap = new HashMap<>();
        paramMap.put("list", poList); // 对应XML中foreach的collection="list"
        return sqlSessionTemplate.insert(
                "MaintenancePaymentMapper.batchInsertMaintenancePayment",
                paramMap
        );
    }
}