23 changed files with 234 additions and 40 deletions
@ -0,0 +1,9 @@ |
|||||
|
package com.epmet.constant; |
||||
|
|
||||
|
public interface DataSourceConstant { |
||||
|
|
||||
|
String GOV_ORG = "govOrg"; |
||||
|
String STATS = "stats"; |
||||
|
String GOV_ISSUE = "govIssue"; |
||||
|
|
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.dao.stats; |
||||
|
|
||||
|
import com.epmet.commons.mybatis.dao.BaseDao; |
||||
|
import com.epmet.entity.stats.DimYearEntity; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
/** |
||||
|
* 年维度表 |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2020-06-15 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface DimYearDao extends BaseDao<DimYearEntity> { |
||||
|
int insertOne(DimYearEntity entity); |
||||
|
} |
@ -0,0 +1,43 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.entity.stats; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
/** |
||||
|
* 年维度表 |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2020-06-15 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@TableName("dim_year") |
||||
|
public class DimYearEntity extends BaseEpmetEntity { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 2019年 |
||||
|
*/ |
||||
|
private String yearName; |
||||
|
|
||||
|
} |
@ -1,11 +1,10 @@ |
|||||
package com.epmet.service.Issue; |
package com.epmet.service.Issue; |
||||
|
|
||||
import com.epmet.entity.IssueEntity; |
import com.epmet.entity.issue.IssueEntity; |
||||
|
|
||||
import java.util.List; |
import java.util.List; |
||||
|
|
||||
public interface DemoIssueService { |
public interface DemoIssueService { |
||||
|
|
||||
List<IssueEntity> listAllEntities(); |
List<IssueEntity> listAllEntities(); |
||||
|
|
||||
} |
} |
||||
|
@ -0,0 +1,8 @@ |
|||||
|
package com.epmet.service; |
||||
|
|
||||
|
public interface StatsDemoService { |
||||
|
|
||||
|
void testList(); |
||||
|
void testTx(); |
||||
|
|
||||
|
} |
@ -0,0 +1,7 @@ |
|||||
|
package com.epmet.service.stats; |
||||
|
|
||||
|
public interface DemoDataStatsService { |
||||
|
|
||||
|
void testTx(); |
||||
|
|
||||
|
} |
@ -1,5 +0,0 @@ |
|||||
package com.epmet.service.stats; |
|
||||
|
|
||||
public interface StatsDemoService { |
|
||||
void demo(); |
|
||||
} |
|
@ -0,0 +1,38 @@ |
|||||
|
package com.epmet.service.stats.impl; |
||||
|
|
||||
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
||||
|
import com.epmet.constant.DataSourceConstant; |
||||
|
import com.epmet.dao.stats.DimYearDao; |
||||
|
import com.epmet.entity.stats.DimYearEntity; |
||||
|
import com.epmet.service.stats.DemoDataStatsService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
@DataSource(value = DataSourceConstant.STATS) |
||||
|
@Service |
||||
|
public class DemoDataStatsServiceImpl implements DemoDataStatsService { |
||||
|
|
||||
|
@Autowired |
||||
|
private DimYearDao dimYearDao; |
||||
|
|
||||
|
/** |
||||
|
* 此service可以加事务 |
||||
|
*/ |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
@Override |
||||
|
public void testTx() { |
||||
|
DimYearEntity dimYearEntity = new DimYearEntity(); |
||||
|
dimYearEntity.setYearName("1"); |
||||
|
dimYearEntity.setId("aaa"); |
||||
|
dimYearEntity.setCreatedBy(""); |
||||
|
dimYearEntity.setDelFlag(""); |
||||
|
dimYearEntity.setRevision(0); |
||||
|
dimYearEntity.setUpdatedBy(""); |
||||
|
dimYearEntity.setUpdatedTime(new Date()); |
||||
|
dimYearDao.insert(dimYearEntity); |
||||
|
dimYearDao.insert(dimYearEntity); |
||||
|
} |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
|
||||
|
<mapper namespace="com.epmet.dao.stats.DimYearDao"> |
||||
|
|
||||
|
<resultMap type="com.epmet.entity.stats.DimYearEntity" id="dimYearMap"> |
||||
|
<result property="id" column="ID"/> |
||||
|
<result property="yearName" column="YEAR_NAME"/> |
||||
|
<result property="delFlag" column="DEL_FLAG"/> |
||||
|
<result property="revision" column="REVISION"/> |
||||
|
<result property="createdBy" column="CREATED_BY"/> |
||||
|
<result property="createdTime" column="CREATED_TIME"/> |
||||
|
<result property="updatedBy" column="UPDATED_BY"/> |
||||
|
<result property="updatedTime" column="UPDATED_TIME"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
<insert id="insertOne"> |
||||
|
INSERT INTO dim_year |
||||
|
(ID, YEAR_NAME, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME) |
||||
|
VALUES |
||||
|
(#{ID}, #{YEAR_NAME}, #{DEL_FLAG}, #{REVISION}, #{CREATED_BY}, #{CREATED_TIME}, #{UPDATED_BY}, #{UPDATED_TIME}) |
||||
|
</insert> |
||||
|
|
||||
|
|
||||
|
</mapper> |
@ -0,0 +1,23 @@ |
|||||
|
package com.epmet.stats.test; |
||||
|
|
||||
|
import com.epmet.DataStatsApplication; |
||||
|
import com.epmet.service.StatsDemoService; |
||||
|
import org.junit.Test; |
||||
|
import org.junit.runner.RunWith; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.test.context.SpringBootTest; |
||||
|
import org.springframework.test.context.junit4.SpringRunner; |
||||
|
|
||||
|
@RunWith(value = SpringRunner.class) |
||||
|
@SpringBootTest(classes = {DataStatsApplication.class}) |
||||
|
public class TestTx { |
||||
|
|
||||
|
@Autowired |
||||
|
private StatsDemoService statsDemoService; |
||||
|
|
||||
|
@Test |
||||
|
public void testTx() { |
||||
|
statsDemoService.testTx(); |
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue