SysMsgDetailServiceImpl.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package cn.com.lzt.sysmsgdetail.service.impl;
  2. import cn.com.lzt.sysmsgdetail.service.SysMsgDetailServiceI;
  3. import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
  4. import cn.com.lzt.sysmsgdetail.entity.SysMsgDetailEntity;
  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("sysMsgDetailService")
  16. @Transactional
  17. public class SysMsgDetailServiceImpl extends CommonServiceImpl implements SysMsgDetailServiceI {
  18. public void delete(SysMsgDetailEntity entity) throws Exception{
  19. super.delete(entity);
  20. //执行删除操作增强业务
  21. this.doDelBus(entity);
  22. }
  23. public Serializable save(SysMsgDetailEntity entity) throws Exception{
  24. Serializable t = super.save(entity);
  25. //执行新增操作增强业务
  26. this.doAddBus(entity);
  27. return t;
  28. }
  29. public void saveOrUpdate(SysMsgDetailEntity 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(SysMsgDetailEntity 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(SysMsgDetailEntity 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(SysMsgDetailEntity t) throws Exception{
  62. //-----------------sql增强 start----------------------------
  63. //-----------------sql增强 end------------------------------
  64. //-----------------java增强 start---------------------------
  65. //-----------------java增强 end-----------------------------
  66. }
  67. private Map<String,Object> populationMap(SysMsgDetailEntity t){
  68. Map<String,Object> map = new HashMap<String,Object>();
  69. map.put("id", t.getId());
  70. map.put("msg_id", t.getMsgId());
  71. map.put("received_id", t.getReceivedId());
  72. map.put("read_status", t.getReadStatus());
  73. map.put("read_time", t.getReadTime());
  74. map.put("create_date", t.getCreateDate());
  75. return map;
  76. }
  77. /**
  78. * 替换sql中的变量
  79. * @param sql
  80. * @param t
  81. * @return
  82. */
  83. public String replaceVal(String sql,SysMsgDetailEntity t){
  84. sql = sql.replace("#{id}",String.valueOf(t.getId()));
  85. sql = sql.replace("#{msg_id}",String.valueOf(t.getMsgId()));
  86. sql = sql.replace("#{received_id}",String.valueOf(t.getReceivedId()));
  87. sql = sql.replace("#{read_status}",String.valueOf(t.getReadStatus()));
  88. sql = sql.replace("#{read_time}",String.valueOf(t.getReadTime()));
  89. sql = sql.replace("#{create_date}",String.valueOf(t.getCreateDate()));
  90. sql = sql.replace("#{UUID}",UUID.randomUUID().toString());
  91. return sql;
  92. }
  93. /**
  94. * 执行JAVA增强
  95. */
  96. private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
  97. if(StringUtil.isNotEmpty(cgJavaValue)){
  98. Object obj = null;
  99. try {
  100. if("class".equals(cgJavaType)){
  101. //因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
  102. obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
  103. }else if("spring".equals(cgJavaType)){
  104. obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
  105. }
  106. if(obj instanceof CgformEnhanceJavaInter){
  107. CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
  108. javaInter.execute("t_bus_sys_msg_detail",data);
  109. }
  110. } catch (Exception e) {
  111. e.printStackTrace();
  112. throw new Exception("执行JAVA增强出现异常!");
  113. }
  114. }
  115. }
  116. }