NutzCN Logo
问答 数据库字段为01 使用Record 返回 false true
发布于 2323天前 作者 qq_5a88e4e5 1999 次浏览 复制 上一个帖子 下一个帖子
标签:
package com.yixin.project.xyd.module.entity;

import java.io.Serializable;
import java.sql.Timestamp;

import org.nutz.dao.entity.annotation.*;

/**
 * 产品仓库实体
 *
 * @author @yushun
 */
@Table(ProductStock.TABLE_NAME)
@Comment("产品仓库")
public class ProductStock implements Serializable {

    private static final long serialVersionUID = 1L;

    public static final String TABLE_NAME = "product_stock";

    /**
     * 产品仓库id
     */
    public static final String STOCK_ID = "stock_id";
    /**
     * 产品仓库名称
     */
    public static final String STOCK_NAME = "stock_name";
    /**
     * 产品仓库类型
     */
    public static final String STOCK_TYPE = "stock_type";
    /**
     * 商户id
     */
    public static final String PARTNER_ID = "partner_id";
    /**
     * 创建时间
     */
    public static final String CREATE_TIME = "create_time";
    /**
     * 状态 0 禁用 1启动
     */
    public static final String CONTRACT_STATUS = "contract_status";
    /**
     * 商户名称
     */
    public static final String PARTNER_NAME = "partner_name";

    @Id
    @Comment("产品仓库id")
    @ColDefine(type = ColType.INT, width = 8, notNull = true, unsigned = true)
    private Integer stock_id;

    @Column
    @Comment("产品仓库名称")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String stock_name;

    @Column
    @Comment("产品仓库类型")
    @ColDefine(type = ColType.INT, width = 1)
    private Integer stock_type;

    @Column
    @Comment("商户id")
    @ColDefine(type = ColType.INT, width = 11)
    private Integer partner_id;

    @Column
    @Comment("创建时间")
    @ColDefine(type = ColType.DATETIME)
    private Timestamp create_time;

    @Column
    @Comment("状态 0 禁用 1启动")
    @ColDefine(type = ColType.INT, width = 1)
    private Integer contract_status;

    @Column
    @Comment("商户名称")
    @ColDefine(type = ColType.VARCHAR, width = 60)
    private String partner_name;


    public void setStock_id(Integer stock_id) {
        this.stock_id = stock_id;
    }

    /**
     * 产品仓库id
     */
    public Integer getStock_id() {
        return this.stock_id;
    }

    public void setStock_name(String stock_name) {
        this.stock_name = stock_name;
    }

    /**
     * 产品仓库名称
     */
    public String getStock_name() {
        return this.stock_name;
    }

    public void setStock_type(Integer stock_type) {
        this.stock_type = stock_type;
    }

    /**
     * 产品仓库类型
     */
    public Integer getStock_type() {
        return this.stock_type;
    }

    public void setPartner_id(Integer partner_id) {
        this.partner_id = partner_id;
    }

    /**
     * 商户id
     */
    public Integer getPartner_id() {
        return this.partner_id;
    }

    public void setCreate_time(Timestamp create_time) {
        this.create_time = create_time;
    }

    /**
     * 创建时间
     */
    public Timestamp getCreate_time() {
        return this.create_time;
    }

    public void setContract_status(Integer contract_status) {
        this.contract_status = contract_status;
    }

    /**
     * 状态 0 禁用 1启动
     */
    public Integer getContract_status() {
        return this.contract_status;
    }

    public void setPartner_name(String partner_name) {
        this.partner_name = partner_name;
    }

    /**
     * 商户名称
     */
    public String getPartner_name() {
        return this.partner_name;
    }

}
CREATE TABLE `product_stock` (
  `stock_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '产品仓库id',
  `stock_name` varchar(32) DEFAULT NULL COMMENT '产品仓库名称',
  `stock_type` tinyint(1) DEFAULT NULL COMMENT '产品仓库类型 0 零售仓库 1 批发仓库',
  `partner_id` int(11) DEFAULT '0' COMMENT '商户id',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `contract_status` tinyint(1) DEFAULT NULL COMMENT '状态 0 禁用 1启动',
  `partner_name` varchar(60) DEFAULT NULL COMMENT '商户名称',
  PRIMARY KEY (`stock_id`)
) ENGINE=InnoDB AUTO_INCREMENT=149 DEFAULT CHARSET=utf8 COMMENT='产品仓库'
@At
	@GET
	@RequiresPermissions("product.stock.spu.add")
	@Desc("产品仓库_spu.添加")
	public Object add(@Param("stock_id") Integer stock_id) throws AlertException {
		Record record= dao.fetch(ProductStock.TABLE_NAME, Cnd.where(ProductStock.STOCK_ID,"=",stock_id));

		record.set("stock_type_name",record.getInt(ProductStock.STOCK_TYPE)==0?"零售":"批发");
		System.out.println(Json.toJson(record));
		return record;
	}
{
   "stock_id": 137,
   "stock_name": "测试供应商-批发仓库",
   "stock_type": true,
   "partner_id": 45,
   "create_time": "2018-07-13 09:21:37",
   "contract_status": true,
   "partner_name": "测试供应商",
   "stock_type_name": "批发"
}
1 回复

因为是tinyint

添加回复
请先登陆
回到顶部