package com.cnbm.packing.service; import com.cnbm.dynamic.datasource.annotation.DataSource; import com.cnbm.packing.dto.WoPowerLevelDTO; import com.cnbm.packing.mapper.CamlineMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; /** * @Desc: "" * @Author: caixiang * @DATE: 2023/2/15 14:19 */ @Service public class DynamicDataSourceService { @Autowired CamlineMapper mapper; @Autowired WoPowerLevelServiceBiz powerLevelServiceBiz; @Transactional @DataSource("slave1") public void salve1Get(){ WoPowerLevelDTO woPowerLevelDTO = powerLevelServiceBiz.get(Long.valueOf(1)); System.out.println(woPowerLevelDTO.toString()); } public void getTodayBoxNum(){ Integer todayBoxNum = mapper.getTodayBoxNum(); System.out.println(todayBoxNum); } public float getPMPPBySubId(String subId){ return mapper.getPMPPBySubId(subId); } @DataSource("slave2") @Transactional public void salve3Get(){ float byid = mapper.getByid("LTWeight"); System.out.println(byid); } }