独角兽企业重金招聘Python工程师标准>>>
java代码:
package com.mon.web;import java.util.List;import javax.annotation.PostConstruct;import mons.collections.CollectionUtils;import org.apache.log4j.Logger;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import com.its.mmo.MmoException;import com.its.mmo.Status;import com.mon.dao.WechatAccountDao;import com.mon.model.WechatAccount;@Controllerpublic class WechatAccountCtrl{private final static Logger logger=Logger.getLogger(WechatAccountCtrl.class);@Autowiredprivate WechatAccountDao wechatAccountDao; //注入对象private static WechatAccountCtrl wechatAccountCtrl;@PostConstruct //利用PostConstruct注解初始化赋值public void init(){wechatAccountCtrl=this;wechatAccountCtrl.wechatAccountDao=this.wechatAccountDao;}/*** 根据品牌id查询微信账户* @param brandId* @throws MmoException*/public static WechatAccount getWechatAccount(String brandId) throws MmoException {List<WechatAccount> accounts = null;try {accounts = wechatAccountCtrl.wechatAccountDao.queryWxInfo(brandId);} catch (Exception e) {logger.error("根据品牌id查询微信账户错误", e);throw new MmoException(Status.SERVICE_FAIL, "根据品牌id查询微信账户错误", e);}if (CollectionUtils.isEmpty(accounts)) {logger.info("该品牌不存在微信账户");throw new MmoException(Status.SERVICE_FAIL, "该品牌不存在微信账户");}return accounts.get(0);}}