@Override
  public Message execute(ActionContext context, C2341_TitleListSelfReqMessage reqMsg) {
    RoleInstance role = this.getCurrentRole(context);
    if (null == role) {
      return null;
    }
    C2341_TitleListSelfRespMessage respMsg = new C2341_TitleListSelfRespMessage();
    Map<Integer, TitleRecord> titleMap = role.getTitleMap();
    if (Util.isEmpty(titleMap)) {
      return respMsg;
    }
    int titleNum = titleMap.size();

    Map<Integer, TitleCategory> categoryMap = GameContext.getTitleApp().getTitleCategoryMap();
    if (Util.isEmpty(categoryMap)) {
      return respMsg;
    }

    int titleNowNum = 0;
    List<TitleCategoryItem> itemList = new ArrayList<TitleCategoryItem>();
    for (TitleCategory c : categoryMap.values()) {
      List<GoodsTitle> titleList = c.getTitleList();
      if (Util.isEmpty(titleList)) {
        continue;
      }
      TitleCategoryItem citem = null;
      for (GoodsTitle title : titleList) {
        int titleId = title.getId();
        TitleRecord record = titleMap.get(titleId);
        if (null == record) {
          continue;
        }
        if (null == citem) {
          citem = new TitleCategoryItem();
          citem.setCategoryName(c.getCategoryName());
        }
        TitleItem titleItem = new TitleItem();
        titleItem.setTitleId(titleId);
        titleItem.setTitleName(title.getName());
        titleItem.setStatus(record.getActivateState());
        citem.getTitles().add(titleItem);
        titleNowNum++;
        // 提前结束循环
        if (titleNowNum >= titleNum) {
          break;
        }
      }
      if (null != citem) {
        itemList.add(citem);
      }
      // 提前结束循环
      if (titleNowNum >= titleNum) {
        break;
      }
    }
    respMsg.setItemList(itemList);
    return respMsg;
  }
 @Override
 public Message execute(ActionContext context, C2349_TitleDetailReqMessage reqMsg) {
   RoleInstance role = this.getCurrentRole(context);
   if (null == role) {
     return null;
   }
   int titleId = reqMsg.getTitleId();
   GoodsTitle title = GameContext.getGoodsApp().getGoodsTemplate(GoodsTitle.class, titleId);
   if (null == title) {
     return new C0002_ErrorRespMessage(reqMsg.getCommandId(), Status.Title_Goods_Null.getTips());
   }
   TitleRecord roleTitle = GameContext.getTitleApp().getRoleTitle(role, titleId);
   C2349_TitleDetailRespMessage respMsg = new C2349_TitleDetailRespMessage();
   TitleWearingItem wearingItem = Converter.getTitleWearingItem(title);
   respMsg.setItem(wearingItem);
   respMsg.setDesc(title.getDesc());
   respMsg.setPay(title.getPay());
   respMsg.setForever(title.isForever() ? (byte) 1 : (byte) 0);
   List<AttriTypeStrValueItem> attrList = new ArrayList<AttriTypeStrValueItem>();
   for (AttriItem ai : title.getAttriItemList()) {
     if (null == ai) {
       continue;
     }
     int value = (int) ai.getValue();
     if (value > 0) {
       AttriTypeStrValueItem item = new AttriTypeStrValueItem();
       item.setType(ai.getAttriTypeValue());
       item.setValue(String.valueOf(value));
       attrList.add(item);
     }
     value = (int) (ai.getPrecValue() * 100);
     if (value > 0) {
       AttriTypeStrValueItem item = new AttriTypeStrValueItem();
       item.setType(ai.getAttriTypeValue());
       item.setValue(value + "%");
       attrList.add(item);
     }
   }
   respMsg.setAttrList(attrList);
   if (null == roleTitle) {
     respMsg.setStatus(TitleStatus.Lack.getType());
     return respMsg;
   }
   respMsg.setStatus(roleTitle.getActivateState());
   respMsg.setExpired(roleTitle.isTimeout() ? (byte) 1 : (byte) 0);
   respMsg.setExpiredTime(roleTitle.getStrDueTime());
   return respMsg;
 }