Basically you implement requested logic on by leveraging chaincodes, you will have to implement following golang interface:
// Chaincode interface must be implemented by all chaincodes. The fabric runs
// the transactions by calling these functions as specified.
type Chaincode interface {
    // Init is called during Instantiate transaction after the chaincode container
    // has been established for the first time, allowing the chaincode to
    // initialize its internal data
    Init(stub ChaincodeStubInterface) pb.Response
    // Invoke is called to update or query the ledger in a proposal transaction.
    // Updated state variables are not committed to the ledger until the
    // transaction is committed.
    Invoke(stub ChaincodeStubInterface) pb.Response
}
For example something similar to this:
type myStoreChaincode struct {
}
func (cc *myStoreChaincode) Init(stub ChaincodeStubInterface) pb.Response {
    return shim.Success(nil)
}
func (cc *myStoreChaincode) Invoke(stub ChaincodeStubInterface) pb.Response {
    action, params = stub.GetFunctionAndParameters()
    if action == "storeItem" {
        cc.StoreItem(stub, params)
    }
    // Handle here other cases and possible parameters combinations
    return shim.Success(nil)
}
func (cc *myStoreChaincode) StoreItem(stub ChaincodeStubInterface, params []string) {
      // Store item on ledger, where params[0] is a key and params[1] actual value
      stub.PutState(params[0], params[1])
}