Search in sources :

Example 6 with ScriptModel

use of io.jpom.model.script.ScriptModel in project Jpom by dromara.

the class ScriptController method unbind.

/**
 * 释放脚本关联的节点
 *
 * @param id 脚本ID
 * @return json
 */
@RequestMapping(value = "unbind.json", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DEL)
public String unbind(@ValidatorItem String id) {
    ScriptModel update = new ScriptModel();
    update.setId(id);
    update.setNodeIds(StrUtil.EMPTY);
    scriptServer.updateById(update, getRequest());
    return JsonMessage.getString(200, "解绑成功");
}
Also used : ScriptModel(io.jpom.model.script.ScriptModel) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature) ClassFeature(io.jpom.permission.ClassFeature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with ScriptModel

use of io.jpom.model.script.ScriptModel in project Jpom by dromara.

the class ScriptController method del.

@RequestMapping(value = "del.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@Feature(method = MethodFeature.DEL)
public String del(String id) {
    HttpServletRequest request = getRequest();
    ScriptModel server = scriptServer.getByKey(id, request);
    if (server != null) {
        File file = server.scriptPath();
        boolean del = FileUtil.del(file);
        Assert.state(del, "清理脚本文件失败");
        // 删除节点中的脚本
        String nodeIds = server.getNodeIds();
        List<String> delNode = StrUtil.splitTrim(nodeIds, StrUtil.COMMA);
        this.syncDelNodeScript(server, getUser(), delNode);
        scriptServer.delByKey(id, request);
        // 
        scriptExecuteLogServer.delByWorkspace(request, entity -> entity.set("scriptId", id));
    }
    return JsonMessage.getString(200, "删除成功");
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ScriptModel(io.jpom.model.script.ScriptModel) File(java.io.File) Feature(io.jpom.permission.Feature) MethodFeature(io.jpom.permission.MethodFeature) ClassFeature(io.jpom.permission.ClassFeature) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ScriptModel (io.jpom.model.script.ScriptModel)7 ClassFeature (io.jpom.permission.ClassFeature)5 Feature (io.jpom.permission.Feature)5 MethodFeature (io.jpom.permission.MethodFeature)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 File (java.io.File)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 JSONObject (com.alibaba.fastjson.JSONObject)1 UserModel (io.jpom.model.data.UserModel)1 ScriptExecuteLogModel (io.jpom.model.script.ScriptExecuteLogModel)1 ScriptExecuteLogServer (io.jpom.service.script.ScriptExecuteLogServer)1 ScriptServer (io.jpom.service.script.ScriptServer)1