浏览代码

add:系统参数设置

yonge 5 年之前
父节点
当前提交
95b986bea4

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

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

+ 86 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysConfig.java

@@ -0,0 +1,86 @@
+package com.ym.mec.biz.dal.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(sys_config):
+ */
+public class SysConfig {
+
+	/**  */
+	private Long id;
+	
+	/** 参数名称 */
+	@ApiModelProperty(value = "参数名称", required = true)
+	private String paramName;
+	
+	/** 参数值 */
+	@ApiModelProperty(value = "参数值", required = true)
+	private String paranValue;
+	
+	/** 描述 */
+	@ApiModelProperty(value = "描述", required = true)
+	private String description;
+	
+	/** 创建时间 */
+	private java.util.Date createOn;
+	
+	/** 修改时间 */
+	private java.util.Date modifyOn;
+	
+	public void setId(Long id){
+		this.id = id;
+	}
+	
+	public Long getId(){
+		return this.id;
+	}
+			
+	public void setParamName(String paramName){
+		this.paramName = paramName;
+	}
+	
+	public String getParamName(){
+		return this.paramName;
+	}
+			
+	public void setParanValue(String paranValue){
+		this.paranValue = paranValue;
+	}
+	
+	public String getParanValue(){
+		return this.paranValue;
+	}
+			
+	public void setDescription(String description){
+		this.description = description;
+	}
+	
+	public String getDescription(){
+		return this.description;
+	}
+			
+	public void setCreateOn(java.util.Date createOn){
+		this.createOn = createOn;
+	}
+	
+	public java.util.Date getCreateOn(){
+		return this.createOn;
+	}
+			
+	public void setModifyOn(java.util.Date modifyOn){
+		this.modifyOn = modifyOn;
+	}
+	
+	public java.util.Date getModifyOn(){
+		return this.modifyOn;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysConfigService.java

@@ -0,0 +1,8 @@
+package com.ym.mec.biz.service;
+
+import com.ym.mec.biz.dal.entity.SysConfig;
+import com.ym.mec.common.service.BaseService;
+
+public interface SysConfigService extends BaseService<Long, SysConfig> {
+
+}

+ 23 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysConfigServiceImpl.java

@@ -0,0 +1,23 @@
+package com.ym.mec.biz.service.impl;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.ym.mec.biz.dal.dao.SysConfigDao;
+import com.ym.mec.biz.dal.entity.SysConfig;
+import com.ym.mec.biz.service.SysConfigService;
+import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.service.impl.BaseServiceImpl;
+
+@Service
+public class SysConfigServiceImpl extends BaseServiceImpl<Long, SysConfig>  implements SysConfigService {
+	
+	@Autowired
+	private SysConfigDao sysConfigDao;
+
+	@Override
+	public BaseDAO<Long, SysConfig> getDAO() {
+		return sysConfigDao;
+	}
+	
+}

+ 78 - 0
mec-biz/src/main/resources/config/mybatis/SysConfigMapper.xml

@@ -0,0 +1,78 @@
+<?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.SysConfigDao">
+
+	<resultMap type="com.ym.mec.biz.dal.entity.SysConfig" id="SysConfig">
+		<result column="id" property="id" />
+		<result column="param_name_" property="paramName" />
+		<result column="paran_value_" property="paranValue" />
+		<result column="description_" property="description" />
+		<result column="create_on_" property="createOn" />
+		<result column="modify_on_" property="modifyOn" />
+	</resultMap>
+
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="SysConfig">
+		SELECT * FROM sys_config WHERE id = #{id}
+	</select>
+
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="SysConfig">
+		SELECT * FROM sys_config ORDER BY
+		id
+	</select>
+
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.SysConfig"
+		useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		<!-- <selectKey resultClass="int" keyProperty="id" > SELECT SEQ_WSDEFINITION_ID.nextval 
+			AS ID FROM DUAL </selectKey> -->
+		INSERT INTO sys_config
+		(id,param_name_,paran_value_,description_,create_on_,modify_on_)
+		VALUES(#{id},#{paramName},#{paranValue},#{description},#{createOn},#{modifyOn})
+	</insert>
+
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.ym.mec.biz.dal.entity.SysConfig">
+		UPDATE sys_config
+		<set>
+			<if test="modifyOn != null">
+				modify_on_ = #{modifyOn},
+			</if>
+			<if test="paranValue != null">
+				paran_value_ = #{paranValue},
+			</if>
+			<if test="description != null">
+				description_ = #{description},
+			</if>
+			<if test="id != null">
+				id = #{id},
+			</if>
+			<if test="createOn != null">
+				create_on_ = #{createOn},
+			</if>
+			<if test="paramName != null">
+				param_name_ = #{paramName},
+			</if>
+		</set>
+		WHERE id = #{id}
+	</update>
+
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete">
+		DELETE FROM sys_config WHERE id = #{id}
+	</delete>
+
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="SysConfig" 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>
+</mapper>

+ 0 - 1
mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupController.java

@@ -1,7 +1,6 @@
 package com.ym.mec.web.controller;
 
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 

+ 77 - 0
mec-web/src/main/java/com/ym/mec/web/controller/SysConfigController.java

@@ -0,0 +1,77 @@
+package com.ym.mec.web.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+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 com.ym.mec.biz.dal.entity.SysConfig;
+import com.ym.mec.biz.service.SysConfigService;
+import com.ym.mec.common.controller.BaseController;
+
+/** 
+ * 系统配置控制层
+ */
+@RestController
+@Api(tags = "系统参数设置")
+@RequestMapping(value = "sysConfig")
+public class SysConfigController extends BaseController {
+
+	@Autowired
+	private SysConfigService sysConfigService;
+
+	@ApiOperation(value = "参数列表")
+	@GetMapping(value = "list")
+	public Object configList() {
+		List<SysConfig> configs = sysConfigService.findAll(null);
+		Map<String, Object> map = new HashMap<String, Object>();
+		if (configs != null && configs.size() > 0) {
+			for (SysConfig config : configs) {
+				map.put(config.getParamName(), config.getParanValue());
+			}
+		}
+		return succeed(map);
+	}
+
+	@ApiOperation(value = "修改参数")
+	@PostMapping(value = "update")
+	public Object update(SysConfig config) {
+		config.setModifyOn(new Date());
+		sysConfigService.update(config);
+		return succeed();
+	}
+
+	@ApiOperation(value = "新增参数")
+	@PostMapping(value = "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")
+	public Object getConfig(Long id) {
+		if (id == null || id <= 0)
+			return failed("请检查输入的ID");
+		return succeed(sysConfigService.get(id));
+	}
+}