zouxuan %!s(int64=3) %!d(string=hai) anos
pai
achega
d94a361f00

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysTenantConfigDao.java

@@ -0,0 +1,9 @@
+package com.ym.mec.biz.dal.dao;
+
+
+import com.ym.mec.biz.dal.entity.SysTenantConfig;
+import com.ym.mec.common.dal.BaseDAO;
+
+public interface SysTenantConfigDao extends BaseDAO<Integer, SysTenantConfig> {
+
+}

+ 72 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysTenantConfig.java

@@ -0,0 +1,72 @@
+package com.ym.mec.biz.dal.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * zx
+ * @author 
+ */
+public class SysTenantConfig implements Serializable {
+    private Integer id;
+
+    private Integer sysConfigId;
+
+    private Integer tenantId;
+
+    private String paramValue;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    private static final long serialVersionUID = 1L;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getSysConfigId() {
+        return sysConfigId;
+    }
+
+    public void setSysConfigId(Integer sysConfigId) {
+        this.sysConfigId = sysConfigId;
+    }
+
+    public Integer getTenantId() {
+        return tenantId;
+    }
+
+    public void setTenantId(Integer tenantId) {
+        this.tenantId = tenantId;
+    }
+
+    public String getParamValue() {
+        return paramValue;
+    }
+
+    public void setParamValue(String paramValue) {
+        this.paramValue = paramValue;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+}

+ 7 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysTenantConfigService.java

@@ -0,0 +1,7 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.SysTenantConfig;
+import com.ym.mec.common.service.BaseService;
+
+public interface SysTenantConfigService extends BaseService<Integer, SysTenantConfig> {
+}

+ 21 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysTenantConfigServiceImpl.java

@@ -0,0 +1,21 @@
+package com.ym.mec.biz.service.impl;
+
+import com.ym.mec.biz.dal.dao.SysTenantConfigDao;
+import com.ym.mec.biz.dal.entity.SysTenantConfig;
+import com.ym.mec.biz.service.SysTenantConfigService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SysTenantConfigServiceImpl extends BaseServiceImpl<Integer, SysTenantConfig>  implements SysTenantConfigService {
+	
+	@Autowired
+	private SysTenantConfigDao sysTenantConfigDao;
+
+	@Override
+	public BaseDAO<Integer, SysTenantConfig> getDAO() {
+		return sysTenantConfigDao;
+	}
+}

+ 108 - 0
mec-biz/src/main/resources/config/mybatis/SysTenantConfigMapper.xml

@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ym.mec.biz.dal.dao.SysTenantConfigDao">
+  <resultMap id="SysTenantConfig" type="com.ym.mec.biz.dal.entity.SysTenantConfig">
+    <id column="id_" jdbcType="INTEGER" property="id" />
+    <result column="sys_config_id_" jdbcType="INTEGER" property="sysConfigId" />
+    <result column="tenant_id_" jdbcType="INTEGER" property="tenantId" />
+    <result column="param_value_" jdbcType="VARCHAR" property="paramValue" />
+    <result column="create_time_" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    id_, sys_config_id_, tenant_id_, param_value_, create_time_, update_time_
+  </sql>
+  <select id="get" parameterType="java.lang.Integer" resultMap="SysTenantConfig">
+    select 
+    <include refid="Base_Column_List" />
+    from sys_tenant_config
+    where id_ = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="delete" parameterType="java.lang.Integer">
+    delete from sys_tenant_config
+    where id_ = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.SysTenantConfig" useGeneratedKeys="true">
+    insert into sys_tenant_config (sys_config_id_, tenant_id_, param_value_,
+      create_time_, update_time_)
+    values (#{sysConfigId,jdbcType=INTEGER}, #{tenantId,jdbcType=INTEGER}, #{paramValue,jdbcType=VARCHAR},
+      #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.SysTenantConfig" useGeneratedKeys="true">
+    insert into sys_tenant_config
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="sysConfigId != null">
+        sys_config_id_,
+      </if>
+      <if test="tenantId != null">
+        tenant_id_,
+      </if>
+      <if test="paramValue != null">
+        param_value_,
+      </if>
+      <if test="createTime != null">
+        create_time_,
+      </if>
+      <if test="updateTime != null">
+        update_time_,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="sysConfigId != null">
+        #{sysConfigId,jdbcType=INTEGER},
+      </if>
+      <if test="tenantId != null">
+        #{tenantId,jdbcType=INTEGER},
+      </if>
+      <if test="paramValue != null">
+        #{paramValue,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <update id="update" parameterType="com.ym.mec.biz.dal.entity.SysTenantConfig">
+    update sys_tenant_config
+    <set>
+      <if test="sysConfigId != null">
+        sys_config_id_ = #{sysConfigId,jdbcType=INTEGER},
+      </if>
+      <if test="tenantId != null">
+        tenant_id_ = #{tenantId,jdbcType=INTEGER},
+      </if>
+      <if test="paramValue != null">
+        param_value_ = #{paramValue,jdbcType=VARCHAR},
+      </if>
+      <if test="createTime != null">
+        create_time_ = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        update_time_ = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id_ = #{id,jdbcType=INTEGER}
+  </update>
+
+  <!-- 分页查询 -->
+  <select id="queryPage" resultMap="SysTenantConfig" parameterType="map">
+    SELECT * FROM sys_config ORDER BY id_
+    <include refid="global.limit" />
+  </select>
+
+  <!-- 查询当前表的总记录数 -->
+  <select id="queryCount" resultType="int">
+    SELECT COUNT(*) FROM sys_config
+  </select>
+
+  <select id="findAll" resultMap="SysTenantConfig">
+    SELECT * FROM sys_config where 1=1
+    <if test="group != null">
+      and group_ = #{group}
+    </if>
+    ORDER BY id_
+  </select>
+</mapper>

+ 94 - 0
mec-web/src/main/java/com/ym/mec/web/controller/SysTenantConfigController.java

@@ -0,0 +1,94 @@
+package com.ym.mec.web.controller;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.entity.SysConfig;
+import com.ym.mec.biz.service.SysConfigService;
+import com.ym.mec.common.controller.BaseController;
+import com.yonge.log.model.AuditLogAnnotation;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/** 
+ * 系统配置控制层
+ */
+@RestController
+@Api(tags = "系统参数设置")
+@RequestMapping(value = "sysConfig")
+public class SysTenantConfigController extends BaseController {
+
+	@Autowired
+	private SysConfigService sysConfigService;
+	@Autowired
+	private SysUserFeignService sysUserFeignService;
+
+	@ApiOperation(value = "参数列表")
+	@GetMapping(value = "list")
+    @PreAuthorize("@pcs.hasPermissions('sysConfig/list')")
+	public Object configList(String group) {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		Map<String,Object> params = new HashMap<String, Object>();
+		params.put("group", group);
+		params.put("tenantId", sysUser.getTenantId());
+		List<SysConfig> configs = sysConfigService.findAll(params);
+		return succeed(configs);
+	}
+
+	@ApiOperation(value = "修改参数")
+	@PostMapping(value = "update")
+    @PreAuthorize("@pcs.hasPermissions('sysConfig/update')")
+	@AuditLogAnnotation(operateName = "修改参数")
+	public Object update(SysConfig config) {
+		config.setModifyOn(new Date());
+		sysConfigService.update(config);
+		return succeed();
+	}
+
+	@ApiOperation(value = "新增参数")
+	@PostMapping(value = "add")
+    @PreAuthorize("@pcs.hasPermissions('sysConfig/add')")
+	public Object addConfig(SysConfig config) {
+		if (config == null)
+			return failed("参数无效");
+		if (StringUtils.isBlank(config.getParamName())) {
+			return failed("参数名称不能为空");
+		}
+		if (StringUtils.isBlank(config.getParanValue())) {
+			return failed("参数值不能为空");
+		}
+		config.setCreateOn(new Date());
+		config.setModifyOn(new Date());
+		return sysConfigService.insert(config) > 0 ? succeed() : failed("添加失败");
+	}
+
+	@ApiOperation(value = "查询参数")
+	@GetMapping(value = "get")
+    @PreAuthorize("@pcs.hasPermissions('sysConfig/get')")
+	public Object getConfig(Long id) {
+		if (id == null || id <= 0)
+			return failed("请检查输入的ID");
+		return succeed(sysConfigService.get(id));
+	}
+
+	@ApiOperation(value = "查询参数")
+	@GetMapping(value = "queryByParamName")
+    @PreAuthorize("@pcs.hasPermissions('sysConfig/queryByParamName')")
+	public Object queryByParamName(String paramName) {
+		if(StringUtils.isBlank(paramName)){
+			return failed("参数不能为空");
+		}
+		return succeed(sysConfigService.findByParamName(paramName));
+	}
+}