Commit 563457bb by kangxiaoshan

合同上传

parent 1f63568c
......@@ -401,18 +401,15 @@ public class ContractController {
@ResponseBody
public ResultModel changesDel(@PathVariable String platform, @CurrentAccount User loginAccount,
String id, String type, HttpServletRequest request) {
return ResultModel.OK(service.changesDel(platform, id, type, IPAddrUtil.getIpAddrNew(request), loginAccount));
}
@RequestMapping("/upload")
@RequestMapping(value = "/upload",method = RequestMethod.POST)
@ResponseBody
public ResultModel fileUpload2(@RequestParam("file") MultipartFile file, @PathVariable String platform) {
return service.uploadBatchInfo(file,platform);
}
......
package common.jdbc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class ContractDao {
@Autowired
JdbcTemplate jdbcTemplate;
public void batchSaveContract(String sql, List<Object[]> args) {
jdbcTemplate.batchUpdate(sql, args);
}
}
package common.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Component;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.interceptor.DefaultTransactionAttribute;
@Component
public class TransactionUtils {
@Autowired
@Qualifier(value = "jdbcTransactionManager")
private DataSourceTransactionManager jdbcTransactionManager;
// 开启事务
public TransactionStatus begin() {
TransactionStatus transaction = jdbcTransactionManager.getTransaction(new DefaultTransactionAttribute());
return transaction;
}
// 提交事务
public void commit(TransactionStatus transaction) {
jdbcTransactionManager.commit(transaction);
}
// 回滚事务
public void rollback(TransactionStatus transaction) {
jdbcTransactionManager.rollback(transaction);
}
}
......@@ -261,6 +261,7 @@
<tx:method name="query*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="find*" propagation="SUPPORTS" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"/>
<tx:method name="uploadBatchInfo" propagation="NEVER"/>
</tx:attributes>
</tx:advice>
......@@ -342,4 +343,7 @@
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource"></property>
</bean>
<bean id="jdbcTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
</beans>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment