forked from thinkgem/jeesite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
55 additions
and
55 deletions.
There are no files selected for viewing
110 changes: 55 additions & 55 deletions
110
src/main/java/com/thinkgem/jeesite/generate/template/service.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,55 @@ | ||
/** | ||
* There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation | ||
*/ | ||
package ${packageName}.${moduleName}.service${subModuleName}; | ||
|
||
import org.hibernate.criterion.DetachedCriteria; | ||
import org.hibernate.criterion.Order; | ||
import org.hibernate.criterion.Restrictions; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.thinkgem.jeesite.common.persistence.Page; | ||
import com.thinkgem.jeesite.common.service.BaseService; | ||
import com.thinkgem.jeesite.common.utils.StringUtils; | ||
import ${packageName}.${moduleName}.entity${subModuleName}.${ClassName}; | ||
import ${packageName}.${moduleName}.dao${subModuleName}.${ClassName}Dao; | ||
|
||
/** | ||
* ${functionName}Service | ||
* @author ${classAuthor} | ||
* @version ${classVersion} | ||
*/ | ||
@Component | ||
@Transactional(readOnly = true) | ||
public class ${ClassName}Service extends BaseService { | ||
|
||
@Autowired | ||
private ${ClassName}Dao ${className}Dao; | ||
|
||
public ${ClassName} get(Long id) { | ||
return ${className}Dao.get(id); | ||
} | ||
|
||
public Page<${ClassName}> find(Page<${ClassName}> page, ${ClassName} ${className}) { | ||
DetachedCriteria dc = ${className}Dao.createDetachedCriteria(); | ||
if (StringUtils.isNotEmpty(${className}.getName())){ | ||
dc.add(Restrictions.like("name", "%"+${className}.getName()+"%")); | ||
} | ||
dc.add(Restrictions.eq(${ClassName}.DEL_FLAG, ${ClassName}.DEL_FLAG_NORMAL)); | ||
dc.addOrder(Order.desc("id")); | ||
return ${className}Dao.find(page, dc); | ||
} | ||
|
||
@Transactional(readOnly = false) | ||
public void save(${ClassName} ${className}) { | ||
${className}Dao.save(${className}); | ||
} | ||
|
||
@Transactional(readOnly = false) | ||
public void delete(Long id) { | ||
${className}Dao.deleteById(id); | ||
} | ||
|
||
} | ||
/** | ||
* There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation | ||
*/ | ||
package ${packageName}.${moduleName}.service${subModuleName}; | ||
|
||
import org.hibernate.criterion.DetachedCriteria; | ||
import org.hibernate.criterion.Order; | ||
import org.hibernate.criterion.Restrictions; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import com.thinkgem.jeesite.common.persistence.Page; | ||
import com.thinkgem.jeesite.common.service.BaseService; | ||
import com.thinkgem.jeesite.common.utils.StringUtils; | ||
import ${packageName}.${moduleName}.entity${subModuleName}.${ClassName}; | ||
import ${packageName}.${moduleName}.dao${subModuleName}.${ClassName}Dao; | ||
|
||
/** | ||
* ${functionName}Service | ||
* @author ${classAuthor} | ||
* @version ${classVersion} | ||
*/ | ||
@Component | ||
@Transactional(readOnly = true) | ||
public class ${ClassName}Service extends BaseService { | ||
|
||
@Autowired | ||
private ${ClassName}Dao ${className}Dao; | ||
|
||
public ${ClassName} get(Long id) { | ||
return ${className}Dao.get(id); | ||
} | ||
|
||
public Page<${ClassName}> find(Page<${ClassName}> page, ${ClassName} ${className}) { | ||
DetachedCriteria dc = ${className}Dao.createDetachedCriteria(); | ||
if (StringUtils.isNotEmpty(${className}.getName())){ | ||
dc.add(Restrictions.like("name", "%"+${className}.getName()+"%")); | ||
} | ||
dc.add(Restrictions.eq(${ClassName}.FIELD_DEL_FLAG, ${ClassName}.DEL_FLAG_NORMAL)); | ||
dc.addOrder(Order.desc("id")); | ||
return ${className}Dao.find(page, dc); | ||
} | ||
|
||
@Transactional(readOnly = false) | ||
public void save(${ClassName} ${className}) { | ||
${className}Dao.save(${className}); | ||
} | ||
|
||
@Transactional(readOnly = false) | ||
public void delete(Long id) { | ||
${className}Dao.deleteById(id); | ||
} | ||
|
||
} |