yuhaitao14 7 years ago
parent
commit
62a6571596

+ 19 - 0
shop/src/main/java/com/zskk/shop/dao/ShopConfigMapper.java

@@ -0,0 +1,19 @@
+/**
+* @版权信息 (@copyright Copyright 2017-XXXX JDJR.COM All Right Reserved);
+* @see
+* @author 于海涛 京东金融【技术研发部-证券及营销平台研发部-营销平台研发部】
+* @version 1.0
+* @date 2018年6月14日
+*/
+
+package com.zskk.shop.dao;
+
+import com.zskk.shop.dao.entry.ShopConfig;
+
+public interface ShopConfigMapper {
+	public void add(ShopConfig shopConfig);
+	
+	public int update(ShopConfig shopConfig);
+	
+	public ShopConfig query(String key);
+}

+ 47 - 0
shop/src/main/java/com/zskk/shop/dao/entry/ShopConfig.java

@@ -0,0 +1,47 @@
+/**
+* @版权信息 (@copyright Copyright 2017-XXXX JDJR.COM All Right Reserved);
+* @see
+* @author 于海涛 京东金融【技术研发部-证券及营销平台研发部-营销平台研发部】
+* @version 1.0
+* @date 2018年6月14日
+*/
+
+package com.zskk.shop.dao.entry;
+
+public class ShopConfig {
+	private Integer id;
+	private String key;
+	private String description;
+	private String value;
+	private Integer ctime;
+	public Integer getId() {
+		return id;
+	}
+	public void setId(Integer id) {
+		this.id = id;
+	}
+	public String getKey() {
+		return key;
+	}
+	public void setKey(String key) {
+		this.key = key;
+	}
+	public String getDescription() {
+		return description;
+	}
+	public void setDescription(String description) {
+		this.description = description;
+	}
+	public String getValue() {
+		return value;
+	}
+	public void setValue(String value) {
+		this.value = value;
+	}
+	public Integer getCtime() {
+		return ctime;
+	}
+	public void setCtime(Integer ctime) {
+		this.ctime = ctime;
+	}
+}

+ 58 - 0
shop/src/main/java/com/zskk/shop/service/ShopConfigService.java

@@ -0,0 +1,58 @@
+/**
+* @版权信息 (@copyright Copyright 2017-XXXX JDJR.COM All Right Reserved);
+* @see
+* @author 于海涛 京东金融【技术研发部-证券及营销平台研发部-营销平台研发部】
+* @version 1.0
+* @date 2018年6月14日
+*/
+
+package com.zskk.shop.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.zskk.shop.dao.ShopConfigMapper;
+import com.zskk.shop.dao.entry.ShopConfig;
+import com.zskk.shop.utils.ToolsUtil;
+
+@Service
+public class ShopConfigService {
+	/**
+	 * KEY 设备描述
+	 */
+	public static final String KEY_EQUIPMENT_INFO = "equipment_info";
+	
+	@Autowired
+	private ShopConfigMapper shopConfigMapper;
+	
+	/**
+	 * 获取KEY
+	 * @param key
+	 * @return
+	 */
+	public String get(String key){
+		ShopConfig config = shopConfigMapper.query(key);
+		return config != null? config.getValue(): null;
+	}
+	
+	/**
+	 * 设置
+	 * @param key
+	 * @param value
+	 * @return
+	 */
+	public void set(String key, String value){
+		ShopConfig config = shopConfigMapper.query(key);
+		if (config != null){
+			config.setValue(value);
+			shopConfigMapper.update(config);
+		}else{
+			config = new ShopConfig();
+			config.setKey(key);
+			config.setValue(value);
+			config.setDescription("");
+			config.setCtime(ToolsUtil.getNow());
+			shopConfigMapper.add(config);
+		}
+	}
+}

+ 17 - 0
shop/src/main/resource/mapper/ShopConfigMapper.xml

@@ -0,0 +1,17 @@
+<?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.zskk.shop.dao.ShopConfigMapper">
+	<insert id="add" parameterType="com.zskk.shop.dao.entry.ShopConfig">
+		insert into shop_config(key, description, value, ctime)
+		values(#{key}, #{description}, #{value}, #{ctime})
+	</insert>
+	<update id="update" parameterMap="com.zskk.shop.dao.entry.ShopConfig">
+		update shop_config description=#{description}, value=#{description}
+		where key=#{key}
+	</update>
+	<select id="queyr" parameterType="com.zskk.shop.dao.entry.ShopConfig">
+		select *
+		from shop_config
+		where key=#{key}
+	</select>
+</mapper>