All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.quhaodian.plug.alidayu.AliDayuPlugController Maven / Gradle / Ivy

There is a newer version: 1.8.10
Show newest version
/*
 * 
 * 
 * 
 */
package com.quhaodian.plug.alidayu;

import com.quhaodian.plug.data.entity.PluginConfig;
import com.quhaodian.plug.data.service.PluginConfigService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.annotation.Resource;

/**
 * Controller - 支付宝(双接口)
 */
@Controller("aliDayuPlugController")
@RequestMapping("/admin/sendcode_plugin/alidayu")
public class AliDayuPlugController {

    @Resource(name = "dayuPlug")
    private DayuPlug dayuPlug;

    @Resource(name = "pluginConfigServiceImpl")
    private PluginConfigService pluginConfigService;

    /**
     * 安装
     */
    @RequestMapping(value = "/install")
    public String install(RedirectAttributes redirectAttributes) {
        if (!dayuPlug.getIsInstalled()) {
            PluginConfig pluginConfig = new PluginConfig();
            pluginConfig.setPluginId(dayuPlug.getId());
            pluginConfig.setIsEnabled(false);
            pluginConfigService.save(pluginConfig);
        }

        return "redirect:/admin/sendcode_plugin/list.htm";
    }

    /**
     * 卸载
     */
    @RequestMapping(value = "/uninstall")
    public String uninstall(RedirectAttributes redirectAttributes) {
        if (dayuPlug.getIsInstalled()) {
            PluginConfig pluginConfig = dayuPlug.getPluginConfig();
            pluginConfigService.deleteById(pluginConfig.getId());
        }
        return "redirect:/admin/sendcode_plugin/list.htm";
    }

    /**
     * 设置
     */
    @RequestMapping(value = "/setting", method = RequestMethod.GET)
    public String setting(ModelMap model) {
        PluginConfig pluginConfig = dayuPlug.getPluginConfig();
        model.addAttribute("pluginConfig", pluginConfig);
        return "/admin/sendcode_plugin/setting_alidayu";
    }

    /**
     * 更新
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public String update(DayuConfig  config) {
        PluginConfig pluginConfig = dayuPlug.getPluginConfig();
        pluginConfig.setAttribute("appkey", config.getAppkey());
        pluginConfig.setAttribute("secret", config.getSecret());
        pluginConfig.setAttribute("product", config.getProduct());
        pluginConfig.setAttribute("signName", config.getSignName());
        pluginConfig.setIsEnabled(config.getEnabled());
        pluginConfig.setSortNum(config.getOrder());

        pluginConfig.setAttribute("register", config.getRegister());
        pluginConfig.setAttribute("login", config.getLogin());
        pluginConfig.setAttribute("binding", config.getBinding());
        pluginConfig.setAttribute("init", config.getInit());
        pluginConfig.setAttribute("reset", config.getReset());
        pluginConfig.setAttribute("changePhone", config.getChangePhone());

        pluginConfigService.update(pluginConfig);

        //addFlashMessage(redirectAttributes, SUCCESS_MESSAGE);
        return "redirect:/admin/sendcode_plugin/list.htm";
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy