ソースを参照

保存修改时,对createTime和updateTime进行更新

chenyongxing 7 年 前
コミット
b624be51db

+ 1 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wlyy/WlyyContants.java

@ -52,6 +52,7 @@ public class WlyyContants {
        public static final String message_fail_signCode_is_null="signCode is null";
        public static final String message_fail_signCode_is_null="signCode is null";
        public static final String message_fail_kpiCode_is_null="kpiCode is null";
        public static final String message_fail_kpiCode_is_null="kpiCode is null";
        public static final String message_fail_agreementCode_is_null="agreementCode is null";
        public static final String message_fail_agreementCode_is_null="agreementCode is null";
        public static final String message_fail_agreement_is_null="agreement is null";
        public static final String message_success_update="agreementKpi update success";
        public static final String message_success_update="agreementKpi update success";
        public static final String message_success_delete="agreementKpi delete success";
        public static final String message_success_delete="agreementKpi delete success";

+ 1 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/wx/WxContants.java

@ -126,5 +126,6 @@ public class WxContants {
        public static final String message_fail_code_exist="code exist";
        public static final String message_fail_code_exist="code exist";
        public static final String message_fail_status_is_null="status is null";
        public static final String message_fail_status_is_null="status is null";
        public static final String message_fail_title_is_null="title is null";
        public static final String message_fail_title_is_null="title is null";
        public static final String message_fail_wxGraphicMessage_is_no_exist="wxGraphicMessage is no exist";
    }
    }
}
}

+ 1 - 1
svr/svr-base/src/main/java/com/yihu/jw/wx/controller/WxGraphicMessageController.java

@ -50,7 +50,7 @@ public class WxGraphicMessageController extends EnvelopRestController {
            @RequestBody String jsonData) {
            @RequestBody String jsonData) {
        try {
        try {
            WxGraphicMessage WxGraphicMessage = toEntity(jsonData, WxGraphicMessage.class);
            WxGraphicMessage WxGraphicMessage = toEntity(jsonData, WxGraphicMessage.class);
            return Envelop.getSuccess(WxContants.WxGraphicMessage.message_success_update, wxGraphicMessageService.updateWxchat(WxGraphicMessage));
            return Envelop.getSuccess(WxContants.WxGraphicMessage.message_success_update, wxGraphicMessageService.updateWxGraphicMessage(WxGraphicMessage));
        } catch (ApiException e) {
        } catch (ApiException e) {
            return Envelop.getError(e.getMessage(), e.getErrorCode());
            return Envelop.getError(e.getMessage(), e.getErrorCode());
        }
        }

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WechatDao.java

@ -19,4 +19,8 @@ public interface WechatDao extends PagingAndSortingRepository<WxWechat, Long>, J
    @Query("from WxWechat w where w.code =?1 and w.status!=-1")
    @Query("from WxWechat w where w.code =?1 and w.status!=-1")
    WxWechat findByCode(String code);
    WxWechat findByCode(String code);
    @Query("from WxWechat w where w.id = ?1 and w.status!=-1")
    WxWechat findById(Long id);
}
}

+ 3 - 3
svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxGraphicMessageDao.java

@ -17,9 +17,9 @@ public interface WxGraphicMessageDao extends PagingAndSortingRepository<WxGraphi
    @Query("from WxWechat w where w.appId = ?1 and w.code!= ?2 and w.status!=-1")
    @Query("from WxWechat w where w.appId = ?1 and w.code!= ?2 and w.status!=-1")
    WxGraphicMessage findByAppIdExcludeCode(String appId, String code);
    WxGraphicMessage findByAppIdExcludeCode(String appId, String code);
    @Query("from WxGraphicMessage w where w.code =?1 and w.status!=-1")
    @Query("from WxGraphicMessage w where w.code =?1 and w.status!=-1")
    WxGraphicMessage findByCode(String code);
    WxGraphicMessage findByCode(String code);
    @Query("from WxGraphicMessage w where w.id =?1 and w.status!=-1")
    WxGraphicMessage findById(Long id);
}
}

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxMenuDao.java

@ -15,6 +15,9 @@ public interface WxMenuDao  extends PagingAndSortingRepository<WxMenu, Long>, Jp
    @Query("from WxMenu m where m.code = ?1 and m.status = 1")
    @Query("from WxMenu m where m.code = ?1 and m.status = 1")
    WxMenu findByCode(String code);
    WxMenu findByCode(String code);
    @Query("from WxMenu m where m.id = ?1 and m.status = 1")
    WxMenu findById(Long id);
    @Query("from WxMenu m where m.wechatCode =?1 and m.status = 1 order  by m.supMenucode ,m.sort")
    @Query("from WxMenu m where m.wechatCode =?1 and m.status = 1 order  by m.supMenucode ,m.sort")
    List<WxMenu> findByWechatCode(String wechatCode);
    List<WxMenu> findByWechatCode(String wechatCode);
@ -39,4 +42,5 @@ public interface WxMenuDao  extends PagingAndSortingRepository<WxMenu, Long>, Jp
    @Query("from WxMenu m where m.wechatCode =?1 and m.status = 1 and m.supMenucode is null order by m.supMenucode ,m.sort")
    @Query("from WxMenu m where m.wechatCode =?1 and m.status = 1 and m.supMenucode is null order by m.supMenucode ,m.sort")
    List<WxMenu> findParentMenuByWechatCode(String wechatCode);
    List<WxMenu> findParentMenuByWechatCode(String wechatCode);
}
}

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/wx/dao/WxTemplateDao.java

@ -12,4 +12,8 @@ public interface WxTemplateDao extends PagingAndSortingRepository<WxTemplate, Lo
    @Query("from WxTemplate w where w.code = ?1 and w.status =1")
    @Query("from WxTemplate w where w.code = ?1 and w.status =1")
    WxTemplate findByCode(String code);
    WxTemplate findByCode(String code);
    @Query("from WxTemplate w where w.id = ?1 and w.status =1")
    WxTemplate findById(Long id);
}
}

+ 19 - 1
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WechatService.java

@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import javax.persistence.Transient;
import java.util.Date;
/**
/**
 * Created by Administrator on 2017/5/20 0020.
 * Created by Administrator on 2017/5/20 0020.
@ -45,6 +46,11 @@ public class WechatService extends BaseJpaService<WxWechat, WechatDao> {
        if (wechatTem != null) {
        if (wechatTem != null) {
            throw new ApiException(WxContants.Wechat.message_fail_appId_exist, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.Wechat.message_fail_appId_exist, CommonContants.common_error_params_code);
        }
        }
        //设置创建时间和修改时间
        Date date = new Date();
        wechat.setCreateTime(date);
        wechat.setUpdateTime(date);
        return wechatDao.save(wechat);
        return wechatDao.save(wechat);
    }
    }
@ -68,9 +74,17 @@ public class WechatService extends BaseJpaService<WxWechat, WechatDao> {
        if (StringUtils.isEmpty(wechat.getAppSecret())) {
        if (StringUtils.isEmpty(wechat.getAppSecret())) {
            throw new ApiException(WxContants.Wechat.message_fail_appSecret_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.Wechat.message_fail_appSecret_is_null, CommonContants.common_error_params_code);
        }
        }
        if (StringUtils.isEmpty(wechat.getId())) {
        Long id = wechat.getId();
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        }
        WxWechat wechat1 = findById(id);
        if(wechat1 == null){
            throw new ApiException(WxContants.Wechat.message_fail_wxWechat_is_no_exist, CommonContants.common_error_params_code);
        }
        //设置修改时间创建时间
        wechat.setCreateTime(wechat1.getCreateTime());
        wechat.setUpdateTime(new Date());
        WxWechat wechatTem = wechatDao.findByAppIdExcludeCode(wechat.getAppId(),wechat.getCode());
        WxWechat wechatTem = wechatDao.findByAppIdExcludeCode(wechat.getAppId(),wechat.getCode());
        if(wechatTem!=null){
        if(wechatTem!=null){
            throw new ApiException(WxContants.Wechat.message_fail_appId_exist, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.Wechat.message_fail_appId_exist, CommonContants.common_error_params_code);
@ -83,6 +97,10 @@ public class WechatService extends BaseJpaService<WxWechat, WechatDao> {
        return wxWechat;
        return wxWechat;
    }
    }
    public WxWechat findById(Long id){
        return wechatDao.findById(id);
    }
    @Transient
    @Transient
    public void deleteWechat(String code) {
    public void deleteWechat(String code) {
        WxWechat wxWechat = wechatDao.findByCode(code);
        WxWechat wxWechat = wechatDao.findByCode(code);

+ 22 - 5
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxGraphicMessageService.java

@ -39,31 +39,48 @@ public class WxGraphicMessageService extends BaseJpaService<WxGraphicMessage, Wx
        if (wxGraphicMessageTem != null) {
        if (wxGraphicMessageTem != null) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_code_exist, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_code_exist, CommonContants.common_error_params_code);
        }
        }
        //设置创建时间和修改时间
        Date date = new Date();
        wxGraphicMessage.setCreateTime(date);
        wxGraphicMessage.setUpdateTime(date);
        return wxGraphicMessageDao.save(wxGraphicMessage);
        return wxGraphicMessageDao.save(wxGraphicMessage);
    }
    }
    @Transient
    @Transient
    public WxGraphicMessage updateWxchat(WxGraphicMessage wxGraphicMessage) {
    public WxGraphicMessage updateWxGraphicMessage(WxGraphicMessage wxGraphicMessage) {
        if (StringUtils.isEmpty(wxGraphicMessage.getCode())) {
        if (StringUtils.isEmpty(wxGraphicMessage.getCode())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_code_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        }
        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
        if (StringUtils.isEmpty(wxGraphicMessage.getStatus())) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_status_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        }
        if (StringUtils.isEmpty(wxGraphicMessage.getId())) {
        Long id = wxGraphicMessage.getId();
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        }
        //根据id查找
        WxGraphicMessage wxGraphicMessage1 = findById(id);
        if(wxGraphicMessage1==null){
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_wxGraphicMessage_is_no_exist, CommonContants.common_error_params_code);
        }
        //设置创建时间和修改时间
        Date date = new Date();
        wxGraphicMessage.setCreateTime(wxGraphicMessage1.getCreateTime());
        wxGraphicMessage.setUpdateTime(date);
        return wxGraphicMessageDao.save(wxGraphicMessage);
        return wxGraphicMessageDao.save(wxGraphicMessage);
    }
    }
    public WxGraphicMessage findByCode(String code) {
    public WxGraphicMessage findByCode(String code) {
        WxGraphicMessage WxGraphicMessage = wxGraphicMessageDao.findByCode(code);
        WxGraphicMessage WxGraphicMessage = wxGraphicMessageDao.findByCode(code);
        if (WxGraphicMessage == null) {
            throw new ApiException(WxContants.WxGraphicMessage.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        return WxGraphicMessage;
        return WxGraphicMessage;
    }
    }
    public WxGraphicMessage findById(Long id) {
      return wxGraphicMessageDao.findById(id);
    }
    @Transient
    @Transient
    public void deleteWxGraphicMessage(String code) {
    public void deleteWxGraphicMessage(String code) {
        WxGraphicMessage WxGraphicMessage = findByCode(code);
        WxGraphicMessage WxGraphicMessage = findByCode(code);

+ 14 - 1
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxMenuService.java

@ -16,6 +16,7 @@ import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.List;
/**
/**
@ -40,6 +41,7 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
     */
     */
    public WxMenu createWxMenu(WxMenu wxMenu) {
    public WxMenu createWxMenu(WxMenu wxMenu) {
        if(canSaveOrUpata(wxMenu)){
        if(canSaveOrUpata(wxMenu)){
            wxMenu.setCreateTime(new Date());
            return wxMenuDao.save(wxMenu);
            return wxMenuDao.save(wxMenu);
        }
        }
        return null;
        return null;
@ -48,9 +50,15 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
    @Transient
    @Transient
    public WxMenu updateWxMenu(WxMenu wxMenu) {
    public WxMenu updateWxMenu(WxMenu wxMenu) {
        if(canSaveOrUpata(wxMenu)){
        if(canSaveOrUpata(wxMenu)){
            if (StringUtils.isEmpty(wxMenu.getId())) {
            Long id = wxMenu.getId();
            if (StringUtils.isEmpty(id)) {
                throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
                throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
            }
            }
            WxMenu wxMenu1 = findById(id);
            if(wxMenu1==null){
                throw new ApiException(WxContants.WxMenu.message_fail_WxMenu_is_no_exist, CommonContants.common_error_params_code);
            }
            wxMenu.setCreateTime(wxMenu1.getCreateTime());
            return wxMenuDao.save(wxMenu);
            return wxMenuDao.save(wxMenu);
        }
        }
        return null;
        return null;
@ -80,6 +88,10 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
        return wxMenuDao.findByCode(code);
        return wxMenuDao.findByCode(code);
    }
    }
    public WxMenu findById(Long id) {
        return wxMenuDao.findById(id);
    }
    /**
    /**
     * 根据wechatCode查找所有菜单
     * 根据wechatCode查找所有菜单
     * @param wechatCode
     * @param wechatCode
@ -307,6 +319,7 @@ public class WxMenuService extends BaseJpaService<WxMenu, WxMenuDao> {
        if(null!=wxMenuTemp){
        if(null!=wxMenuTemp){
            throw new ApiException(WxContants.WxMenu.message_fail_sort_is_repeat, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.WxMenu.message_fail_sort_is_repeat, CommonContants.common_error_params_code);
        }
        }
        wxMenu.setUpdateTime(new Date());
        return true;
        return true;
    }
    }
}
}

+ 17 - 5
svr/svr-base/src/main/java/com/yihu/jw/wx/service/WxTemplateService.java

@ -31,7 +31,6 @@ public class WxTemplateService extends BaseJpaService<WxTemplate, WxTemplateDao>
    @Autowired
    @Autowired
    private WechatService wechatService;
    private WechatService wechatService;
    public WxTemplate createWxTemplate(WxTemplate wxTemplate) {
    public WxTemplate createWxTemplate(WxTemplate wxTemplate) {
        if (StringUtils.isEmpty(wxTemplate.getCode())) {
        if (StringUtils.isEmpty(wxTemplate.getCode())) {
            throw new ApiException(WxContants.WxTemplate.message_fail_code_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.WxTemplate.message_fail_code_is_null, CommonContants.common_error_params_code);
@ -54,6 +53,10 @@ public class WxTemplateService extends BaseJpaService<WxTemplate, WxTemplateDao>
        if(!content.matches("\\{\\{.+\\.DATA\\}\\}")){//content必须还有 "{{.DATA}}"
        if(!content.matches("\\{\\{.+\\.DATA\\}\\}")){//content必须还有 "{{.DATA}}"
            throw new ApiException(WxContants.WxTemplate.message_fail_content_format_is_not_right, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.WxTemplate.message_fail_content_format_is_not_right, CommonContants.common_error_params_code);
        }
        }
        //设置创建时间和修改时间
        Date date = new Date();
        wxTemplate.setCreateTime(date);
        wxTemplate.setUpdateTime(date);
        return wxTemplateDao.save(wxTemplate);
        return wxTemplateDao.save(wxTemplate);
    }
    }
@ -71,9 +74,16 @@ public class WxTemplateService extends BaseJpaService<WxTemplate, WxTemplateDao>
        if (StringUtils.isEmpty(content)) {
        if (StringUtils.isEmpty(content)) {
            throw new ApiException(WxContants.WxTemplate.message_fail_content_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.WxTemplate.message_fail_content_is_null, CommonContants.common_error_params_code);
        }
        }
        if (StringUtils.isEmpty(wxTemplate.getId())) {
        Long id = wxTemplate.getId();
        if (StringUtils.isEmpty(id)) {
            throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.Wechat.message_fail_id_is_null, CommonContants.common_error_params_code);
        }
        }
        WxTemplate wxTemplate1 = findById(id);
        if(wxTemplate1==null){
            throw new ApiException(WxContants.WxTemplate.message_fail_template_is_no_exist, CommonContants.common_error_params_code);
        }
        wxTemplate.setCreateTime(wxTemplate1.getCreateTime());
        wxTemplate.setUpdateTime(new Date());
        if(!content.matches("\\{\\{.+\\.DATA\\}\\}")){//content必须还有 "{{.DATA}}"
        if(!content.matches("\\{\\{.+\\.DATA\\}\\}")){//content必须还有 "{{.DATA}}"
            throw new ApiException(WxContants.WxTemplate.message_fail_content_format_is_not_right, CommonContants.common_error_params_code);
            throw new ApiException(WxContants.WxTemplate.message_fail_content_format_is_not_right, CommonContants.common_error_params_code);
        }
        }
@ -91,9 +101,11 @@ public class WxTemplateService extends BaseJpaService<WxTemplate, WxTemplateDao>
    public WxTemplate findByCode(String code) {
    public WxTemplate findByCode(String code) {
        WxTemplate wxTemplate = wxTemplateDao.findByCode(code);
        WxTemplate wxTemplate = wxTemplateDao.findByCode(code);
        if (wxTemplate == null) {
            throw new ApiException(WxContants.WxTemplate.message_fail_code_no_exist, CommonContants.common_error_params_code);
        }
        return wxTemplate;
    }
    public WxTemplate findById(Long id) {
        WxTemplate wxTemplate = wxTemplateDao.findById(id);
        return wxTemplate;
        return wxTemplate;
    }
    }

+ 1 - 2
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/entity/WlyyAgreementKpi.java

@ -6,7 +6,6 @@ import com.yihu.jw.wlyy.Agreement.entity.base.IdEntity;
import javax.persistence.Column;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Table;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Date;
/**
/**
@ -103,7 +102,7 @@ public class WlyyAgreementKpi extends IdEntity {
        return createTime;
        return createTime;
    }
    }
    public void setCreateTime(Timestamp createTime) {
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
        this.createTime = createTime;
    }
    }

+ 1 - 2
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/entity/WlyyAgreementKpiLog.java

@ -6,7 +6,6 @@ import com.yihu.jw.wlyy.Agreement.entity.base.IdEntity;
import javax.persistence.Column;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Table;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Date;
/**
/**
@ -87,7 +86,7 @@ public class WlyyAgreementKpiLog extends IdEntity {
        return createTime;
        return createTime;
    }
    }
    public void setCreateTime(Timestamp createTime) {
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
        this.createTime = createTime;
    }
    }

+ 4 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/service/WlyyAgreementKpiLogService.java

@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import javax.persistence.Transient;
import java.util.Date;
/**
/**
 * Created by Administrator on 2017/6/1 0001.
 * Created by Administrator on 2017/6/1 0001.
@ -41,6 +42,9 @@ public class WlyyAgreementKpiLogService extends BaseJpaService<WlyyAgreementKpiL
        if (StringUtils.isEmpty(wlyyAgreementKpiLog.getCode())) {
        if (StringUtils.isEmpty(wlyyAgreementKpiLog.getCode())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        }
        //设置创建时间
        Date date = new Date();
        wlyyAgreementKpiLog.setCreateTime(date);
        return wlyyAgreementKpiLogDao.save(wlyyAgreementKpiLog);
        return wlyyAgreementKpiLogDao.save(wlyyAgreementKpiLog);
    }
    }

+ 32 - 0
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/service/WlyyAgreementKpiService.java

@ -5,12 +5,14 @@ import com.yihu.jw.restmodel.common.CommonContants;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.exception.ApiException;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.restmodel.wlyy.WlyyContants;
import com.yihu.jw.wlyy.Agreement.dao.WlyyAgreementKpiDao;
import com.yihu.jw.wlyy.Agreement.dao.WlyyAgreementKpiDao;
import com.yihu.jw.wlyy.Agreement.entity.WlyyAgreement;
import com.yihu.jw.wlyy.Agreement.entity.WlyyAgreementKpi;
import com.yihu.jw.wlyy.Agreement.entity.WlyyAgreementKpi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import javax.persistence.Transient;
import java.util.Date;
/**
/**
 * Created by Administrator on 2017/6/1 0001.
 * Created by Administrator on 2017/6/1 0001.
@ -21,11 +23,23 @@ public class WlyyAgreementKpiService extends BaseJpaService<WlyyAgreementKpi, Wl
    @Autowired
    @Autowired
    private WlyyAgreementKpiDao wlyyAgreementKpiDao;
    private WlyyAgreementKpiDao wlyyAgreementKpiDao;
    @Autowired
    private WlyyAgreementService wlyyAgreementService;
    @Transient
    @Transient
    public WlyyAgreementKpi create(WlyyAgreementKpi wlyyAgreementKpi) {
    public WlyyAgreementKpi create(WlyyAgreementKpi wlyyAgreementKpi) {
        if (StringUtils.isEmpty(wlyyAgreementKpi.getCode())) {
        if (StringUtils.isEmpty(wlyyAgreementKpi.getCode())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        }
        //判断agreement是否存在
        String agreementCode = wlyyAgreementKpi.getAgreementCode();
        if (StringUtils.isEmpty(agreementCode)) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
        }
        WlyyAgreement agreement = wlyyAgreementService.findByCode(agreementCode);
        if(agreement == null){
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_agreement_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpi.getKpiName())) {
        if (StringUtils.isEmpty(wlyyAgreementKpi.getKpiName())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
        }
        }
@ -35,6 +49,10 @@ public class WlyyAgreementKpiService extends BaseJpaService<WlyyAgreementKpi, Wl
        if (StringUtils.isEmpty(wlyyAgreementKpi.getStatus())) {
        if (StringUtils.isEmpty(wlyyAgreementKpi.getStatus())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_status_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        }
        //设置创建时间和修改时间
        Date date = new Date();
        wlyyAgreementKpi.setCreateTime(date);
        wlyyAgreementKpi.setUpdaateTime(date);
        return wlyyAgreementKpiDao.save(wlyyAgreementKpi);
        return wlyyAgreementKpiDao.save(wlyyAgreementKpi);
    }
    }
@ -44,6 +62,15 @@ public class WlyyAgreementKpiService extends BaseJpaService<WlyyAgreementKpi, Wl
        if (StringUtils.isEmpty(code)) {
        if (StringUtils.isEmpty(code)) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_code_is_null, CommonContants.common_error_params_code);
        }
        }
        //判断agreement是否存在
        String agreementCode = wlyyAgreementKpi.getAgreementCode();
        if (StringUtils.isEmpty(agreementCode)) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_agreementCode_is_null, CommonContants.common_error_params_code);
        }
        WlyyAgreement agreement = wlyyAgreementService.findByCode(agreementCode);
        if(agreement == null){
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_agreement_is_null, CommonContants.common_error_params_code);
        }
        if (StringUtils.isEmpty(wlyyAgreementKpi.getKpiName())) {
        if (StringUtils.isEmpty(wlyyAgreementKpi.getKpiName())) {
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.AgreementKpi.message_fail_kpiName_is_null, CommonContants.common_error_params_code);
        }
        }
@ -61,6 +88,11 @@ public class WlyyAgreementKpiService extends BaseJpaService<WlyyAgreementKpi, Wl
        if(wlyyAgreementKpi1==null){
        if(wlyyAgreementKpi1==null){
            throw new ApiException(WlyyContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
        }
        }
        //设置创建时间和修改时间
        Date date = new Date();
        wlyyAgreementKpi.setCreateTime(wlyyAgreementKpi1.getCreateTime());
        wlyyAgreementKpi.setUpdaateTime(date);
        wlyyAgreementKpi1 = wlyyAgreementKpiDao.findCodeExcludeId(code,id);
        wlyyAgreementKpi1 = wlyyAgreementKpiDao.findCodeExcludeId(code,id);
        if(wlyyAgreementKpi1 !=null){
        if(wlyyAgreementKpi1 !=null){
            throw new ApiException(WlyyContants.Agreement.message_fail_code_exist, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.Agreement.message_fail_code_exist, CommonContants.common_error_params_code);

+ 11 - 1
svr/svr-wlyy/src/main/java/com/yihu/jw/wlyy/Agreement/service/WlyyAgreementService.java

@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import javax.persistence.Transient;
import javax.persistence.Transient;
import java.util.Date;
/**
/**
 * Created by Administrator on 2017/6/1 0001.
 * Created by Administrator on 2017/6/1 0001.
@ -35,6 +36,10 @@ public class WlyyAgreementService extends BaseJpaService<WlyyAgreement, WlyyAgre
        if (StringUtils.isEmpty(wlyyAgreement.getStatus())) {
        if (StringUtils.isEmpty(wlyyAgreement.getStatus())) {
            throw new ApiException(WlyyContants.Agreement.message_fail_status_is_null, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.Agreement.message_fail_status_is_null, CommonContants.common_error_params_code);
        }
        }
        //设置创建时间和修改时间
        Date date = new Date();
        wlyyAgreement.setCreateTime(date);
        wlyyAgreement.setUpdateTime(date);
        return wlyyAgreementDao.save(wlyyAgreement);
        return wlyyAgreementDao.save(wlyyAgreement);
    }
    }
@ -61,7 +66,12 @@ public class WlyyAgreementService extends BaseJpaService<WlyyAgreement, WlyyAgre
        if(wlyyAgreement1==null){
        if(wlyyAgreement1==null){
            throw new ApiException(WlyyContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.Agreement.message_fail_wlyyAgreement_is_no_exist, CommonContants.common_error_params_code);
        }
        }
         wlyyAgreement1 = wlyyAgreementDao.findCodeExcludeId(code,id);
        //设置创建时间和修改时间
        Date date = new Date();
        wlyyAgreement.setCreateTime(wlyyAgreement1.getCreateTime());
        wlyyAgreement.setUpdateTime(date);
        wlyyAgreement1 = wlyyAgreementDao.findCodeExcludeId(code,id);
        if(wlyyAgreement1 !=null){
        if(wlyyAgreement1 !=null){
            throw new ApiException(WlyyContants.Agreement.message_fail_code_exist, CommonContants.common_error_params_code);
            throw new ApiException(WlyyContants.Agreement.message_fail_code_exist, CommonContants.common_error_params_code);
        }
        }