{
  "properties": {},
  "id": "9db9c4ea-fe92-5fc8-9557-4af2b2bf215d",
  "script": null,
  "groupId": "25a971ba-6a80-5bb8-88f2-a0d53c183824",
  "name": "删除",
  "createTime": 1778891835481,
  "updateTime": null,
  "lock": null,
  "createBy": null,
  "updateBy": null,
  "path": "/delete",
  "method": "POST",
  "parameters": [],
  "options": [],
  "requestBody": null,
  "headers": [],
  "paths": [],
  "responseBody": null,
  "description": null,
  "requestBodyDefinition": null,
  "responseBodyDefinition": null
}
================================
import 'com.itam.util.UuidUtil';

var id = body.id;
var operatorName = body.operator_name != null ? body.operator_name : 'system';
var operatorId = body.operator_id;
assert body.id != null : 400, 'id不能为空';

var old = db.selectOne("""
    select name from itam_licenses where id = #{id} and deleted = 0
""");

var result = db.update("""
    update itam_licenses set deleted = 1, update_time = now() where id = #{id}
""");

if (old != null) {
    var changeId = UuidUtil.v7();
    db.insert("""
    insert into itam_change_record (id, asset_type, asset_id, asset_name, change_type, field_name, old_value, new_value, operator_id, operator_name, create_time)
    values (#{changeId}, 'license', #{id}, #{old.name}, 'delete', null, null, null, #{operatorId}, #{operatorName}, now())
    """);
}

return result;
