1234567891011121314151617181920212223242526272829303132333435363738394041 |
- // Copyright 2019 getensh.com. All rights reserved.
- // Use of this source code is governed by getensh.com.
- package task
- import (
- "adm-task/errors"
- "context"
- "git.getensh.com/common/gopkgsv2/database"
- pb_v1 "adm-task/pb/v1"
- )
- func UpdateOfflineTask(ctx context.Context, req *pb_v1.UpdateOfflineTaskRequest) (reply *pb_v1.UpdateOfflineTaskReply, err error) {
- if req.TaskId == 0 {
- return nil, errors.ServiceError
- }
- reply = &pb_v1.UpdateOfflineTaskReply{}
- if req.Total != 0 {
- err = database.DB().Exec("update t_adm_offline_task set total=? where id=?", req.Total, req.TaskId).Error
- return reply, err
- }
- if req.FinishCount != 0 {
- err = database.DB().Exec("update t_adm_offline_task set finish_count=finish_count+? where id=?", req.FinishCount, req.TaskId).Error
- return reply, err
- }
- if req.IsFinish != 0 {
- err = database.DB().Exec("update t_adm_offline_task set is_finish=? where id=?", req.IsFinish, req.TaskId).Error
- if req.IsFinish == 1 {
- database.DB().Exec("update t_adm_offline_task set finish_count=total where id=?", req.TaskId)
- }
- return reply, err
- }
- return reply, nil
- }
|