Commit cdb2d293 by s_guodong

去掉mybatis模块

parent 3979441c
......@@ -28,11 +28,6 @@
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.brilliance</groupId>
<artifactId>gjjs-bd-mybatis-support</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
......@@ -107,6 +102,10 @@
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>gjjs-bd-common</artifactId>
<groupId>com.brilliance</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>gjjs-bd-mybatis-support</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>com.brilliance</groupId>
<artifactId>gjjs-bd-runtime</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.brilliance</groupId>
<artifactId>gjjs-mda</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.brilliance.mda.support.mybatis;
import com.brilliance.mda.runtime.mda.ILocker;
import com.brilliance.mda.runtime.mda.LockInfo;
import org.springframework.stereotype.Component;
import java.io.Serializable;
@Component
public class DBLocker implements ILocker {
@Override
public boolean lock(Serializable key) {
return false;
}
@Override
public boolean lock(Serializable key, int expireflg) {
return false;
}
@Override
public boolean lock(Serializable key, long timeout) {
return false;
}
@Override
public LockInfo lock(String userName, Serializable key) {
return null;
}
@Override
public boolean unlock(Serializable key) {
return false;
}
@Override
public boolean unlock(String lockname, Serializable key) {
return false;
}
}
package com.brilliance.mda.support.mybatis;
import com.brilliance.mda.runtime.mda.IDisplay;
import org.apache.commons.io.IOUtils;
import org.springframework.stereotype.Component;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
/**
* 快照保存器
* @author fukai
*
*/
@Component
public class FileDisplayManager implements IDisplay {
@Override
public boolean saveDisplay(String filePathOrKey,String data) {
File file = new File(filePathOrKey);
File parentFolder = file.getParentFile();
if(!parentFolder.exists() && !parentFolder.mkdirs())
return false;
FileWriter fr = null;
try{
file.createNewFile();
fr = new FileWriter(file);
IOUtils.write(data, fr);
}catch(Exception e)
{
e.printStackTrace();
return false;
}
return true;
}
@SuppressWarnings("deprecation")
@Override
public String readDisplay(String filePathOrKey) {
File file = new File(filePathOrKey);
if(!file.exists())
return null;
FileReader fr = null;
try{
fr = new FileReader(file);
return IOUtils.toString(fr);
}catch(Exception e)
{
e.printStackTrace();
}finally
{
IOUtils.closeQuietly(fr);
}
return null;
}
}
package com.brilliance.mda.support.mybatis.count;
public class Cnt {
private String nam; //配置名称
private int val; //配置名称
private int stp; //配置名称
}
package com.brilliance.mda.support.mybatis.count;
import com.brilliance.mda.support.mybatis.count.mapper.CounterMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
/**
* @author hulei
* dbcounter基于oracle自主事务的实现
*/
//@Service
public class CounterImplWithOracleTransaction implements CounterService {
Logger logger = LoggerFactory.getLogger(this.getClass().getName());
@Resource
public CounterMapper counterMapper;
public int dbCounter(String seqname) {
String seq = "SEQ_" + seqname.toUpperCase();
return counterMapper.seqNextval(seq);
}
}
package com.brilliance.mda.support.mybatis.count;
import com.brilliance.mda.runtime.mda.RuleExecuteException;
import com.brilliance.mda.support.mybatis.count.mapper.CounterMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.concurrent.locks.ReentrantLock;
@Service
public class CounterImplWithSpringTransaction implements CounterService {
Logger logger = LoggerFactory.getLogger(this.getClass().getName());
@Resource
public CounterMapper counterMapper;
public ReentrantLock lock = new ReentrantLock();
@Transactional(propagation=Propagation.REQUIRES_NEW)
public int dbCounter(String seqname)
{
Integer cnt = counterMapper.getCountValWithUpdate(seqname);
if(cnt == null) cnt = 0;
if(cnt == 0)
{
lock.lock();
try {
cnt = counterMapper.getCountValWithUpdate(seqname);
if(cnt == null) {
cnt = 0;
counterMapper.insertNewCounter(seqname, 1); //插入新数
}
else
counterMapper.updateCounter(seqname); //计算器增加
}catch (Exception e)
{
throw(new RuleExecuteException("主键生成异常",e));
}finally {
lock.unlock();
}
}
else
counterMapper.updateCounter(seqname); //计算器增加
return cnt;
}
}
package com.brilliance.mda.support.mybatis.count;
public interface CounterService {
int dbCounter(String seqname);
}
package com.brilliance.mda.support.mybatis.count.mapper;
import java.util.HashMap;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
@Component
public class CounterMapper{
final String FNAME = this.getClass().getName();
@Autowired
public SqlSessionTemplate template;
public Integer getCountValWithUpdate(@Param("nam") String seqName){
return template.selectOne(FNAME+".getCountValWithUpdate",seqName);
}
public int insertNewCounter(@Param("nam") String nam, @Param("stp") int stp){
Map<String, Object> map = new HashMap<>();
map.put("nam", nam);
map.put("start",1);
map.put("stp", stp);
return template.insert(FNAME+".insertNewCounter",map);
}
public void updateCounter(@Param("nam") String seqName){
template.selectOne(FNAME+".updateCounter",seqName);
}
public int seqNextval(String seqName) {
return template.selectOne(FNAME+".seqNextval",seqName);
}
public int dbCounter(String seqName){
return template.selectOne(FNAME+".dbCounter",seqName);
}
}
\ No newline at end of file
package com.brilliance.mda.support.mybatis.dync;
import com.brilliance.mda.runtime.mda.impl.AbstractModule;
public class DbExecute extends AbstractModule{
}
package com.brilliance.mda.support.mybatis.dync.mapper;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
@Component
public class DbExecuteMapper {
@Autowired
SqlSessionTemplate sqlSessionTemplate;
final String FNAME = this.getClass().getName();
public List<Map<String,Object>> dyncReadForMap(Map<String,Object> params){
return sqlSessionTemplate.selectList(FNAME+".dyncReadForMap",params);
}
public int dyncUpdateForMap(Map<String,Object> params){
return sqlSessionTemplate.update(FNAME+".dyncUpdateForMap",params);
}
}
package com.brilliance.mda.support.mybatis.entity;
import java.lang.annotation.*;
@Inherited
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Column {
public String value();
}
package com.brilliance.mda.support.mybatis.entity;
import java.lang.annotation.*;
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Table {
public String value();
}
package com.brilliance.mda.support.mybatis.listener;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
@Component
public class StartListener implements ApplicationListener<ContextRefreshedEvent>{
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
ApplicationContext context = event.getApplicationContext();
}
}
......@@ -10,7 +10,6 @@
</parent>
<modules>
<module>gjjs-bd-business</module>
<module>gjjs-bd-mybatis-support</module>
</modules>
<groupId>com.brilliance</groupId>
......
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