ServiceImplTemplate.ftl 2.84 KB
package ${basePackage}.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import ${basePackage}.bean.entity.${entityClassSimpleName};
import ${basePackage}.repository.${repositoryClassSimpleName};
import ${basePackage}.service.${serviceClassSimpleName};
import com.taover.util.UtilLog;
import com.taover.util.bean.ResultInfo;
import com.taover.util.bean.UtilResultInfo;

@Service
public class ${serviceImplClassSimpleName} implements ${serviceClassSimpleName} {
	@Resource
	private ${repositoryClassSimpleName} ${repositoryClassFieldName};
	
	@Override
	public ResultInfo getListV1(List<Object[]> condition, Integer page, Integer size) {
		try {
			return UtilResultInfo.getSuccess("查询成功", this.${repositoryClassFieldName}.getVoPage(condition, page, size));
		} catch (Exception e) {
			UtilLog.errorForException(e, this.getClass());
			return UtilResultInfo.getFailure(e.getMessage());
		}
	}

	@Override
	public ResultInfo getOneV1(String ssid) {
		try {
			return UtilResultInfo.getSuccess("查询成功", this.${repositoryClassFieldName}.getVoBySsid(ssid));
		} catch (Exception e) {
			UtilLog.errorForException(e, this.getClass());
			return UtilResultInfo.getFailure(e.getMessage());
		}
	}

	@Override
	public ResultInfo getListManage(List<Object[]> condition, Integer page, Integer size) {
		try {
			return UtilResultInfo.getSuccess("查询成功", this.${repositoryClassFieldName}.getVoPage(condition, page, size));
		} catch (Exception e) {
			UtilLog.errorForException(e, this.getClass());
			return UtilResultInfo.getFailure(e.getMessage());
		}
	}

	@Override
	public ResultInfo getOneManage(String ssid) {
		try {
			return UtilResultInfo.getSuccess("查询成功", this.${repositoryClassFieldName}.getVoBySsid(ssid));
		} catch (Exception e) {
			return UtilResultInfo.getFailure(e.getMessage());
		}
	}

	@Override
	public ResultInfo putManage(String ssid, List<Object[]> updateList) {
		try{
			this.${repositoryClassFieldName}.updateEntityBySsid(ssid, updateList);
		}catch(Exception e){
			UtilLog.errorForException(e, this.getClass());
			return UtilResultInfo.getFailure(e.getMessage());
		}
		return UtilResultInfo.getSuccess("更新成功");
	}

	@Override
	public ResultInfo deleteManage(String ssid) {
		try{
			this.${repositoryClassFieldName}.deleteEntityBySsid(ssid);
		}catch(Exception e){
			UtilLog.errorForException(e, this.getClass());
			return UtilResultInfo.getFailure(e.getMessage());
		}
		return UtilResultInfo.getSuccess("删除成功");
	}

	@Override
	public ResultInfo postManage(Map<String, Object> data) {
		try {
			return UtilResultInfo.getSuccess("创建成功", this.${repositoryClassFieldName}.addEntityByMap(data));
		} catch (Exception e) {
			UtilLog.errorForException(e, this.getClass());
			return UtilResultInfo.getFailure(e.getMessage());
		}
	}
}