UEP-添加

时间:2022-12-01 23:13:48
 
添加数据时候自动更新时间,注意添加数据时,要设置最大主键
  时间的工具类:CommonUtil
  人的工具类: ContextUtil       
        ScmCompanyAccount scmCompanyAccount=new ScmCompanyAccount();
//设置最大主键
scmCompanyAccount.setAccountId(new Long(CTCSequenceUtil.genEntitySequenceNo(ScmCompanyAccount.class)));
//设置默认登录人和登录时间
long loginId = ContextUtil.getUserView().getLoginId();
scmCompanyAccount.setCreateOper(loginId);
scmCompanyAccount.setCreateDate(CommonUtil.getDateTime());
dataWrap.setData(scmCompanyAccount);
responseData.setAjaxDataWrap("dataWrap", dataWrap);     保存时更新数据,该判断写在保存方法中
        if (updateList != null && updateList.size()>0){
             for(ScmCompanyAccount entity:updateList){
            //设置默认登录人和登录时间
             long loginId = ContextUtil.getUserView().getLoginId();
             entity.setModifyOper(loginId);
              entity.setModifyDate(CommonUtil.getDateTime());
            }
        JPAUtil.update(updateList);