Просмотр исходного кода

增加BaseServiceMock抽象类和模板

shuzheng 9 лет назад
Родитель
Сommit
834c0e4df5

+ 96 - 0
zheng-common/src/main/java/com/zheng/common/base/BaseServiceMock.java

@@ -0,0 +1,96 @@
+package com.zheng.common.base;
+
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 降级实现BaseService抽象类
+ * Created by ZhangShuzheng on 2017/02/14.
+ */
+public abstract class BaseServiceMock<Mapper, Record, Example> implements BaseService<Record, Example> {
+
+	@Override
+	public int countByExample(Example example) {
+		return -1;
+	}
+
+	@Override
+	public int deleteByExample(Example example) {
+		return -1;
+	}
+
+	@Override
+	public int deleteByPrimaryKey(Integer id) {
+		return -1;
+	}
+
+	@Override
+	public int insert(Record record) {
+		return -1;
+	}
+
+	@Override
+	public int insertSelective(Record record) {
+		return -1;
+	}
+
+	@Override
+	public List<Record> selectByExampleWithBLOBs(Example example) {
+		return null;
+	}
+
+	@Override
+	public List<Record> selectByExample(Example example) {
+		return null;
+	}
+
+	@Override
+	public Record selectFirstByExample(Example example) {
+		return null;
+	}
+
+	@Override
+	public Record selectByPrimaryKey(Integer id) {
+		return null;
+	}
+
+	@Override
+	public int updateByExampleSelective(@Param("record") Record record, @Param("example") Example example) {
+		return -1;
+	}
+
+	@Override
+	public int updateByExampleWithBLOBs(@Param("record") Record record, @Param("example") Example example) {
+		return -1;
+	}
+
+	@Override
+	public int updateByExample(@Param("record") Record record, @Param("example") Example example) {
+		return -1;
+	}
+
+	@Override
+	public int updateByPrimaryKeySelective(Record record) {
+		return -1;
+	}
+
+	@Override
+	public int updateByPrimaryKeyWithBLOBs(Record record) {
+		return -1;
+	}
+
+	@Override
+	public int updateByPrimaryKey(Record record) {
+		return -1;
+	}
+
+	@Override
+	public int deleteByPrimaryKeys(String ids) {
+		return -1;
+	}
+
+	@Override
+	public void initMapper() {}
+
+}

+ 21 - 0
zheng-common/src/main/resources/template/ServiceMock.vm

@@ -0,0 +1,21 @@
+package ${groupId}.${module}.rpc.service.impl;
+
+import ${groupId}.${module}.dao.mapper.${model}Mapper;
+import ${groupId}.${module}.dao.model.${model};
+import ${groupId}.${module}.dao.model.${model}Example;
+import ${groupId}.${module}.rpc.api.${model}Service;
+import ${groupId}.common.base.BaseServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+* 降级实现${modelname}Service
+* Created by shuzheng on ${ctime}.
+*/
+@Service
+@Transactional
+public class ${model}ServiceMock extends BaseServiceMock<${model}Mapper, ${model}, ${model}Example> implements ${model}Service {
+
+}