wx.setStorageSync("_categoryId", category.id) wx.switchTab({ url: '/pages/category/category', })
时间: 2024-05-19 18:13:57 浏览: 158
The above code is used in a WeChat Mini Program to set a key-value pair in the local storage and then switch to a different tab.
Here, the key-value pair being set in the local storage is "_categoryId" and the value being set is the ID of a category.
After setting this value in the local storage, the code then switches to a different tab with the URL "/pages/category/category". This is likely a page that displays the products in the selected category.
Overall, this code is used to store the ID of a selected category and then navigate to the page displaying products in that category.
相关问题
SELECT a1.id, a1.name, a1.category_id as categoryId, a2.name as categoryName, a3.id as mgId, a4.id as mid, a4.maintenance_date as maintenanceDate FROM t_goods a1 LEFT JOIN t_goods_category a2 ON a2.id = a1.category_id LEFT JOIN t_maintenance_register_goods a3 ON a3.goods_id = a1.id LEFT JOIN t_maintenance_register a4 ON a4.id = a3.register_id WHERE a1.is_delete = 0 AND a1.is_scrap = 0 这个sql语句会出现重复,重复的记录a4.maintenance_date属性会不同,只保留最早的a4.maintenance_date 帮我改一下sql
你可以使用以下 SQL 语句来查询多个表中除了时间都重复的记录,并保留时间最早的那条:
```
SELECT a1.id, a1.name, a1.category_id AS categoryId, a2.name AS categoryName, a3.id AS mgId, a4.id AS mid, a4.maintenance_date AS maintenanceDate
FROM t_goods a1
LEFT JOIN t_goods_category a2 ON a2.id = a1.category_id
LEFT JOIN t_maintenance_register_goods a3 ON a3.goods_id = a1.id
LEFT JOIN (
SELECT t_maintenance_register_goods.register_id, MIN(t_maintenance_register.maintenance_date) AS maintenance_date
FROM t_maintenance_register_goods
LEFT JOIN t_maintenance_register ON t_maintenance_register.id = t_maintenance_register_goods.register_id
GROUP BY t_maintenance_register_goods.register_id
) a4 ON a4.register_id = a3.register_id
WHERE a1.is_delete = 0 AND a1.is_scrap = 0
```
这个语句会查询多个表,并且连接列 `category_id`、`goods_id` 和 `register_id`,并保留时间最早的那条记录。你需要根据实际情况修改列名和条件。
请帮我解释下面这段代码 <select id="listByUser" resultType="com.yj.model.vo.EnrollByUserItemVO"> select cc.*, cc.course_start_time AS courseStartTimeMd, ub.id ubid, info.payment_status as payment_status, info.total_money as totalMoney, ccc.category_name, CASE WHEN cc.course_video is not null and cc.course_video != '' THEN 2 WHEN (SELECT count(1) FROM crs_course_class ccc2 WHERE cc.id = ccc2.course_id AND ccc2.data_flag = 1 AND ccc2.class_video IS NOT NULL and ccc2.class_video != '') > 0 THEN 2 ELSE 1 END AS courseType from user_course_enroll ub INNER JOIN crs_course cc ON ub.course_id = cc.id INNER JOIN crs_course_category ccc ON cc.course_category_id = ccc.id LEFT JOIN order_item item ON item.project_relevancy_id = ub.id LEFT JOIN order_info info ON item.info_id = info.id LEFT JOIN user_browse uu ON uu.user_id = ub.user_id and uu.course_id = ub.course_id and uu.data_flag = 1 where 1 = 1 <if test="(publicId != null and publicId != '' ) or ( userIds != null and userIds.size() != 0)"> and ( <if test="publicId != null and publicId != '' "> ub.public_id = #{publicId} </if> <if test="publicId != null and publicId != '' and userIds != null and userIds.size() != 0"> or ub.user_id IN <foreach collection="userIds" item="item" open="(" separator="," close=")" index="index"> #{item} </foreach> </if> <if test="(publicId == null or publicId == '') and userIds != null and userIds.size() != 0"> ub.user_id IN <foreach collection="userIds" item="item" open="(" separator="," close=")" index="index"> #{item} </foreach> </if> ) </if> <choose> <when test="query.paymentStateList != null and query.paymentStateList.size() != 0"> and ccc.data_flag = 1 </when> <otherwise> and ub.apply_type = 1 and ccc.data_flag = 1 and ub.data_flag = 1 and ub.verify_state = 1 and cc.data_flag = 1 </otherwise> </choose> <if test="query.shelfStatus !=null"> and cc.shelf_status = #{query.shelfStatus} </if> <if test="query.categoryId !=null and query.categoryId != ''"> and ccc.id = #{query.categoryId} </if> <if test="query.learnState !=null"> and uu.learn_state = #{query.learnState} and ccc.prelect_way = 1 </if> <if test="query.paymentStateList != null and query.paymentStateList.size() != 0"> AND ( info.payment_status IN <foreach collection="query.paymentStateList" item="item" open="(" separator="," close=")" index="index"> #{item} </foreach> ) </if> </select>
这是一个 MyBatis 的 SQL 查询语句,通过 id 属性指定查询语句的名称为 "listByUser",通过 resultType 指定查询结果映射到 com.yj.model.vo.EnrollByUserItemVO 类型的实例对象中。
查询语句主要是通过多个表的连接查询,得到用户选课信息的详细数据。其中包括课程信息、课程分类信息、用户选课信息、订单信息等。查询条件根据用户传入的参数动态生成。在条件中使用了 if 和 foreach 标签,根据不同的情况生成不同的查询条件。
除此之外,查询语句中还使用了 choose 标签,根据不同的条件生成不同的查询条件,相当于 Java 中的 switch 语句。
最后,查询语句中还使用了 CASE WHEN 语法,根据不同的条件返回不同的结果。在这个查询语句中,根据课程是否有视频,以及课程下是否有班次有视频,分别标记课程类型为 2 或 1。
阅读全文