package com.jfinal.club._admin.ct;

import com.jfinal.aop.Inject;
import com.jfinal.club.my.doc.UsersDocService;
import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

/**
 * @ClassName DocAdminValidator
 * @Description TODO
 * @Author caolong
 * @Date 2020/3/25 14:36
 */
public class CtAdminValidator extends Validator {

    @Inject
    UsersDocService usersDocService;

    @Override
    protected void validate(Controller c) {
        setShortCircuit(true);
        c.getFile("filenames", usersDocService.getAvatarTempDir(), usersDocService.getAvatarMaxSize());
        validateRequired("userct.ctname", "msg", "词条名称不能为空");
        validateRequired("userct.cttext", "msg", "词条描述不能为空");
    }


    @Override
    protected void handleError(Controller c) {
        c.renderJson();
    }
}
