| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- package cn.com.lzt.userchangeslog.service.impl;
- import cn.com.lzt.userchangeslog.service.UserChangesLogServiceI;
- import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
- import cn.com.lzt.userchangeslog.entity.UserChangesLogEntity;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.UUID;
- import java.io.Serializable;
- import org.jeecgframework.core.util.ApplicationContextUtil;
- import org.jeecgframework.core.util.MyClassLoader;
- import org.jeecgframework.core.util.StringUtil;
- import org.jeecgframework.web.cgform.enhance.CgformEnhanceJavaInter;
- @Service("userChangesLogService")
- @Transactional
- public class UserChangesLogServiceImpl extends CommonServiceImpl implements UserChangesLogServiceI {
-
- public void delete(UserChangesLogEntity entity) throws Exception{
- super.delete(entity);
- //执行删除操作增强业务
- this.doDelBus(entity);
- }
-
- public Serializable save(UserChangesLogEntity entity) throws Exception{
- Serializable t = super.save(entity);
- //执行新增操作增强业务
- this.doAddBus(entity);
- return t;
- }
-
- public void saveOrUpdate(UserChangesLogEntity entity) throws Exception{
- super.saveOrUpdate(entity);
- //执行更新操作增强业务
- this.doUpdateBus(entity);
- }
-
- /**
- * 新增操作增强业务
- * @param t
- * @return
- */
- private void doAddBus(UserChangesLogEntity t) throws Exception{
- //-----------------sql增强 start----------------------------
- //-----------------sql增强 end------------------------------
-
- //-----------------java增强 start---------------------------
- //-----------------java增强 end-----------------------------
- }
- /**
- * 更新操作增强业务
- * @param t
- * @return
- */
- private void doUpdateBus(UserChangesLogEntity t) throws Exception{
- //-----------------sql增强 start----------------------------
- //-----------------sql增强 end------------------------------
-
- //-----------------java增强 start---------------------------
- //-----------------java增强 end-----------------------------
- }
- /**
- * 删除操作增强业务
- * @param id
- * @return
- */
- private void doDelBus(UserChangesLogEntity t) throws Exception{
- //-----------------sql增强 start----------------------------
- //-----------------sql增强 end------------------------------
-
- //-----------------java增强 start---------------------------
- //-----------------java增强 end-----------------------------
- }
-
- private Map<String,Object> populationMap(UserChangesLogEntity t){
- Map<String,Object> map = new HashMap<String,Object>();
- map.put("id", t.getId());
- map.put("change_time", t.getChangeTime());
- map.put("user_code", t.getUserCode());
- map.put("user_name", t.getUserName());
- map.put("belong_unitid", t.getBelongUnitid());
- map.put("in_unitid", t.getInUnitid());
- map.put("change_type", t.getChangeType());
- map.put("applicant", t.getApplicant());
- map.put("pay_remind_status", t.getPayRemindStatus());
- map.put("pay_unit", t.getPayUnit());
- return map;
- }
-
- /**
- * 替换sql中的变量
- * @param sql
- * @param t
- * @return
- */
- public String replaceVal(String sql,UserChangesLogEntity t){
- sql = sql.replace("#{id}",String.valueOf(t.getId()));
- sql = sql.replace("#{change_time}",String.valueOf(t.getChangeTime()));
- sql = sql.replace("#{user_code}",String.valueOf(t.getUserCode()));
- sql = sql.replace("#{user_name}",String.valueOf(t.getUserName()));
- sql = sql.replace("#{belong_unitid}",String.valueOf(t.getBelongUnitid()));
- sql = sql.replace("#{in_unitid}",String.valueOf(t.getInUnitid()));
- sql = sql.replace("#{change_type}",String.valueOf(t.getChangeType()));
- sql = sql.replace("#{applicant}",String.valueOf(t.getApplicant()));
- sql = sql.replace("#{pay_remind_status}",String.valueOf(t.getPayRemindStatus()));
- sql = sql.replace("#{pay_unit}",String.valueOf(t.getPayUnit()));
- sql = sql.replace("#{UUID}",UUID.randomUUID().toString());
- return sql;
- }
-
- /**
- * 执行JAVA增强
- */
- private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
- if(StringUtil.isNotEmpty(cgJavaValue)){
- Object obj = null;
- try {
- if("class".equals(cgJavaType)){
- //因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
- obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
- }else if("spring".equals(cgJavaType)){
- obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
- }
- if(obj instanceof CgformEnhanceJavaInter){
- CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
- javaInter.execute("t_bus_user_changes_log",data);
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw new Exception("执行JAVA增强出现异常!");
- }
- }
- }
- }
|