diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopExtendController.java b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopExtendController.java new file mode 100644 index 00000000..2a1f6172 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/controller/shop/TbShopExtendController.java @@ -0,0 +1,75 @@ +package cn.ysk.cashier.controller.shop; + + +import cn.ysk.cashier.annotation.rest.AnonymousDeleteMapping; +import cn.ysk.cashier.annotation.rest.AnonymousGetMapping; +import cn.ysk.cashier.annotation.rest.AnonymousPostMapping; +import cn.ysk.cashier.annotation.rest.AnonymousPutMapping; +import cn.ysk.cashier.mybatis.entity.TbShopExtend; +import cn.ysk.cashier.mybatis.service.TbShopExtendService; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import cn.ysk.cashier.dto.shop.TbShopExtendQueryCriteria; + +import javax.annotation.Resource; +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * 店铺扩展信息(TbShopExtend)表控制层 + * + * @author ww + * @since 2024-07-18 11:10:16 + */ +@RestController +@RequestMapping("tbShopExtend") +public class TbShopExtendController { + /** + * 服务对象 + */ + @Resource + private TbShopExtendService tbShopExtendService; + + @GetMapping + @ApiOperation("分页查询") + @AnonymousGetMapping + public ResponseEntity selectAll(TbShopExtendQueryCriteria criteria) { + return new ResponseEntity<>(tbShopExtendService.queryAll(criteria), HttpStatus.OK); + } + + @GetMapping("{id}") + @ApiOperation("通过Id查询详情") + @AnonymousGetMapping + public TbShopExtend selectOne(@PathVariable Serializable id) { + return tbShopExtendService.getById(id); + } + + @PostMapping + @ApiOperation("新增") + @AnonymousPostMapping + public ResponseEntity insert(@RequestBody TbShopExtend tbShopExtend) { + tbShopExtend.setCreateTime(new Date()); + return new ResponseEntity<>(tbShopExtendService.save(tbShopExtend), HttpStatus.CREATED); + } + + @PutMapping + @ApiOperation("通过id修改") + @AnonymousPutMapping + public ResponseEntity update(@RequestBody TbShopExtend tbShopExtend) { + tbShopExtend.setUpdateTime(new Date()); + tbShopExtendService.updateById(tbShopExtend); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @DeleteMapping + @ApiOperation("删除") + @AnonymousDeleteMapping + public ResponseEntity delete(@RequestParam("idList") List idList) { + tbShopExtendService.removeByIds(idList); + return new ResponseEntity<>(HttpStatus.OK); + } +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopExtendQueryCriteria.java b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopExtendQueryCriteria.java new file mode 100644 index 00000000..667ee2b7 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/dto/shop/TbShopExtendQueryCriteria.java @@ -0,0 +1,36 @@ +package cn.ysk.cashier.dto.shop; + +import lombok.Data; + + +/** + * 店铺扩展信息(TbShopExtend)表查询类 + * + * @author ww + * @since 2024-07-18 10:46:57 + */ +@Data +public class TbShopExtendQueryCriteria { + private Integer shopId; + //img:图片;text:文本; + private String type; + //自定义key + private String autokey; + //值 + private String value; + private long page = 1; + private long size = 10; + + public void setPage(long page) { + if (page != 0) { + this.page = page; + } + } + + public void setSize(long size) { + if (size != 0) { + this.size = size; + } + } +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopExtend.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopExtend.java new file mode 100644 index 00000000..a49b186b --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/entity/TbShopExtend.java @@ -0,0 +1,88 @@ +package cn.ysk.cashier.mybatis.entity; + +import java.util.Date; + +import com.baomidou.mybatisplus.extension.activerecord.Model; + + +/** + * 店铺扩展信息(TbShopExtend)表实体类 + * + * @author ww + * @since 2024-07-18 11:10:16 + */ +@SuppressWarnings("serial") +public class TbShopExtend extends Model { + //自增id + private Integer id; + //商户Id + private Integer shopId; + //img:图片;text:文本; + private String type; + //自定义key + private String autokey; + //值 + private String value; + //更新时间 + private Date updateTime; + //创建时间 + private Date createTime; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getShopId() { + return shopId; + } + + public void setShopId(Integer shopId) { + this.shopId = shopId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getAutokey() { + return autokey; + } + + public void setAutokey(String autokey) { + this.autokey = autokey; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopExtendMapper.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopExtendMapper.java new file mode 100644 index 00000000..970a9ba4 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/mapper/TbShopExtendMapper.java @@ -0,0 +1,15 @@ +package cn.ysk.cashier.mybatis.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import cn.ysk.cashier.mybatis.entity.TbShopExtend; + +/** + * 店铺扩展信息(TbShopExtend)表数据库访问层 + * + * @author ww + * @since 2024-07-18 11:10:16 + */ +public interface TbShopExtendMapper extends BaseMapper { + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopExtendService.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopExtendService.java new file mode 100644 index 00000000..61a6b174 --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/TbShopExtendService.java @@ -0,0 +1,20 @@ +package cn.ysk.cashier.mybatis.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import cn.ysk.cashier.mybatis.entity.TbShopExtend; +import cn.ysk.cashier.dto.shop.TbShopExtendQueryCriteria; + +import java.util.Map; + +/** + * 店铺扩展信息(TbShopExtend)表服务接口 + * + * @author ww + * @since 2024-07-18 11:10:16 + */ +public interface TbShopExtendService extends IService { + + Map queryAll(TbShopExtendQueryCriteria criteria); + +} + diff --git a/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopExtendServiceImpl.java b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopExtendServiceImpl.java new file mode 100644 index 00000000..fe7bc2cc --- /dev/null +++ b/eladmin-system/src/main/java/cn/ysk/cashier/mybatis/service/impl/TbShopExtendServiceImpl.java @@ -0,0 +1,45 @@ +package cn.ysk.cashier.mybatis.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import cn.ysk.cashier.mybatis.mapper.TbShopExtendMapper; +import cn.ysk.cashier.mybatis.entity.TbShopExtend; +import cn.ysk.cashier.mybatis.service.TbShopExtendService; +import org.springframework.stereotype.Service; +import org.apache.commons.lang3.StringUtils; +import cn.ysk.cashier.dto.shop.TbShopExtendQueryCriteria; +import org.springframework.beans.factory.annotation.Autowired; +import cn.ysk.cashier.utils.PageUtil; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; + +import java.util.Map; + +/** + * 店铺扩展信息(TbShopExtend)表服务实现类 + * + * @author ww + * @since 2024-07-18 10:57:39 + */ +@Service("tbShopExtendService") +public class TbShopExtendServiceImpl extends ServiceImpl implements TbShopExtendService { + + @Autowired + private TbShopExtendMapper tbShopExtendmapper; + + @Override + public Map queryAll(TbShopExtendQueryCriteria criteria) { + Page page = new Page<>(criteria.getPage(), criteria.getSize()); + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("shop_id", criteria.getShopId()); + if (StringUtils.isNotBlank(criteria.getType())) { + wrapper.eq("type",criteria.getType()); + } + if (StringUtils.isNotBlank(criteria.getAutokey())) { + wrapper.like("autokey",criteria.getAutokey()); + } + wrapper.orderByDesc("create_time"); + Page ipage = tbShopExtendmapper.selectPage(page, wrapper); + return PageUtil.toPage(ipage.getRecords(), ipage.getTotal()); + } +} +