字典翻译

最近比较烦,电脑坏了。把以前的好东西备份一下。
1.字典翻译

表结构

CREATE TABLE `t_sys_dict` (
  `dict_id` varchar(20) NOT NULL,
  `sys_code` varchar(20) NOT NULL DEFAULT 'xiong' COMMENT '系统代码',
  `dict_code` varchar(50) NOT NULL COMMENT '数据字典键',
  `dict_value` varchar(200) NOT NULL COMMENT '数据字典值',
  `dict_remark` varchar(50) DEFAULT NULL COMMENT '数据字典描述',
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`dict_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='数据字典表';

INSERT INTO `t_sys_dict` VALUES ('10', 'XYC', 'orderStatus', 'WAIT_BUYER_CONFIRM_GOODS', '等待买家确认收货,即:卖家已发货', '2019-04-19 20:38:32');
INSERT INTO `t_sys_dict` VALUES ('11', 'XYC', 'orderStatus', 'TRADE_BUYER_SIGNED', '买家已签收,货到付款专用', '2019-04-19 20:38:32');
INSERT INTO `t_sys_dict` VALUES ('12', 'XYC', 'orderStatus', 'TRADE_FINISHED', '交易成功', '2019-04-19 20:38:32');
INSERT INTO `t_sys_dict` VALUES ('13', 'XYC', 'orderStatus', 'TRADE_CLOSED', '交易关闭', '2019-04-19 20:38:32');
INSERT INTO `t_sys_dict` VALUES ('14', 'XYC', 'orderStatus', 'TRADE_CLOSED_BY_TAOBAO', '交易被淘宝关闭', '2019-04-19 20:38:32');
INSERT INTO `t_sys_dict` VALUES ('7', 'XYC', 'orderStatus', 'TRADE_NO_CREATE_PAY', '没有创建支付宝交易', '2019-04-19 20:38:32');
INSERT INTO `t_sys_dict` VALUES ('8', 'XYC', 'orderStatus', 'WAIT_BUYER_PAY', '等待买家付款', '2019-04-19 20:38:32');
INSERT INTO `t_sys_dict` VALUES ('9', 'XYC', 'orderStatus', 'WAIT_SELLER_SEND_GOODS', '等待卖家发货,即:买家已付款', '2019-04-19 20:38:32');

字典注解类

package com.xyc.cloud.utils;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Dict {
	public abstract String dictCode() default "";
}

需要翻译实体类字段

	/**
	 * 退款对应的订单交易状态。 可选值
	 * TRADE_NO_CREATE_PAY(没有创建支付宝交易) 
	 * WAIT_BUYER_PAY(等待买家付款)
	 * WAIT_SELLER_SEND_GOODS(等待卖家发货,即:买家已付款)
	 * WAIT_BUYER_CONFIRM_GOODS(等待买家确认收货,即:卖家已发货) 
	 * TRADE_BUYER_SIGNED(买家已签收,货到付款专用)
	 * TRADE_FINISHED(交易成功) 
	 * TRADE_CLOSED(交易关闭) 
	 * TRADE_CLOSED_BY_TAOBAO(交易被淘宝关闭)
	 * ALL_WAIT_PAY(包含:WAIT_BUYER_PAY、TRADE_NO_CREATE_PAY)
	 * ALL_CLOSED(包含:TRADE_CLOSED、TRADE_CLOSED_BY_TAOBAO)
	 */
	@Dict(dictCode="orderStatus")
	@ApiModelProperty(value = "退款对应的订单交易状态")
	private String orderStatus;

执行翻译

		List<Map<String, Object>>  map = sysDictService.translateToMapList(list); //list 你的数据库查询结果集

最终结果

元数据翻译数据

2.下面是字典翻译的CRUD 和具体内部转换

mode类

package com.xiong.cloud.bean;

import java.util.Date;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.honghu.cloud.common.utils.mybatis.IModel;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@ApiModel("数据字典表")
public class SysDict implements IModel {

	private static final long serialVersionUID = 1L;

	public String toString() {
		return ReflectionToStringBuilder.toString(this);
	}

	@ApiModelProperty(value = "")
	private String dictId;

	/**
	 * 数据字典键
	 */
	@ApiModelProperty(value = "数据字典键")
	private String dictCode;

	/**
	 * 数据字典值
	 */
	@ApiModelProperty(value = "数据字典值")
	private String dictValue;

	
	/**
	 * 数据字典描述
	 */
	@ApiModelProperty(value = "数据字典描述")
	private String dictRemark;

	@ApiModelProperty(value = "")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
	private Date createTime;

	public String getDictId() {
		return dictId;
	}

	public void setDictId(String dictId) {
		this.dictId = dictId;
	}

	/**
	 * 获取 数据字典键
	 */
	public String getDictCode() {
		return dictCode;
	}

	/**
	 * 设置 数据字典键
	 */
	public void setDictCode(String dictCode) {
		this.dictCode = dictCode;
	}

	/**
	 * 获取 数据字典值
	 */
	public String getDictValue() {
		return dictValue;
	}

	/**
	 * 设置 数据字典值
	 */
	public void setDictValue(String dictValue) {
		this.dictValue = dictValue;
	}

	/**
	 * 获取 数据字典描述
	 */
	public String getDictRemark() {
		return dictRemark;
	}

	/**
	 * 设置 数据字典描述
	 *
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值