feat(generator): 优化模板生成逻辑并添加新功能
- 改进 index.tsx 模板,增加智能字段检测和条件性功能生成 - 修复字段注释为空时模板渲染失败的问题 - 添加自动更新 app.config.ts 页面路径的功能 - 新增 ShopArticle相关的实体、Mapper、Service 等代码 - 优化 add.tsx 和 add.config.ts模板,提高用户体验
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.service.ShopArticleService;
|
||||
import com.gxwebsoft.shop.entity.ShopArticle;
|
||||
import com.gxwebsoft.shop.param.ShopArticleParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品文章控制器
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-13 00:28:23
|
||||
*/
|
||||
@Tag(name = "商品文章管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/shop-article")
|
||||
public class ShopArticleController extends BaseController {
|
||||
@Resource
|
||||
private ShopArticleService shopArticleService;
|
||||
|
||||
@Operation(summary = "分页查询商品文章")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ShopArticle>> page(ShopArticleParam param) {
|
||||
// 使用关联查询
|
||||
return success(shopArticleService.pageRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "查询全部商品文章")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ShopArticle>> list(ShopArticleParam param) {
|
||||
// 使用关联查询
|
||||
return success(shopArticleService.listRel(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "根据id查询商品文章")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ShopArticle> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(shopArticleService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@Operation(summary = "添加商品文章")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ShopArticle shopArticle) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
shopArticle.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (shopArticleService.save(shopArticle)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@Operation(summary = "修改商品文章")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ShopArticle shopArticle) {
|
||||
if (shopArticleService.updateById(shopArticle)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@Operation(summary = "删除商品文章")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (shopArticleService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@Operation(summary = "批量添加商品文章")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<ShopArticle> list) {
|
||||
if (shopArticleService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@Operation(summary = "批量修改商品文章")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody BatchParam<ShopArticle> batchParam) {
|
||||
if (batchParam.update(shopArticleService, "article_id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@OperationLog
|
||||
@Operation(summary = "批量删除商品文章")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (shopArticleService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
192
src/main/java/com/gxwebsoft/shop/entity/ShopArticle.java
Normal file
192
src/main/java/com/gxwebsoft/shop/entity/ShopArticle.java
Normal file
@@ -0,0 +1,192 @@
|
||||
package com.gxwebsoft.shop.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 商品文章
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-13 00:28:23
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(name = "ShopArticle对象", description = "商品文章")
|
||||
public class ShopArticle implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "文章ID")
|
||||
@TableId(value = "article_id", type = IdType.AUTO)
|
||||
private Integer articleId;
|
||||
|
||||
@Schema(description = "文章标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "文章类型 0常规 1视频")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "模型")
|
||||
private String model;
|
||||
|
||||
@Schema(description = "详情页模板")
|
||||
private String detail;
|
||||
|
||||
@Schema(description = "文章分类ID")
|
||||
private Integer categoryId;
|
||||
|
||||
@Schema(description = "上级id, 0是顶级")
|
||||
private Integer parentId;
|
||||
|
||||
@Schema(description = "话题")
|
||||
private String topic;
|
||||
|
||||
@Schema(description = "标签")
|
||||
private String tags;
|
||||
|
||||
@Schema(description = "封面图")
|
||||
private String image;
|
||||
|
||||
@Schema(description = "封面图宽")
|
||||
private Integer imageWidth;
|
||||
|
||||
@Schema(description = "封面图高")
|
||||
private Integer imageHeight;
|
||||
|
||||
@Schema(description = "付费金额")
|
||||
private BigDecimal price;
|
||||
|
||||
@Schema(description = "开始时间")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
@Schema(description = "结束时间")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
@Schema(description = "来源")
|
||||
private String source;
|
||||
|
||||
@Schema(description = "产品概述")
|
||||
private String overview;
|
||||
|
||||
@Schema(description = "虚拟阅读量(仅用作展示)")
|
||||
private Integer virtualViews;
|
||||
|
||||
@Schema(description = "实际阅读量")
|
||||
private Integer actualViews;
|
||||
|
||||
@Schema(description = "评分")
|
||||
private BigDecimal rate;
|
||||
|
||||
@Schema(description = "列表显示方式(10小图展示 20大图展示)")
|
||||
private Integer showType;
|
||||
|
||||
@Schema(description = "访问密码")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "可见类型 0所有人 1登录可见 2密码可见")
|
||||
private Integer permission;
|
||||
|
||||
@Schema(description = "发布来源客户端 (APP、H5、小程序等)")
|
||||
private String platform;
|
||||
|
||||
@Schema(description = "文章附件")
|
||||
private String files;
|
||||
|
||||
@Schema(description = "视频地址")
|
||||
private String video;
|
||||
|
||||
@Schema(description = "接受的文件类型")
|
||||
private String accept;
|
||||
|
||||
@Schema(description = "经度")
|
||||
private String longitude;
|
||||
|
||||
@Schema(description = "纬度")
|
||||
private String latitude;
|
||||
|
||||
@Schema(description = "所在省份")
|
||||
private String province;
|
||||
|
||||
@Schema(description = "所在城市")
|
||||
private String city;
|
||||
|
||||
@Schema(description = "所在辖区")
|
||||
private String region;
|
||||
|
||||
@Schema(description = "街道地址")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "点赞数")
|
||||
private Integer likes;
|
||||
|
||||
@Schema(description = "评论数")
|
||||
private Integer commentNumbers;
|
||||
|
||||
@Schema(description = "提醒谁看")
|
||||
private String toUsers;
|
||||
|
||||
@Schema(description = "作者")
|
||||
private String author;
|
||||
|
||||
@Schema(description = "推荐")
|
||||
private Integer recommend;
|
||||
|
||||
@Schema(description = "报名人数")
|
||||
private Integer bmUsers;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "商户ID")
|
||||
private Integer merchantId;
|
||||
|
||||
@Schema(description = "项目ID")
|
||||
private Integer projectId;
|
||||
|
||||
@Schema(description = "语言")
|
||||
private String lang;
|
||||
|
||||
@Schema(description = "关联默认语言的文章ID")
|
||||
private Integer langArticleId;
|
||||
|
||||
@Schema(description = "是否自动翻译")
|
||||
private Boolean translation;
|
||||
|
||||
@Schema(description = "编辑器类型 0 Markdown编辑器 1 富文本编辑器 ")
|
||||
private Boolean editor;
|
||||
|
||||
@Schema(description = "pdf文件地址")
|
||||
private String pdfUrl;
|
||||
|
||||
@Schema(description = "版本号")
|
||||
private Integer version;
|
||||
|
||||
@Schema(description = "排序(数字越小越靠前)")
|
||||
private Integer sortNumber;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String comments;
|
||||
|
||||
@Schema(description = "状态, 0已发布, 1待审核 2已驳回 3违规内容")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@Schema(description = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.shop.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.shop.entity.ShopArticle;
|
||||
import com.gxwebsoft.shop.param.ShopArticleParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品文章Mapper
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-13 00:28:23
|
||||
*/
|
||||
public interface ShopArticleMapper extends BaseMapper<ShopArticle> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<ShopArticle>
|
||||
*/
|
||||
List<ShopArticle> selectPageRel(@Param("page") IPage<ShopArticle> page,
|
||||
@Param("param") ShopArticleParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<ShopArticle> selectListRel(@Param("param") ShopArticleParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,192 @@
|
||||
<?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.gxwebsoft.shop.mapper.ShopArticleMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM shop_article a
|
||||
<where>
|
||||
<if test="param.articleId != null">
|
||||
AND a.article_id = #{param.articleId}
|
||||
</if>
|
||||
<if test="param.title != null">
|
||||
AND a.title LIKE CONCAT('%', #{param.title}, '%')
|
||||
</if>
|
||||
<if test="param.type != null">
|
||||
AND a.type = #{param.type}
|
||||
</if>
|
||||
<if test="param.model != null">
|
||||
AND a.model LIKE CONCAT('%', #{param.model}, '%')
|
||||
</if>
|
||||
<if test="param.detail != null">
|
||||
AND a.detail LIKE CONCAT('%', #{param.detail}, '%')
|
||||
</if>
|
||||
<if test="param.categoryId != null">
|
||||
AND a.category_id = #{param.categoryId}
|
||||
</if>
|
||||
<if test="param.parentId != null">
|
||||
AND a.parent_id = #{param.parentId}
|
||||
</if>
|
||||
<if test="param.topic != null">
|
||||
AND a.topic LIKE CONCAT('%', #{param.topic}, '%')
|
||||
</if>
|
||||
<if test="param.tags != null">
|
||||
AND a.tags LIKE CONCAT('%', #{param.tags}, '%')
|
||||
</if>
|
||||
<if test="param.image != null">
|
||||
AND a.image LIKE CONCAT('%', #{param.image}, '%')
|
||||
</if>
|
||||
<if test="param.imageWidth != null">
|
||||
AND a.image_width = #{param.imageWidth}
|
||||
</if>
|
||||
<if test="param.imageHeight != null">
|
||||
AND a.image_height = #{param.imageHeight}
|
||||
</if>
|
||||
<if test="param.price != null">
|
||||
AND a.price = #{param.price}
|
||||
</if>
|
||||
<if test="param.startTime != null">
|
||||
AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%')
|
||||
</if>
|
||||
<if test="param.endTime != null">
|
||||
AND a.end_time LIKE CONCAT('%', #{param.endTime}, '%')
|
||||
</if>
|
||||
<if test="param.source != null">
|
||||
AND a.source LIKE CONCAT('%', #{param.source}, '%')
|
||||
</if>
|
||||
<if test="param.overview != null">
|
||||
AND a.overview LIKE CONCAT('%', #{param.overview}, '%')
|
||||
</if>
|
||||
<if test="param.virtualViews != null">
|
||||
AND a.virtual_views = #{param.virtualViews}
|
||||
</if>
|
||||
<if test="param.actualViews != null">
|
||||
AND a.actual_views = #{param.actualViews}
|
||||
</if>
|
||||
<if test="param.rate != null">
|
||||
AND a.rate = #{param.rate}
|
||||
</if>
|
||||
<if test="param.showType != null">
|
||||
AND a.show_type = #{param.showType}
|
||||
</if>
|
||||
<if test="param.password != null">
|
||||
AND a.password LIKE CONCAT('%', #{param.password}, '%')
|
||||
</if>
|
||||
<if test="param.permission != null">
|
||||
AND a.permission = #{param.permission}
|
||||
</if>
|
||||
<if test="param.platform != null">
|
||||
AND a.platform LIKE CONCAT('%', #{param.platform}, '%')
|
||||
</if>
|
||||
<if test="param.files != null">
|
||||
AND a.files LIKE CONCAT('%', #{param.files}, '%')
|
||||
</if>
|
||||
<if test="param.video != null">
|
||||
AND a.video LIKE CONCAT('%', #{param.video}, '%')
|
||||
</if>
|
||||
<if test="param.accept != null">
|
||||
AND a.accept LIKE CONCAT('%', #{param.accept}, '%')
|
||||
</if>
|
||||
<if test="param.longitude != null">
|
||||
AND a.longitude LIKE CONCAT('%', #{param.longitude}, '%')
|
||||
</if>
|
||||
<if test="param.latitude != null">
|
||||
AND a.latitude LIKE CONCAT('%', #{param.latitude}, '%')
|
||||
</if>
|
||||
<if test="param.province != null">
|
||||
AND a.province LIKE CONCAT('%', #{param.province}, '%')
|
||||
</if>
|
||||
<if test="param.city != null">
|
||||
AND a.city LIKE CONCAT('%', #{param.city}, '%')
|
||||
</if>
|
||||
<if test="param.region != null">
|
||||
AND a.region LIKE CONCAT('%', #{param.region}, '%')
|
||||
</if>
|
||||
<if test="param.address != null">
|
||||
AND a.address LIKE CONCAT('%', #{param.address}, '%')
|
||||
</if>
|
||||
<if test="param.likes != null">
|
||||
AND a.likes = #{param.likes}
|
||||
</if>
|
||||
<if test="param.commentNumbers != null">
|
||||
AND a.comment_numbers = #{param.commentNumbers}
|
||||
</if>
|
||||
<if test="param.toUsers != null">
|
||||
AND a.to_users LIKE CONCAT('%', #{param.toUsers}, '%')
|
||||
</if>
|
||||
<if test="param.author != null">
|
||||
AND a.author LIKE CONCAT('%', #{param.author}, '%')
|
||||
</if>
|
||||
<if test="param.recommend != null">
|
||||
AND a.recommend = #{param.recommend}
|
||||
</if>
|
||||
<if test="param.bmUsers != null">
|
||||
AND a.bm_users = #{param.bmUsers}
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.merchantId != null">
|
||||
AND a.merchant_id = #{param.merchantId}
|
||||
</if>
|
||||
<if test="param.projectId != null">
|
||||
AND a.project_id = #{param.projectId}
|
||||
</if>
|
||||
<if test="param.lang != null">
|
||||
AND a.lang LIKE CONCAT('%', #{param.lang}, '%')
|
||||
</if>
|
||||
<if test="param.langArticleId != null">
|
||||
AND a.lang_article_id = #{param.langArticleId}
|
||||
</if>
|
||||
<if test="param.translation != null">
|
||||
AND a.translation = #{param.translation}
|
||||
</if>
|
||||
<if test="param.editor != null">
|
||||
AND a.editor = #{param.editor}
|
||||
</if>
|
||||
<if test="param.pdfUrl != null">
|
||||
AND a.pdf_url LIKE CONCAT('%', #{param.pdfUrl}, '%')
|
||||
</if>
|
||||
<if test="param.version != null">
|
||||
AND a.version = #{param.version}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.comments != null">
|
||||
AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.ShopArticle">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.ShopArticle">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
207
src/main/java/com/gxwebsoft/shop/param/ShopArticleParam.java
Normal file
207
src/main/java/com/gxwebsoft/shop/param/ShopArticleParam.java
Normal file
@@ -0,0 +1,207 @@
|
||||
package com.gxwebsoft.shop.param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 商品文章查询参数
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-13 00:28:23
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Schema(name = "ShopArticleParam对象", description = "商品文章查询参数")
|
||||
public class ShopArticleParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "文章ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer articleId;
|
||||
|
||||
@Schema(description = "文章标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "文章类型 0常规 1视频")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "模型")
|
||||
private String model;
|
||||
|
||||
@Schema(description = "详情页模板")
|
||||
private String detail;
|
||||
|
||||
@Schema(description = "文章分类ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer categoryId;
|
||||
|
||||
@Schema(description = "上级id, 0是顶级")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer parentId;
|
||||
|
||||
@Schema(description = "话题")
|
||||
private String topic;
|
||||
|
||||
@Schema(description = "标签")
|
||||
private String tags;
|
||||
|
||||
@Schema(description = "封面图")
|
||||
private String image;
|
||||
|
||||
@Schema(description = "封面图宽")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer imageWidth;
|
||||
|
||||
@Schema(description = "封面图高")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer imageHeight;
|
||||
|
||||
@Schema(description = "付费金额")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private BigDecimal price;
|
||||
|
||||
@Schema(description = "开始时间")
|
||||
private String startTime;
|
||||
|
||||
@Schema(description = "结束时间")
|
||||
private String endTime;
|
||||
|
||||
@Schema(description = "来源")
|
||||
private String source;
|
||||
|
||||
@Schema(description = "产品概述")
|
||||
private String overview;
|
||||
|
||||
@Schema(description = "虚拟阅读量(仅用作展示)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer virtualViews;
|
||||
|
||||
@Schema(description = "实际阅读量")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer actualViews;
|
||||
|
||||
@Schema(description = "评分")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private BigDecimal rate;
|
||||
|
||||
@Schema(description = "列表显示方式(10小图展示 20大图展示)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer showType;
|
||||
|
||||
@Schema(description = "访问密码")
|
||||
private String password;
|
||||
|
||||
@Schema(description = "可见类型 0所有人 1登录可见 2密码可见")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer permission;
|
||||
|
||||
@Schema(description = "发布来源客户端 (APP、H5、小程序等)")
|
||||
private String platform;
|
||||
|
||||
@Schema(description = "文章附件")
|
||||
private String files;
|
||||
|
||||
@Schema(description = "视频地址")
|
||||
private String video;
|
||||
|
||||
@Schema(description = "接受的文件类型")
|
||||
private String accept;
|
||||
|
||||
@Schema(description = "经度")
|
||||
private String longitude;
|
||||
|
||||
@Schema(description = "纬度")
|
||||
private String latitude;
|
||||
|
||||
@Schema(description = "所在省份")
|
||||
private String province;
|
||||
|
||||
@Schema(description = "所在城市")
|
||||
private String city;
|
||||
|
||||
@Schema(description = "所在辖区")
|
||||
private String region;
|
||||
|
||||
@Schema(description = "街道地址")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "点赞数")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer likes;
|
||||
|
||||
@Schema(description = "评论数")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer commentNumbers;
|
||||
|
||||
@Schema(description = "提醒谁看")
|
||||
private String toUsers;
|
||||
|
||||
@Schema(description = "作者")
|
||||
private String author;
|
||||
|
||||
@Schema(description = "推荐")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer recommend;
|
||||
|
||||
@Schema(description = "报名人数")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer bmUsers;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "商户ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Long merchantId;
|
||||
|
||||
@Schema(description = "项目ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer projectId;
|
||||
|
||||
@Schema(description = "语言")
|
||||
private String lang;
|
||||
|
||||
@Schema(description = "关联默认语言的文章ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer langArticleId;
|
||||
|
||||
@Schema(description = "是否自动翻译")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Boolean translation;
|
||||
|
||||
@Schema(description = "编辑器类型 0 Markdown编辑器 1 富文本编辑器 ")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Boolean editor;
|
||||
|
||||
@Schema(description = "pdf文件地址")
|
||||
private String pdfUrl;
|
||||
|
||||
@Schema(description = "版本号")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer version;
|
||||
|
||||
@Schema(description = "排序(数字越小越靠前)")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String comments;
|
||||
|
||||
@Schema(description = "状态, 0已发布, 1待审核 2已驳回 3违规内容")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gxwebsoft.shop.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.shop.entity.ShopArticle;
|
||||
import com.gxwebsoft.shop.param.ShopArticleParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品文章Service
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-13 00:28:23
|
||||
*/
|
||||
public interface ShopArticleService extends IService<ShopArticle> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<ShopArticle>
|
||||
*/
|
||||
PageResult<ShopArticle> pageRel(ShopArticleParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<ShopArticle>
|
||||
*/
|
||||
List<ShopArticle> listRel(ShopArticleParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param articleId 文章ID
|
||||
* @return ShopArticle
|
||||
*/
|
||||
ShopArticle getByIdRel(Integer articleId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.shop.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.shop.mapper.ShopArticleMapper;
|
||||
import com.gxwebsoft.shop.service.ShopArticleService;
|
||||
import com.gxwebsoft.shop.entity.ShopArticle;
|
||||
import com.gxwebsoft.shop.param.ShopArticleParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品文章Service实现
|
||||
*
|
||||
* @author 科技小王子
|
||||
* @since 2025-08-13 00:28:23
|
||||
*/
|
||||
@Service
|
||||
public class ShopArticleServiceImpl extends ServiceImpl<ShopArticleMapper, ShopArticle> implements ShopArticleService {
|
||||
|
||||
@Override
|
||||
public PageResult<ShopArticle> pageRel(ShopArticleParam param) {
|
||||
PageParam<ShopArticle, ShopArticleParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<ShopArticle> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopArticle> listRel(ShopArticleParam param) {
|
||||
List<ShopArticle> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<ShopArticle, ShopArticleParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopArticle getByIdRel(Integer articleId) {
|
||||
ShopArticleParam param = new ShopArticleParam();
|
||||
param.setArticleId(articleId);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,6 +13,11 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
* CMS模块-代码生成工具
|
||||
@@ -56,7 +61,7 @@ public class CmsGenerator {
|
||||
// "cms_docs_book",
|
||||
// "cms_docs_content",
|
||||
// "cms_ad",
|
||||
"cms_ad_record",
|
||||
// "cms_ad_record",
|
||||
// "cms_navigation",
|
||||
// "cms_design",
|
||||
// "cms_design_record",
|
||||
@@ -315,6 +320,87 @@ public class CmsGenerator {
|
||||
mpg.setCfg(cfg);
|
||||
|
||||
mpg.execute();
|
||||
|
||||
// 自动更新 app.config.ts
|
||||
updateAppConfig(TABLE_NAMES, MODULE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动更新 app.config.ts 文件,添加新生成的页面路径
|
||||
*/
|
||||
private static void updateAppConfig(String[] tableNames, String moduleName) {
|
||||
String appConfigPath = OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE + "/app.config.ts";
|
||||
|
||||
try {
|
||||
// 读取原文件内容
|
||||
String content = new String(Files.readAllBytes(Paths.get(appConfigPath)));
|
||||
|
||||
// 为每个表生成页面路径
|
||||
StringBuilder newPages = new StringBuilder();
|
||||
for (String tableName : tableNames) {
|
||||
String entityPath = tableName.replaceAll("_", "");
|
||||
// 转换为驼峰命名
|
||||
String[] parts = tableName.split("_");
|
||||
StringBuilder camelCase = new StringBuilder(parts[0]);
|
||||
for (int i = 1; i < parts.length; i++) {
|
||||
camelCase.append(parts[i].substring(0, 1).toUpperCase()).append(parts[i].substring(1));
|
||||
}
|
||||
entityPath = camelCase.toString();
|
||||
|
||||
newPages.append(" '").append(entityPath).append("/index',\n");
|
||||
newPages.append(" '").append(entityPath).append("/add',\n");
|
||||
}
|
||||
|
||||
// 查找对应模块的子包配置
|
||||
String modulePattern = "\"root\":\\s*\"" + moduleName + "\",\\s*\"pages\":\\s*\\[([^\\]]*)]";
|
||||
Pattern pattern = Pattern.compile(modulePattern, Pattern.DOTALL);
|
||||
Matcher matcher = pattern.matcher(content);
|
||||
|
||||
if (matcher.find()) {
|
||||
String existingPages = matcher.group(1);
|
||||
|
||||
// 检查页面是否已存在,避免重复添加
|
||||
boolean needUpdate = false;
|
||||
String[] newPageArray = newPages.toString().split("\n");
|
||||
for (String newPage : newPageArray) {
|
||||
if (!newPage.trim().isEmpty() && !existingPages.contains(newPage.trim().replace(" ", "").replace(",", ""))) {
|
||||
needUpdate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (needUpdate) {
|
||||
// 备份原文件
|
||||
String backupPath = appConfigPath + ".backup." + System.currentTimeMillis();
|
||||
Files.copy(Paths.get(appConfigPath), Paths.get(backupPath));
|
||||
System.out.println("已备份原文件到: " + backupPath);
|
||||
|
||||
// 在现有页面列表末尾添加新页面
|
||||
String updatedPages = existingPages.trim();
|
||||
if (!updatedPages.endsWith(",")) {
|
||||
updatedPages += ",";
|
||||
}
|
||||
updatedPages += "\n" + newPages.toString().trim();
|
||||
|
||||
// 替换内容
|
||||
String updatedContent = content.replace(matcher.group(1), updatedPages);
|
||||
|
||||
// 写入更新后的内容
|
||||
Files.write(Paths.get(appConfigPath), updatedContent.getBytes());
|
||||
|
||||
System.out.println("✅ 已自动更新 app.config.ts,添加了以下页面路径:");
|
||||
System.out.println(newPages.toString());
|
||||
} else {
|
||||
System.out.println("ℹ️ app.config.ts 中已包含所有页面路径,无需更新");
|
||||
}
|
||||
} else {
|
||||
System.out.println("⚠️ 未找到 " + moduleName + " 模块的子包配置,请手动添加页面路径");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("❌ 更新 app.config.ts 失败: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
/**
|
||||
* CMS模块-代码生成工具
|
||||
@@ -100,6 +105,7 @@ public class ShopGenerator {
|
||||
// "shop_express_template",
|
||||
// "shop_express_template_detail",
|
||||
// "shop_gift"
|
||||
"shop_article"
|
||||
};
|
||||
// 需要去除的表前缀
|
||||
private static final String[] TABLE_PREFIX = new String[]{
|
||||
@@ -343,6 +349,87 @@ public class ShopGenerator {
|
||||
mpg.setCfg(cfg);
|
||||
|
||||
mpg.execute();
|
||||
|
||||
// 自动更新 app.config.ts
|
||||
updateAppConfig(TABLE_NAMES, MODULE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动更新 app.config.ts 文件,添加新生成的页面路径
|
||||
*/
|
||||
private static void updateAppConfig(String[] tableNames, String moduleName) {
|
||||
String appConfigPath = OUTPUT_LOCATION_UNIAPP + OUTPUT_DIR_VUE + "/app.config.ts";
|
||||
|
||||
try {
|
||||
// 读取原文件内容
|
||||
String content = new String(Files.readAllBytes(Paths.get(appConfigPath)));
|
||||
|
||||
// 为每个表生成页面路径
|
||||
StringBuilder newPages = new StringBuilder();
|
||||
for (String tableName : tableNames) {
|
||||
String entityPath = tableName.replaceAll("_", "");
|
||||
// 转换为驼峰命名
|
||||
String[] parts = tableName.split("_");
|
||||
StringBuilder camelCase = new StringBuilder(parts[0]);
|
||||
for (int i = 1; i < parts.length; i++) {
|
||||
camelCase.append(parts[i].substring(0, 1).toUpperCase()).append(parts[i].substring(1));
|
||||
}
|
||||
entityPath = camelCase.toString();
|
||||
|
||||
newPages.append(" '").append(entityPath).append("/index',\n");
|
||||
newPages.append(" '").append(entityPath).append("/add',\n");
|
||||
}
|
||||
|
||||
// 查找对应模块的子包配置
|
||||
String modulePattern = "\"root\":\\s*\"" + moduleName + "\",\\s*\"pages\":\\s*\\[([^\\]]*)]";
|
||||
Pattern pattern = Pattern.compile(modulePattern, Pattern.DOTALL);
|
||||
Matcher matcher = pattern.matcher(content);
|
||||
|
||||
if (matcher.find()) {
|
||||
String existingPages = matcher.group(1);
|
||||
|
||||
// 检查页面是否已存在,避免重复添加
|
||||
boolean needUpdate = false;
|
||||
String[] newPageArray = newPages.toString().split("\n");
|
||||
for (String newPage : newPageArray) {
|
||||
if (!newPage.trim().isEmpty() && !existingPages.contains(newPage.trim().replace(" ", "").replace(",", ""))) {
|
||||
needUpdate = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (needUpdate) {
|
||||
// 备份原文件
|
||||
String backupPath = appConfigPath + ".backup." + System.currentTimeMillis();
|
||||
Files.copy(Paths.get(appConfigPath), Paths.get(backupPath));
|
||||
System.out.println("已备份原文件到: " + backupPath);
|
||||
|
||||
// 在现有页面列表末尾添加新页面
|
||||
String updatedPages = existingPages.trim();
|
||||
if (!updatedPages.endsWith(",")) {
|
||||
updatedPages += ",";
|
||||
}
|
||||
updatedPages += "\n" + newPages.toString().trim();
|
||||
|
||||
// 替换内容
|
||||
String updatedContent = content.replace(matcher.group(1), updatedPages);
|
||||
|
||||
// 写入更新后的内容
|
||||
Files.write(Paths.get(appConfigPath), updatedContent.getBytes());
|
||||
|
||||
System.out.println("✅ 已自动更新 app.config.ts,添加了以下页面路径:");
|
||||
System.out.println(newPages.toString());
|
||||
} else {
|
||||
System.out.println("ℹ️ app.config.ts 中已包含所有页面路径,无需更新");
|
||||
}
|
||||
} else {
|
||||
System.out.println("⚠️ 未找到 " + moduleName + " 模块的子包配置,请手动添加页面路径");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("❌ 更新 app.config.ts 失败: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '新增${table.comment!}',
|
||||
navigationBarTitleText: '新增${table.comment!'数据'}',
|
||||
navigationBarTextStyle: 'black'
|
||||
})
|
||||
|
||||
@@ -36,7 +36,7 @@ const Add${entity} = () => {
|
||||
}
|
||||
|
||||
Taro.showToast({
|
||||
title: `${params.id ? '更新' : '保存'}成功`,
|
||||
title: `操作成功`,
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
@@ -45,7 +45,7 @@ const Add${entity} = () => {
|
||||
}, 1000)
|
||||
} catch (error) {
|
||||
Taro.showToast({
|
||||
title: `${params.id ? '更新' : '保存'}失败`,
|
||||
title: `操作失败`,
|
||||
icon: 'error'
|
||||
});
|
||||
}
|
||||
@@ -97,11 +97,11 @@ const Add${entity} = () => {
|
||||
<CellGroup style={{padding: '4px 0'}}>
|
||||
<% for(field in table.fields){ %>
|
||||
<% if(field.propertyName != 'id' && field.propertyName != 'createTime' && field.propertyName != 'updateTime'){ %>
|
||||
<Form.Item name="${field.propertyName}" label="${field.comment!}" initialValue={FormData.${field.propertyName}} required>
|
||||
<% if(field.propertyType == 'String' && (field.comment?contains('描述') || field.comment?contains('备注') || field.comment?contains('内容'))){ %>
|
||||
<TextArea maxLength={200} placeholder="请输入${field.comment!}"/>
|
||||
<Form.Item name="${field.propertyName}" label="${field.comment!field.propertyName}" initialValue={FormData.${field.propertyName}} required>
|
||||
<% if(field.propertyType == 'String' && field.comment?? && (field.comment?contains('描述') || field.comment?contains('备注') || field.comment?contains('内容'))){ %>
|
||||
<TextArea maxLength={200} placeholder="请输入${field.comment!'内容'}"/>
|
||||
<% } else { %>
|
||||
<Input placeholder="请输入${field.comment!}" maxLength={50}/>
|
||||
<Input placeholder="请输入${field.comment!'字段'}" maxLength={50}/>
|
||||
<% } %>
|
||||
</Form.Item>
|
||||
<% } %>
|
||||
|
||||
@@ -131,11 +131,19 @@ public class ${table.controllerName} {
|
||||
<% } %>
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ${entity} ${table.entityPath}) {
|
||||
<% var hasUserIdField = false; %>
|
||||
<% for(field in table.fields){ %>
|
||||
<% if(field.propertyName == 'userId'){ %>
|
||||
<% hasUserIdField = true; %>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if(hasUserIdField){ %>
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
${table.entityPath}.setUserId(loginUser.getUserId());
|
||||
}
|
||||
<% } %>
|
||||
if (${serviceIns}.save(${table.entityPath})) {
|
||||
return success("添加成功");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default definePageConfig({
|
||||
navigationBarTitleText: '${table.comment!}管理',
|
||||
navigationBarTitleText: '${table.comment!'数据'}管理',
|
||||
navigationBarTextStyle: 'black'
|
||||
})
|
||||
|
||||
@@ -8,7 +8,15 @@ import {list${entity}, remove${entity}, update${entity}} from "@/api/${package.M
|
||||
|
||||
const ${entity}List = () => {
|
||||
const [list, setList] = useState<${entity}[]>([])
|
||||
<% var hasIsDefaultField = false; %>
|
||||
<% for(field in table.fields){ %>
|
||||
<% if(field.propertyName == 'isDefault'){ %>
|
||||
<% hasIsDefaultField = true; %>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if(hasIsDefaultField){ %>
|
||||
const [selectedItem, setSelectedItem] = useState<${entity}>()
|
||||
<% } %>
|
||||
|
||||
const reload = () => {
|
||||
list${entity}({
|
||||
@@ -16,8 +24,10 @@ const ${entity}List = () => {
|
||||
})
|
||||
.then(data => {
|
||||
setList(data || [])
|
||||
<% if(hasIsDefaultField){ %>
|
||||
// 设置默认选中项
|
||||
setSelectedItem(data.find(item => item.isDefault))
|
||||
<% } %>
|
||||
})
|
||||
.catch(() => {
|
||||
Taro.showToast({
|
||||
@@ -27,6 +37,7 @@ const ${entity}List = () => {
|
||||
})
|
||||
}
|
||||
|
||||
<% if(hasIsDefaultField){ %>
|
||||
const onDefault = async (item: ${entity}) => {
|
||||
if (selectedItem) {
|
||||
await update${entity}({
|
||||
@@ -45,15 +56,6 @@ const ${entity}List = () => {
|
||||
reload();
|
||||
}
|
||||
|
||||
const onDel = async (id?: number) => {
|
||||
await remove${entity}(id)
|
||||
Taro.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'success'
|
||||
});
|
||||
reload();
|
||||
}
|
||||
|
||||
const selectItem = async (item: ${entity}) => {
|
||||
if (selectedItem) {
|
||||
await update${entity}({
|
||||
@@ -69,6 +71,18 @@ const ${entity}List = () => {
|
||||
Taro.navigateBack()
|
||||
},500)
|
||||
}
|
||||
<% } %>
|
||||
|
||||
const onDel = async (id?: number) => {
|
||||
await remove${entity}(id)
|
||||
Taro.showToast({
|
||||
title: '删除成功',
|
||||
icon: 'success'
|
||||
});
|
||||
reload();
|
||||
}
|
||||
|
||||
|
||||
|
||||
useDidShow(() => {
|
||||
reload()
|
||||
@@ -98,22 +112,38 @@ const ${entity}List = () => {
|
||||
<>
|
||||
{list.map((item, _) => (
|
||||
<Cell.Group key={item.id}>
|
||||
<% if(hasIsDefaultField){ %>
|
||||
<Cell className={'flex flex-col gap-1'} onClick={() => selectItem(item)}>
|
||||
<% } else { %>
|
||||
<Cell className={'flex flex-col gap-1'}>
|
||||
<% } %>
|
||||
<View>
|
||||
<View className={'font-medium text-sm'}>{item.name}</View>
|
||||
<% var displayFields = []; %>
|
||||
<% for(field in table.fields){ %>
|
||||
<% if(field.propertyName != 'id' && field.propertyName != 'createTime' && field.propertyName != 'updateTime' && field.propertyName != 'isDefault'){ %>
|
||||
<% displayFields.add(field); %>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if(displayFields.size() > 0){ %>
|
||||
<View className={'font-medium text-sm'}>{item.${displayFields[0].propertyName}}</View>
|
||||
<% } %>
|
||||
</View>
|
||||
<% if(displayFields.size() > 1){ %>
|
||||
<View className={'text-xs'}>
|
||||
{item.description}
|
||||
{item.${displayFields[1].propertyName}}
|
||||
</View>
|
||||
<% } %>
|
||||
</Cell>
|
||||
<Cell
|
||||
align="center"
|
||||
<% if(hasIsDefaultField){ %>
|
||||
title={
|
||||
<View className={'flex items-center gap-1'} onClick={() => onDefault(item)}>
|
||||
{item.isDefault ? <Checked className={'text-green-600'} size={16}/> : <CheckNormal size={16}/>}
|
||||
<View className={'text-gray-400'}>默认选项</View>
|
||||
</View>
|
||||
}
|
||||
<% } %>
|
||||
extra={
|
||||
<>
|
||||
<View className={'text-gray-400'} onClick={() => onDel(item.id)}>
|
||||
|
||||
Reference in New Issue
Block a user