diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/ShopUnitController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ShopUnitController.java new file mode 100644 index 0000000..c6f431d --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/ShopUnitController.java @@ -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)); + } +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUnit.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUnit.java index 2b3b263..34b5d4c 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUnit.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopUnit.java @@ -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(); + } } \ No newline at end of file diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopUnitMapper.java b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopUnitMapper.java new file mode 100644 index 0000000..1bbce49 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/mapper/MpShopUnitMapper.java @@ -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 { + + +} + + + diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopUnitService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopUnitService.java new file mode 100644 index 0000000..7ebffc4 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/TbShopUnitService.java @@ -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 { + + Page getShopUnit(Integer shopId, Integer page, Integer size, String name); +} diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopUnitServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopUnitServiceImpl.java new file mode 100644 index 0000000..5b98286 --- /dev/null +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopUnitServiceImpl.java @@ -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 + implements TbShopUnitService{ + + @Override + public Page getShopUnit(Integer shopId, Integer page, Integer size, String name) { + LambdaQueryWrapper query = new LambdaQueryWrapper().eq(TbShopUnit::getShopId, shopId); + if (StrUtil.isNotBlank(name)) { + query.like(TbShopUnit::getName, name); + } + return page(new Page<>(page, size), query); + } +} + + + + diff --git a/src/main/resources/mapper/TbShopUnitMapper.xml b/src/main/resources/mapper/TbShopUnitMapper.xml index 8630f61..4a51490 100644 --- a/src/main/resources/mapper/TbShopUnitMapper.xml +++ b/src/main/resources/mapper/TbShopUnitMapper.xml @@ -1,153 +1,26 @@ - - - - - - - - - - - - - - - - id, name, decimals_digits, unit_type, is_system, status, merchant_id, shop_id, created_at, - updated_at - - - - delete from tb_shop_unit - where id = #{id,jdbcType=INTEGER} - - - insert into tb_shop_unit (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 into tb_shop_unit - - - id, - - - name, - - - decimals_digits, - - - unit_type, - - - is_system, - - - status, - - - merchant_id, - - - shop_id, - - - created_at, - - - updated_at, - - - - - #{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}, - - - - - update tb_shop_unit - - - 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 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} - - \ No newline at end of file + + + + + + + + + + + + + + + + + + id,name,decimals_digits, + unit_type,is_system,status, + merchant_id,shop_id,created_at, + updated_at + +