github.com/inklabsfoundation/inkchain@v0.17.1-0.20181025012015-c3cef8062f19/examples/creative/scripts/func_artist.sh (about)

     1  #!/usr/bin/env bash
     2  #
     3  #Copyright Ziggurat Corp. 2017 All Rights Reserved.
     4  #
     5  #SPDX-License-Identifier: Apache-2.0
     6  #
     7  
     8  # Detecting whether can import the header file to render colorful cli output
     9  if [ -f ./func_init.sh ]; then
    10   source ./func_init.sh
    11  elif [ -f scripts/func_init.sh ]; then
    12   source scripts/func_init.sh
    13  else
    14   alias echo_r="echo"
    15   alias echo_g="echo"
    16   alias echo_b="echo"
    17  fi
    18  
    19  # addArtist  $USER_TOKEN_01 "hanmeimei" "女作家" "韩梅梅,女,金牛座,1981年出生于云南。毕业于北京电影学院导演系,畅销书作家。"
    20  # addArtist  $USER_TOKEN_02 "lilei" "程序员" "李雷,男,狮子座,1980年出生于山东。毕业于蓝翔,屌丝程序员。"
    21  addArtist(){
    22      tag="add artist"
    23      echo_b "Attempting to $tag"
    24      sleep 3
    25      peer chaincode invoke -C $CHANNEL_NAME -n creative --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["AddArtist","'$2'","'$3'","'$4'"]}' -i $SERVICE_CHARGE -z $1 >&log.txt
    26      res=$?
    27      cat log.txt
    28      verifyResult $res "$tag: Dainel Failed."
    29      echo_g "===================== creative  $tag successfully======================= "
    30      echo
    31  }
    32  
    33  # deleteArtist $USER_TOKEN_01 "hanmeimei"
    34  # deleteArtist $USER_TOKEN_02 "lilei"
    35  deleteArtist () {
    36      tag="delete artist"
    37      echo_b "Attempting to $tag"
    38      sleep 3
    39      peer chaincode invoke -C $CHANNEL_NAME -n creative --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["DeleteArtist","'$2'"]}' -i $SERVICE_CHARGE -z $1 >&log.txt
    40      res=$?
    41      cat log.txt
    42      verifyResult $res "$tag: Dainel Failed."
    43      echo_g "===================== creative  $tag successfully======================= "
    44      echo
    45  }
    46  
    47  # TODO 可1次修改多值
    48  # modifyArtist $USER_TOKEN_01 Name "女作家&女演员"
    49  # modifyArtist $USER_TOKEN_01 Desc "韩梅梅,女,金牛座,1981年出生于云南。毕业于北京电影学院导演系,畅销书作家。TO DO +"
    50  # modifyArtist $USER_TOKEN_02 Name "程序员&架构师"
    51  # modifyArtist $USER_TOKEN_02 Desc "李雷,男,狮子座,1980年出生于山东。毕业于蓝翔,屌丝程序员。TO DO +"
    52  modifyArtist () {
    53      tag="modify artist"
    54      echo_b "Attempting to $tag"
    55      sleep 3
    56      peer chaincode invoke -C $CHANNEL_NAME -n creative --tls $CORE_PEER_TLS_ENABLED --cafile $ORDERER_CA -c '{"Args":["ModifyArtist","'$2'","'$3'"]}' -i $SERVICE_CHARGE -z $1 >&log.txt
    57      res=$?
    58      cat log.txt
    59      verifyResult $res "$tag: Dainel Failed."
    60      echo_g "===================== creative  $tag successfully======================= "
    61      echo
    62  }
    63  
    64  # queryArtist "hanmeimei"
    65  # queryArtist "lilei"
    66  queryArtist () {
    67      tag="query artist"
    68      echo_b "Attempting to $tag"
    69      sleep 3
    70      peer chaincode query -C $CHANNEL_NAME -n creative -c '{"Args":["QueryArtist","'$1'"]}' >log.txt
    71      res=$?
    72      cat log.txt
    73      verifyResult $res "$tag: Dainel Failed."
    74      echo_g "===================== creative  $tag successfully======================= "
    75      echo
    76  }
    77  
    78  # listOfArtist
    79  # listOfArtist
    80  listOfArtist () {
    81      tag="list of artist"
    82      echo_b "Attempting to $tag"
    83      sleep 3
    84      peer chaincode query -C $CHANNEL_NAME -n creative -c '{"Args":["ListOfArtist"]}' >log.txt
    85      res=$?
    86      cat log.txt
    87      verifyResult $res "$tag: Dainel Failed."
    88      echo_g "===================== creative  $tag successfully======================= "
    89      echo
    90  }