TBusUserEducationServiceImpl.java 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. package cn.com.lzt.education.service.impl;
  2. import cn.com.lzt.education.service.TBusUserEducationServiceI;
  3. import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
  4. import cn.com.lzt.education.entity.TBusUserEducationEntity;
  5. import org.springframework.stereotype.Service;
  6. import org.springframework.transaction.annotation.Transactional;
  7. import java.util.HashMap;
  8. import java.util.Map;
  9. import java.util.UUID;
  10. import java.io.Serializable;
  11. import org.jeecgframework.core.util.ApplicationContextUtil;
  12. import org.jeecgframework.core.util.MyClassLoader;
  13. import org.jeecgframework.core.util.StringUtil;
  14. import org.jeecgframework.web.cgform.enhance.CgformEnhanceJavaInter;
  15. @Service("tBusUserEducationService")
  16. @Transactional
  17. public class TBusUserEducationServiceImpl extends CommonServiceImpl implements TBusUserEducationServiceI {
  18. public void delete(TBusUserEducationEntity entity) throws Exception{
  19. super.delete(entity);
  20. //执行删除操作增强业务
  21. this.doDelBus(entity);
  22. }
  23. public Serializable save(TBusUserEducationEntity entity) throws Exception{
  24. Serializable t = super.save(entity);
  25. //执行新增操作增强业务
  26. this.doAddBus(entity);
  27. return t;
  28. }
  29. public void saveOrUpdate(TBusUserEducationEntity entity) throws Exception{
  30. super.saveOrUpdate(entity);
  31. //执行更新操作增强业务
  32. this.doUpdateBus(entity);
  33. }
  34. /**
  35. * 新增操作增强业务
  36. * @param t
  37. * @return
  38. */
  39. private void doAddBus(TBusUserEducationEntity t) throws Exception{
  40. //-----------------sql增强 start----------------------------
  41. //-----------------sql增强 end------------------------------
  42. //-----------------java增强 start---------------------------
  43. //-----------------java增强 end-----------------------------
  44. }
  45. /**
  46. * 更新操作增强业务
  47. * @param t
  48. * @return
  49. */
  50. private void doUpdateBus(TBusUserEducationEntity t) throws Exception{
  51. //-----------------sql增强 start----------------------------
  52. //-----------------sql增强 end------------------------------
  53. //-----------------java增强 start---------------------------
  54. //-----------------java增强 end-----------------------------
  55. }
  56. /**
  57. * 删除操作增强业务
  58. * @param id
  59. * @return
  60. */
  61. private void doDelBus(TBusUserEducationEntity t) throws Exception{
  62. //-----------------sql增强 start----------------------------
  63. //-----------------sql增强 end------------------------------
  64. //-----------------java增强 start---------------------------
  65. //-----------------java增强 end-----------------------------
  66. }
  67. private Map<String,Object> populationMap(TBusUserEducationEntity t){
  68. Map<String,Object> map = new HashMap<String,Object>();
  69. map.put("id", t.getId());
  70. map.put("create_name", t.getCreateName());
  71. map.put("create_by", t.getCreateBy());
  72. map.put("create_date", t.getCreateDate());
  73. map.put("update_name", t.getUpdateName());
  74. map.put("update_by", t.getUpdateBy());
  75. map.put("update_date", t.getUpdateDate());
  76. map.put("sys_org_code", t.getSysOrgCode());
  77. map.put("sys_company_code", t.getSysCompanyCode());
  78. map.put("bpm_status", t.getBpmStatus());
  79. map.put("user_id", t.getUserId());
  80. map.put("edu_type", t.getEduType());
  81. map.put("school", t.getSchool());
  82. map.put("edu_starttime", t.getEduStarttime());
  83. map.put("edu_endtime", t.getEduEndtime());
  84. map.put("description", t.getDescription());
  85. return map;
  86. }
  87. /**
  88. * 替换sql中的变量
  89. * @param sql
  90. * @param t
  91. * @return
  92. */
  93. public String replaceVal(String sql,TBusUserEducationEntity t){
  94. sql = sql.replace("#{id}",String.valueOf(t.getId()));
  95. sql = sql.replace("#{create_name}",String.valueOf(t.getCreateName()));
  96. sql = sql.replace("#{create_by}",String.valueOf(t.getCreateBy()));
  97. sql = sql.replace("#{create_date}",String.valueOf(t.getCreateDate()));
  98. sql = sql.replace("#{update_name}",String.valueOf(t.getUpdateName()));
  99. sql = sql.replace("#{update_by}",String.valueOf(t.getUpdateBy()));
  100. sql = sql.replace("#{update_date}",String.valueOf(t.getUpdateDate()));
  101. sql = sql.replace("#{sys_org_code}",String.valueOf(t.getSysOrgCode()));
  102. sql = sql.replace("#{sys_company_code}",String.valueOf(t.getSysCompanyCode()));
  103. sql = sql.replace("#{bpm_status}",String.valueOf(t.getBpmStatus()));
  104. sql = sql.replace("#{user_id}",String.valueOf(t.getUserId()));
  105. sql = sql.replace("#{edu_type}",String.valueOf(t.getEduType()));
  106. sql = sql.replace("#{school}",String.valueOf(t.getSchool()));
  107. sql = sql.replace("#{edu_starttime}",String.valueOf(t.getEduStarttime()));
  108. sql = sql.replace("#{edu_endtime}",String.valueOf(t.getEduEndtime()));
  109. sql = sql.replace("#{description}",String.valueOf(t.getDescription()));
  110. sql = sql.replace("#{UUID}",UUID.randomUUID().toString());
  111. return sql;
  112. }
  113. /**
  114. * 执行JAVA增强
  115. */
  116. private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
  117. if(StringUtil.isNotEmpty(cgJavaValue)){
  118. Object obj = null;
  119. try {
  120. if("class".equals(cgJavaType)){
  121. //因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
  122. obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
  123. }else if("spring".equals(cgJavaType)){
  124. obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
  125. }
  126. if(obj instanceof CgformEnhanceJavaInter){
  127. CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
  128. javaInter.execute("t_bus_user_education",data);
  129. }
  130. } catch (Exception e) {
  131. e.printStackTrace();
  132. throw new Exception("执行JAVA增强出现异常!");
  133. }
  134. }
  135. }
  136. }