yangyb il y a 1 semaine
Parent
commit
1ad611bc92

+ 259 - 0
mall-api/src/main/java/com/txz/mall/dto/BannerDTO.java

@@ -0,0 +1,259 @@
+/*
+ *
+ * BannerDTO.java
+ * Copyright(C) 2017-2020 fendo公司
+ * @date 2025-08-05
+ */
+package com.txz.mall.dto;
+
+import java.io.Serializable;
+import java.util.Date;
+
+public class BannerDTO implements Serializable {
+    /**
+     * m_banner
+     */
+    private static final long serialVersionUID = 1L;
+    /**
+     * 组合数据ID
+     */
+    private Long id;
+    /**
+     * 名称
+     */
+    private String title;
+    /**
+     * 图片地址
+     */
+    private String image;
+    /**
+     * 0-内链,1-外链
+     */
+    private Integer linkType;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+    /**
+     * 创建人id
+     */
+    private Long createUserId;
+    /**
+     * 更新人id
+     */
+    private Long updateUserId;
+    /**
+     * 是否删除
+     */
+    private Byte isDelete;
+    /**
+     * 跳转地址
+     */
+    private String link;
+    /**
+     * 排序
+     */
+    private Byte seq;
+
+    /**
+     * 组合数据ID
+     *
+     * @return id 组合数据ID
+     */
+    public Long getId() {
+        return id;
+    }
+
+    /**
+     * 组合数据ID
+     *
+     * @param id 组合数据ID
+     */
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    /**
+     * 名称
+     *
+     * @return title 名称
+     */
+    public String getTitle() {
+        return title;
+    }
+
+    /**
+     * 名称
+     *
+     * @param title 名称
+     */
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    /**
+     * 图片地址
+     *
+     * @return image 图片地址
+     */
+    public String getImage() {
+        return image;
+    }
+
+    /**
+     * 图片地址
+     *
+     * @param image 图片地址
+     */
+    public void setImage(String image) {
+        this.image = image;
+    }
+
+    /**
+     * 0-内链,1-外链
+     *
+     * @return link_type 0-内链,1-外链
+     */
+    public Integer getLinkType() {
+        return linkType;
+    }
+
+    /**
+     * 0-内链,1-外链
+     *
+     * @param linkType 0-内链,1-外链
+     */
+    public void setLinkType(Integer linkType) {
+        this.linkType = linkType;
+    }
+
+    /**
+     * 创建时间
+     *
+     * @return create_time 创建时间
+     */
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    /**
+     * 创建时间
+     *
+     * @param createTime 创建时间
+     */
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    /**
+     * 更新时间
+     *
+     * @return update_time 更新时间
+     */
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    /**
+     * 更新时间
+     *
+     * @param updateTime 更新时间
+     */
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    /**
+     * 创建人id
+     *
+     * @return create_user_id 创建人id
+     */
+    public Long getCreateUserId() {
+        return createUserId;
+    }
+
+    /**
+     * 创建人id
+     *
+     * @param createUserId 创建人id
+     */
+    public void setCreateUserId(Long createUserId) {
+        this.createUserId = createUserId;
+    }
+
+    /**
+     * 更新人id
+     *
+     * @return update_user_id 更新人id
+     */
+    public Long getUpdateUserId() {
+        return updateUserId;
+    }
+
+    /**
+     * 更新人id
+     *
+     * @param updateUserId 更新人id
+     */
+    public void setUpdateUserId(Long updateUserId) {
+        this.updateUserId = updateUserId;
+    }
+
+    /**
+     * 是否删除
+     *
+     * @return is_delete 是否删除
+     */
+    public Byte getIsDelete() {
+        return isDelete;
+    }
+
+    /**
+     * 是否删除
+     *
+     * @param isDelete 是否删除
+     */
+    public void setIsDelete(Byte isDelete) {
+        this.isDelete = isDelete;
+    }
+
+    /**
+     * 跳转地址
+     *
+     * @return link 跳转地址
+     */
+    public String getLink() {
+        return link;
+    }
+
+    /**
+     * 跳转地址
+     *
+     * @param link 跳转地址
+     */
+    public void setLink(String link) {
+        this.link = link;
+    }
+
+    /**
+     * 排序
+     *
+     * @return seq 排序
+     */
+    public Byte getSeq() {
+        return seq;
+    }
+
+    /**
+     * 排序
+     *
+     * @param seq 排序
+     */
+    public void setSeq(Byte seq) {
+        this.seq = seq;
+    }
+}

+ 27 - 0
mall-interface/src/main/java/com/txz/mall/service/BannerServiceClient.java

@@ -0,0 +1,27 @@
+package com.txz.mall.service;
+
+
+import com.txz.mall.dto.*;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.*;
+import java.util.List;
+
+
+@FeignClient("mall")
+public interface BannerServiceClient {
+
+	@RequestMapping( value = {"/banner/add"}, method = {RequestMethod.POST} )
+    public Result add(@RequestBody BannerDPO banner,@RequestParam("userId") Long userId);
+
+	@RequestMapping( value = {"/banner/delete"}, method = {RequestMethod.POST} )
+	public Result delete(@RequestParam("id") Integer id,@RequestParam("userId") Long userId);
+
+	@RequestMapping( value = {"/banner/update"}, method = {RequestMethod.POST} )
+	public Result update(@RequestBody BannerDPO banner,@RequestParam("userId") Long userId);
+
+	@RequestMapping( value = {"/banner/detail"}, method = {RequestMethod.POST} )
+	public Result<BannerDPO> detail(@RequestParam("id") Integer id,@RequestParam("userId") Long userId);
+
+	@RequestMapping( value = {"/banner/list"}, method = {RequestMethod.POST} )
+	public Result<List<BannerDPO>> list(@RequestBody BannerDPO banner, @RequestParam("page") Integer page, @RequestParam("size") Integer size,@RequestParam("userId") Long userId);
+}

+ 124 - 0
mall-service/src/main/java/com/txz/mall/controller/BannerController.java

@@ -0,0 +1,124 @@
+package com.txz.mall.controller;
+
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.txz.mall.core.Result;
+import com.txz.mall.core.ResultCode;
+import com.txz.mall.model.Banner;
+import com.txz.mall.service.BannerService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.*;
+import tk.mybatis.mapper.entity.Condition;
+import tk.mybatis.mapper.entity.Example.Criteria;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Created by CodeGenerator on 2025/08/05.
+ */
+@Api(tags = "[后台]轮播图管理")
+@RestController
+@RequestMapping("/banner")
+public class BannerController {
+
+    private static Logger log = LoggerFactory.getLogger(BannerController.class);
+
+    @Resource
+    private BannerService bannerService;
+
+    @PostMapping("/add")
+    @ApiOperation(value = "轮播图新增")
+    public Result add(@RequestBody Banner banner) {
+        if (banner == null) {
+            return Result.fail(ResultCode.OBJECT_IS_NULL);
+        }
+        try {
+            banner.setCreateTime(new Date());
+//            banner.setCreateUserId(userId);
+            bannerService.save(banner);
+        } catch (Exception e) {
+            log.error("新增对象操作异常e:{}", e);
+            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+        }
+        return Result.success();
+    }
+
+    @PostMapping("/delete")
+    @ApiOperation(value = "轮播图删除")
+    public Result delete(@RequestParam Long id) {
+        if (id == null) {
+            return Result.fail(ResultCode.ID_IS_NULL);
+        }
+        try {
+            Banner banner = new Banner();
+            banner.setId(id);
+            banner.setIsDelete(1);
+            bannerService.update(banner);
+        } catch (Exception e) {
+            log.error("删除对象操作异常e:{}", e);
+            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+        }
+        return Result.success();
+    }
+
+    @PostMapping("/update")
+    @ApiOperation(value = "轮播图更新")
+    public Result update(@RequestBody Banner banner) {
+        if (banner == null) {
+            return Result.fail(ResultCode.OBJECT_IS_NULL);
+        }
+        if (banner.getId() == null) {
+            return Result.fail(ResultCode.ID_IS_NULL);
+        }
+        try {
+            banner.setUpdateTime(new Date());
+//            banner.setUpdateUserId(userId);
+            bannerService.update(banner);
+        } catch (Exception e) {
+            log.error("更新对象操作异常e:{}", e);
+            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+        }
+        return Result.success();
+    }
+
+    @PostMapping("/detail")
+    @ApiOperation(value = "轮播图获取详情")
+    public Result<Banner> detail(@RequestParam Long id) {
+        if (id == null) {
+            return Result.fail(ResultCode.ID_IS_NULL);
+        }
+        Banner banner = null;
+        try {
+            banner = bannerService.findById(id);
+        } catch (Exception e) {
+            log.error("查询对象操作异常e:{}", e);
+            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+        }
+        return Result.success(banner);
+    }
+
+    @PostMapping("/list")
+    @ApiOperation(value = "轮播图获取列表")
+    public Result<List<Banner>> list(@RequestBody Banner banner, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
+        PageHelper.startPage(page, size);
+
+        Condition condition = new Condition(banner.getClass());
+        Criteria criteria = condition.createCriteria();
+        criteria.andEqualTo("isDelete", 0);
+        condition.setOrderByClause("create_time DESC");
+        PageInfo pageInfo = null;
+        try {
+            List<Banner> list = bannerService.findByCondition(condition);
+            pageInfo = new PageInfo(list);
+        } catch (Exception e) {
+            log.error("查询对象操作异常e:{}", e);
+            return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
+        }
+        return Result.success(pageInfo);
+    }
+}

+ 7 - 0
mall-service/src/main/java/com/txz/mall/dao/BannerMapper.java

@@ -0,0 +1,7 @@
+package com.txz.mall.dao;
+
+import com.txz.mall.core.Mapper;
+import com.txz.mall.model.Banner;
+
+public interface BannerMapper extends Mapper<Banner> {
+}

+ 74 - 0
mall-service/src/main/java/com/txz/mall/model/Banner.java

@@ -0,0 +1,74 @@
+package com.txz.mall.model;
+
+import lombok.Data;
+
+import javax.persistence.*;
+import java.util.Date;
+
+@Data
+@Table(name = "m_banner")
+public class Banner {
+    /**
+     * 组合数据ID
+     */
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+
+    /**
+     * 名称
+     */
+    private String title;
+
+    /**
+     * 图片地址
+     */
+    private String image;
+
+    /**
+     * 0-内链,1-外链
+     */
+    @Column(name = "link_type")
+    private Integer linkType;
+
+    /**
+     * 创建时间
+     */
+    @Column(name = "create_time")
+    private Date createTime;
+
+    /**
+     * 更新时间
+     */
+    @Column(name = "update_time")
+    private Date updateTime;
+
+    /**
+     * 创建人id
+     */
+    @Column(name = "create_user_id")
+    private Long createUserId;
+
+    /**
+     * 更新人id
+     */
+    @Column(name = "update_user_id")
+    private Long updateUserId;
+
+    /**
+     * 是否删除
+     */
+    @Column(name = "is_delete")
+    private Integer isDelete;
+
+    /**
+     * 跳转地址
+     */
+    private String link;
+
+    /**
+     * 排序
+     */
+    private Integer seq;
+
+}

+ 12 - 0
mall-service/src/main/java/com/txz/mall/service/BannerService.java

@@ -0,0 +1,12 @@
+package com.txz.mall.service;
+
+import com.txz.mall.core.Service;
+import com.txz.mall.model.Banner;
+
+
+/**
+ * Created by CodeGenerator on 2025/08/05.
+ */
+public interface BannerService extends Service<Banner> {
+
+}

+ 22 - 0
mall-service/src/main/java/com/txz/mall/service/impl/BannerServiceImpl.java

@@ -0,0 +1,22 @@
+package com.txz.mall.service.impl;
+
+import com.txz.mall.core.AbstractService;
+import com.txz.mall.dao.BannerMapper;
+import com.txz.mall.model.Banner;
+import com.txz.mall.service.BannerService;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+
+
+/**
+ * Created by CodeGenerator on 2025/08/05.
+ */
+@Service
+@Transactional
+public class BannerServiceImpl extends AbstractService<Banner> implements BannerService {
+    @Resource
+    private BannerMapper mBannerMapper;
+
+}

+ 20 - 0
mall-service/src/main/resources/mapper/BannerMapper.xml

@@ -0,0 +1,20 @@
+<?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.txz.mall.dao.BannerMapper">
+    <resultMap id="BaseResultMap" type="com.txz.mall.model.Banner">
+        <!--
+          WARNING - @mbg.generated
+        -->
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="title" jdbcType="VARCHAR" property="title"/>
+        <result column="image" jdbcType="VARCHAR" property="image"/>
+        <result column="link_type" jdbcType="INTEGER" property="linkType"/>
+        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
+        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
+        <result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
+        <result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
+        <result column="is_delete" jdbcType="INTEGER" property="isDelete"/>
+        <result column="link" jdbcType="VARCHAR" property="link"/>
+        <result column="seq" jdbcType="INTEGER" property="seq"/>
+    </resultMap>
+</mapper>

+ 1 - 1
mall-service/src/test/java/CodeGenerator.java

@@ -47,7 +47,7 @@ public class CodeGenerator {
 	public static void main(String[] args) {
 //		genCode("o_lottery","o_lottery_prize","o_lottery_record");
 		// genCode("输入表名","输入自定义Model名称");
-		  genCode("m_store_product");
+		genCode("m_banner");
 		//genCode("c_member_coupon");
 	}