feat: 1.增加商品单位列表接口
This commit is contained in:
parent
c6aff238c1
commit
7797edd813
|
|
@ -0,0 +1,25 @@
|
|||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.service.TbShopUnitService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/unit")
|
||||
public class ShopUnitController {
|
||||
private final TbShopUnitService shopUnitService;
|
||||
|
||||
public ShopUnitController(TbShopUnitService shopUnitService) {
|
||||
this.shopUnitService = shopUnitService;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public Result getShopUnit(@RequestParam Integer shopId, @RequestParam(defaultValue = "1") Integer page,
|
||||
@RequestParam(defaultValue = "20") Integer size, @RequestParam(required = false) String name) {
|
||||
return Result.success(CodeEnum.SUCCESS, shopUnitService.getShopUnit(shopId, page, size, name));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,107 +1,270 @@
|
|||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品单位
|
||||
* @TableName tb_shop_unit
|
||||
*/
|
||||
@TableName(value ="tb_shop_unit")
|
||||
public class TbShopUnit implements Serializable {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 单位名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 小数位(个数大于0,表示小数据精度位数)
|
||||
*/
|
||||
private Integer decimalsDigits;
|
||||
|
||||
/**
|
||||
* 单位类型(weight代表重量,小数单位,为number代表个数)
|
||||
*/
|
||||
private String unitType;
|
||||
|
||||
private Byte isSystem;
|
||||
/**
|
||||
* 0后台添加 -1系统默认 (公斤、瓶)
|
||||
*/
|
||||
private Integer isSystem;
|
||||
|
||||
private Byte status;
|
||||
/**
|
||||
* 预留字段1-正常
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String merchantId;
|
||||
|
||||
/**
|
||||
* 店铺Id
|
||||
*/
|
||||
private String shopId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long createdAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long updatedAt;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位名称
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name == null ? null : name.trim();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小数位(个数大于0,表示小数据精度位数)
|
||||
*/
|
||||
public Integer getDecimalsDigits() {
|
||||
return decimalsDigits;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小数位(个数大于0,表示小数据精度位数)
|
||||
*/
|
||||
public void setDecimalsDigits(Integer decimalsDigits) {
|
||||
this.decimalsDigits = decimalsDigits;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位类型(weight代表重量,小数单位,为number代表个数)
|
||||
*/
|
||||
public String getUnitType() {
|
||||
return unitType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位类型(weight代表重量,小数单位,为number代表个数)
|
||||
*/
|
||||
public void setUnitType(String unitType) {
|
||||
this.unitType = unitType == null ? null : unitType.trim();
|
||||
this.unitType = unitType;
|
||||
}
|
||||
|
||||
public Byte getIsSystem() {
|
||||
/**
|
||||
* 0后台添加 -1系统默认 (公斤、瓶)
|
||||
*/
|
||||
public Integer getIsSystem() {
|
||||
return isSystem;
|
||||
}
|
||||
|
||||
public void setIsSystem(Byte isSystem) {
|
||||
/**
|
||||
* 0后台添加 -1系统默认 (公斤、瓶)
|
||||
*/
|
||||
public void setIsSystem(Integer isSystem) {
|
||||
this.isSystem = isSystem;
|
||||
}
|
||||
|
||||
public Byte getStatus() {
|
||||
/**
|
||||
* 预留字段1-正常
|
||||
*/
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Byte status) {
|
||||
/**
|
||||
* 预留字段1-正常
|
||||
*/
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public String getMerchantId() {
|
||||
return merchantId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setMerchantId(String merchantId) {
|
||||
this.merchantId = merchantId == null ? null : merchantId.trim();
|
||||
this.merchantId = merchantId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺Id
|
||||
*/
|
||||
public String getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 店铺Id
|
||||
*/
|
||||
public void setShopId(String shopId) {
|
||||
this.shopId = shopId == null ? null : shopId.trim();
|
||||
this.shopId = shopId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public Long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setCreatedAt(Long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public Long getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setUpdatedAt(Long updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
TbShopUnit other = (TbShopUnit) that;
|
||||
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
|
||||
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()))
|
||||
&& (this.getDecimalsDigits() == null ? other.getDecimalsDigits() == null : this.getDecimalsDigits().equals(other.getDecimalsDigits()))
|
||||
&& (this.getUnitType() == null ? other.getUnitType() == null : this.getUnitType().equals(other.getUnitType()))
|
||||
&& (this.getIsSystem() == null ? other.getIsSystem() == null : this.getIsSystem().equals(other.getIsSystem()))
|
||||
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
|
||||
&& (this.getMerchantId() == null ? other.getMerchantId() == null : this.getMerchantId().equals(other.getMerchantId()))
|
||||
&& (this.getShopId() == null ? other.getShopId() == null : this.getShopId().equals(other.getShopId()))
|
||||
&& (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
|
||||
&& (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
|
||||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||
result = prime * result + ((getDecimalsDigits() == null) ? 0 : getDecimalsDigits().hashCode());
|
||||
result = prime * result + ((getUnitType() == null) ? 0 : getUnitType().hashCode());
|
||||
result = prime * result + ((getIsSystem() == null) ? 0 : getIsSystem().hashCode());
|
||||
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
|
||||
result = prime * result + ((getMerchantId() == null) ? 0 : getMerchantId().hashCode());
|
||||
result = prime * result + ((getShopId() == null) ? 0 : getShopId().hashCode());
|
||||
result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
|
||||
result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", id=").append(id);
|
||||
sb.append(", name=").append(name);
|
||||
sb.append(", decimalsDigits=").append(decimalsDigits);
|
||||
sb.append(", unitType=").append(unitType);
|
||||
sb.append(", isSystem=").append(isSystem);
|
||||
sb.append(", status=").append(status);
|
||||
sb.append(", merchantId=").append(merchantId);
|
||||
sb.append(", shopId=").append(shopId);
|
||||
sb.append(", createdAt=").append(createdAt);
|
||||
sb.append(", updatedAt=").append(updatedAt);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.chaozhanggui.system.cashierservice.mapper;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopUnit;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_shop_unit(商品单位)】的数据库操作Mapper
|
||||
* @createDate 2024-11-26 09:36:19
|
||||
* @Entity com.chaozhanggui.system.cashierservice.entity.TbShopUnit
|
||||
*/
|
||||
@Mapper
|
||||
public interface MpShopUnitMapper extends BaseMapper<TbShopUnit> {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopUnit;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_shop_unit(商品单位)】的数据库操作Service
|
||||
* @createDate 2024-11-26 09:36:19
|
||||
*/
|
||||
public interface TbShopUnitService extends IService<TbShopUnit> {
|
||||
|
||||
Page<TbShopUnit> getShopUnit(Integer shopId, Integer page, Integer size, String name);
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopUnit;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.MpShopUnitMapper;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbShopUnitService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_shop_unit(商品单位)】的数据库操作Service实现
|
||||
* @createDate 2024-11-26 09:36:19
|
||||
*/
|
||||
@Service
|
||||
public class TbShopUnitServiceImpl extends ServiceImpl<MpShopUnitMapper, TbShopUnit>
|
||||
implements TbShopUnitService{
|
||||
|
||||
@Override
|
||||
public Page<TbShopUnit> getShopUnit(Integer shopId, Integer page, Integer size, String name) {
|
||||
LambdaQueryWrapper<TbShopUnit> query = new LambdaQueryWrapper<TbShopUnit>().eq(TbShopUnit::getShopId, shopId);
|
||||
if (StrUtil.isNotBlank(name)) {
|
||||
query.like(TbShopUnit::getName, name);
|
||||
}
|
||||
return page(new Page<>(page, size), query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,153 +1,26 @@
|
|||
<?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.chaozhanggui.system.cashierservice.dao.TbShopUnitMapper">
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.chaozhanggui.system.cashierservice.mapper.MpShopUnitMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbShopUnit">
|
||||
<id column="id" jdbcType="INTEGER" property="id" />
|
||||
<result column="name" jdbcType="VARCHAR" property="name" />
|
||||
<result column="decimals_digits" jdbcType="INTEGER" property="decimalsDigits" />
|
||||
<result column="unit_type" jdbcType="VARCHAR" property="unitType" />
|
||||
<result column="is_system" jdbcType="TINYINT" property="isSystem" />
|
||||
<result column="status" jdbcType="TINYINT" property="status" />
|
||||
<result column="merchant_id" jdbcType="VARCHAR" property="merchantId" />
|
||||
<result column="shop_id" jdbcType="VARCHAR" property="shopId" />
|
||||
<result column="created_at" jdbcType="BIGINT" property="createdAt" />
|
||||
<result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="decimalsDigits" column="decimals_digits" jdbcType="INTEGER"/>
|
||||
<result property="unitType" column="unit_type" jdbcType="VARCHAR"/>
|
||||
<result property="isSystem" column="is_system" jdbcType="TINYINT"/>
|
||||
<result property="status" column="status" jdbcType="TINYINT"/>
|
||||
<result property="merchantId" column="merchant_id" jdbcType="VARCHAR"/>
|
||||
<result property="shopId" column="shop_id" jdbcType="VARCHAR"/>
|
||||
<result property="createdAt" column="created_at" jdbcType="BIGINT"/>
|
||||
<result property="updatedAt" column="updated_at" jdbcType="BIGINT"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id, name, decimals_digits, unit_type, is_system, status, merchant_id, shop_id, created_at,
|
||||
updated_at
|
||||
</sql>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from tb_shop_unit
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</select>
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
|
||||
delete from tb_shop_unit
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</delete>
|
||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUnit">
|
||||
insert into tb_shop_unit (id, name, decimals_digits,
|
||||
id,name,decimals_digits,
|
||||
unit_type,is_system,status,
|
||||
merchant_id,shop_id,created_at,
|
||||
updated_at)
|
||||
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{decimalsDigits,jdbcType=INTEGER},
|
||||
#{unitType,jdbcType=VARCHAR}, #{isSystem,jdbcType=TINYINT}, #{status,jdbcType=TINYINT},
|
||||
#{merchantId,jdbcType=VARCHAR}, #{shopId,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT},
|
||||
#{updatedAt,jdbcType=BIGINT})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUnit">
|
||||
insert into tb_shop_unit
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
id,
|
||||
</if>
|
||||
<if test="name != null">
|
||||
name,
|
||||
</if>
|
||||
<if test="decimalsDigits != null">
|
||||
decimals_digits,
|
||||
</if>
|
||||
<if test="unitType != null">
|
||||
unit_type,
|
||||
</if>
|
||||
<if test="isSystem != null">
|
||||
is_system,
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status,
|
||||
</if>
|
||||
<if test="merchantId != null">
|
||||
merchant_id,
|
||||
</if>
|
||||
<if test="shopId != null">
|
||||
shop_id,
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
created_at,
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
updated_at,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">
|
||||
#{id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="name != null">
|
||||
#{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="decimalsDigits != null">
|
||||
#{decimalsDigits,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="unitType != null">
|
||||
#{unitType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="isSystem != null">
|
||||
#{isSystem,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
#{status,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="merchantId != null">
|
||||
#{merchantId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="shopId != null">
|
||||
#{shopId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
#{createdAt,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
#{updatedAt,jdbcType=BIGINT},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUnit">
|
||||
update tb_shop_unit
|
||||
<set>
|
||||
<if test="name != null">
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="decimalsDigits != null">
|
||||
decimals_digits = #{decimalsDigits,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="unitType != null">
|
||||
unit_type = #{unitType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="isSystem != null">
|
||||
is_system = #{isSystem,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="merchantId != null">
|
||||
merchant_id = #{merchantId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="shopId != null">
|
||||
shop_id = #{shopId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
created_at = #{createdAt,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
updated_at = #{updatedAt,jdbcType=BIGINT},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUnit">
|
||||
update tb_shop_unit
|
||||
set name = #{name,jdbcType=VARCHAR},
|
||||
decimals_digits = #{decimalsDigits,jdbcType=INTEGER},
|
||||
unit_type = #{unitType,jdbcType=VARCHAR},
|
||||
is_system = #{isSystem,jdbcType=TINYINT},
|
||||
status = #{status,jdbcType=TINYINT},
|
||||
merchant_id = #{merchantId,jdbcType=VARCHAR},
|
||||
shop_id = #{shopId,jdbcType=VARCHAR},
|
||||
created_at = #{createdAt,jdbcType=BIGINT},
|
||||
updated_at = #{updatedAt,jdbcType=BIGINT}
|
||||
where id = #{id,jdbcType=INTEGER}
|
||||
</update>
|
||||
updated_at
|
||||
</sql>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue