package cc.smtweb.system.bpm.web.sys.user.user;

import cc.smtweb.framework.core.annotation.SwBody;
import cc.smtweb.framework.core.annotation.SwService;
import cc.smtweb.framework.core.common.R;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.mvc.service.AbstractHandler;
import cc.smtweb.framework.core.session.UserSession;
import cc.smtweb.system.bpm.web.engine.dynPage.DynPageService;

/**
 * Created by 1 at 2022-07-28 15:24:49
 * 页面【[用户列表]的服务类
 */
@SwService
public class UserService extends DynPageService {
    public final static String TYPE_CUST = "cust";

    @Override
    protected AbstractHandler createHandler(String type) {
        switch (type) {
            case TYPE_SAVE:
                return new UserHandler.UserSaveHandler();
            case TYPE_DEL:
                return new UserHandler.UserDelHandler();
            case TYPE_LOAD:
                return new UserHandler.UserLoadHandler();
            case TYPE_CUST:
                return new UserHandler.UserCustHandler();
        }
        return super.createHandler(type);
    }

    /**
     * @Author yaoq
     * @Date 2022/7/21 15:50
     * @Params
     * @Return cc.smtweb.framework.core.common.R
     * @Description 明细批量新增
     */
    public R batchDelParty(@SwBody SwMap params, UserSession us) {
        return pageHandler(params, us, TYPE_CUST, handler -> ((UserHandler.UserCustHandler) handler).batchDelParty());
    }


    /**
     * @Author yaoq
     * @Date 2022/7/21 15:50
     * @Params
     * @Return cc.smtweb.framework.core.common.R
     * @Description 删除全部
     */
    public R delAll(@SwBody SwMap params, UserSession us) {
        return pageHandler(params, us, TYPE_CUST, handler -> ((UserHandler.UserCustHandler) handler).delAll());
    }


    /**
     * @Author yaoq
     * @Date 2022/8/15 16:48
     * @Params
     * @Return cc.smtweb.framework.core.common.R
     * @Description 重置密码
     */
    public R resetPwd(@SwBody SwMap params, UserSession us) {
        return pageHandler(params, us, TYPE_CUST, handler -> ((UserHandler.UserCustHandler) handler).resetPwd());
    }

}
