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

net.mingsoft.mdiy.action.web.ConfigAction Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2012-present 铭软科技(mingsoft.net)
 * 本软件及相关文档文件(以下简称“软件”)的版权归 铭软科技 所有
 * 遵循 铭软科技《服务协议》中的《保密条款》
 */




package net.mingsoft.mdiy.action.web;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import net.mingsoft.base.entity.ResultData;
import net.mingsoft.mdiy.action.BaseAction;
import net.mingsoft.mdiy.biz.IModelBiz;
import net.mingsoft.mdiy.constant.e.ModelCustomTypeEnum;
import net.mingsoft.mdiy.entity.ConfigEntity;
import net.mingsoft.mdiy.entity.ModelEntity;
import net.mingsoft.mdiy.util.ConfigUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 自定义配置表管理控制层
 * @author 铭飞开发团队
 * @version
 * 版本号:1
* 创建日期:2017-8-12 15:58:29
* 历史修订:
*/ @Api(tags={"前端-自定义模块接口"}) @Controller("webMdiyConfig") @RequestMapping("/mdiy/config") public class ConfigAction extends BaseAction { /** * 注入自定义模型业务层 */ @Autowired private IModelBiz modelBiz; /** * 获取配置中的key指定value值 * @param configName 配置名称 * @param key 配置的key值 * @param response * @param request * @return */ @ApiOperation(value = "获取配置中的key指定value值") @ApiImplicitParams({ @ApiImplicitParam(name = "configName", value = "配置名称", required = true,paramType="query"), @ApiImplicitParam(name = "key", value = "配置key", required = true,paramType="query"), }) @GetMapping("/get") @ResponseBody public ResultData get(String configName,String key, HttpServletResponse response, HttpServletRequest request){ if (StringUtils.isEmpty(configName) || StringUtils.isEmpty(key)) { return ResultData.build().error(getResString("err.empty",getResString("config.name"))); } LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); lqw.eq(ModelEntity::getModelName,configName) .eq(ModelEntity::getModelCustomType, ModelCustomTypeEnum.CONFIG.getLabel()); ModelEntity modelEntity = modelBiz.getOne(lqw); if(modelEntity!=null) { //判断是否允许外部获取配置信息 if(Boolean.parseBoolean(JSONUtil.toBean(modelEntity.getModelJson(), Map.class).get("isWebSubmit").toString())) { return ResultData.build().success(ConfigUtil.getString(configName,key)); } } return ResultData.build().error("此配置数据不允许外部获取"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy