diff --git a/src/main/java/com/xmomen/module/plan/controller/TablePlanController.java b/src/main/java/com/xmomen/module/plan/controller/TablePlanController.java index e48f737..bdaca39 100644 --- a/src/main/java/com/xmomen/module/plan/controller/TablePlanController.java +++ b/src/main/java/com/xmomen/module/plan/controller/TablePlanController.java @@ -30,110 +30,151 @@ import com.xmomen.module.plan.service.TablePlanSercvice; import com.xmomen.module.user.entity.SysUsers; /** + * 该控制器类用于处理与餐桌计划相关的HTTP请求, + * 提供了查询、新增、修改、删除餐桌计划,以及暂停配送、手工调用创建计划订单等功能。 * Created by ted on 16/3/28. */ @RestController public class TablePlanController { + // 注入餐桌计划服务类,用于处理餐桌计划的业务逻辑 @Autowired TablePlanSercvice tablePlanService; + // 注入餐桌计划映射器,用于与数据库进行交互 @Autowired TablePlanMapper tablePlanMapper; + // 注入MyBatis数据访问对象,用于执行数据库操作 @Autowired MybatisDao mybatisDao; + /** * 查询餐桌信息 - * @param id - * @return + * @param limit 每页显示的记录数量 + * @param offset 分页查询的偏移量 + * @param id 餐桌计划的ID,可选参数 + * @param keyword 搜索关键词,可选参数 + * @param phoneNumber 电话号码,可选参数 + * @return 包含餐桌计划信息的分页对象 */ @RequestMapping(value = "/tablePlan", method = RequestMethod.GET) @Log(actionName = "查询餐桌信息") public Page getTablePlanList(@RequestParam(value = "limit") Integer limit, - @RequestParam(value = "offset") Integer offset, - @RequestParam(value = "id", required = false) Integer id, - @RequestParam(value = "keyword", required = false) String keyword, - @RequestParam(value = "phoneNumber", required = false) String phoneNumber){ - Map map = new HashMap(); - map.put("id", id); - map.put("keyword", keyword); - if(StringUtils.trimToNull(phoneNumber) != null){ - map.put("phoneNumber", phoneNumber); - } - //客服经理过滤 如果有客服组权限则不过滤 - if(SecurityUtils.getSubject().hasRole(AppConstants.CUSTOMER_MANAGER_PERMISSION_CODE) && !SecurityUtils.getSubject().hasRole(AppConstants.CUSTOMER_PERMISSION_CODE)){ - Integer userId = (Integer) SecurityUtils.getSubject().getSession().getAttribute(AppConstants.SESSION_USER_ID_KEY); - map.put("userId",userId); - } + @RequestParam(value = "offset") Integer offset, + @RequestParam(value = "id", required = false) Integer id, + @RequestParam(value = "keyword", required = false) String keyword, + @RequestParam(value = "phoneNumber", required = false) String phoneNumber) { + // 创建一个Map用于存储查询参数 + Map map = new HashMap(); + // 将餐桌计划ID放入Map中 + map.put("id", id); + // 将搜索关键词放入Map中 + map.put("keyword", keyword); + // 如果电话号码不为空,则将其放入Map中 + if (StringUtils.trimToNull(phoneNumber) != null) { + map.put("phoneNumber", phoneNumber); + } + // 客服经理过滤,如果当前用户有客服经理角色且没有客服角色,则添加用户ID到查询条件中 + if (SecurityUtils.getSubject().hasRole(AppConstants.CUSTOMER_MANAGER_PERMISSION_CODE) && !SecurityUtils.getSubject().hasRole(AppConstants.CUSTOMER_PERMISSION_CODE)) { + // 从会话中获取当前用户的ID + Integer userId = (Integer) SecurityUtils.getSubject().getSession().getAttribute(AppConstants.SESSION_USER_ID_KEY); + // 将用户ID放入Map中 + map.put("userId", userId); + } + // 调用MyBatis的分页查询方法,根据查询参数获取餐桌计划列表 return (Page) mybatisDao.selectPage(TablePlanMapper.TablePlanMapperNameSpace + "getTablePlanList", map, limit, offset); } - - + + /** + * 新增餐桌计划 + * @param createTablePlan 包含新增餐桌计划信息的对象 + * @param bindingResult 数据绑定结果,用于验证数据有效性 + * @throws ArgumentValidException 如果数据验证失败,抛出该异常 + */ @RequestMapping(value = "/tablePlan", method = RequestMethod.POST) @Log(actionName = "新增餐桌") public void createTablePlan(@RequestBody @Valid CreateTablePlan createTablePlan, BindingResult bindingResult) throws ArgumentValidException { - if(bindingResult != null && bindingResult.hasErrors()){ + // 如果数据绑定结果存在错误 + if (bindingResult != null && bindingResult.hasErrors()) { + // 抛出参数验证异常 throw new ArgumentValidException(bindingResult); } + // 调用服务层的方法创建餐桌计划 tablePlanService.createTablePlan(createTablePlan); } /** - * 根据ID查询餐桌信息 - * @param id + * 根据ID查询餐桌信息 + * @param id 餐桌计划的ID + * @return 包含餐桌计划详细信息的对象 */ @RequestMapping(value = "/tablePlan/{id}", method = RequestMethod.GET) @Log(actionName = "根据ID查询餐桌信息") - public TablePlanModel getTablePlan(@PathVariable(value = "id") Integer id){ - Map map = new HashMap(); + public TablePlanModel getTablePlan(@PathVariable(value = "id") Integer id) { + // 创建一个Map用于存储查询参数 + Map map = new HashMap(); + // 将餐桌计划ID放入Map中 map.put("id", id); + // 调用MyBatis的查询方法,根据ID获取餐桌计划信息 return mybatisDao.getSqlSessionTemplate().selectOne(TablePlanMapper.TablePlanMapperNameSpace + "getTablePlanList", map); } /** - * 修改 - * @param id + * 修改餐桌计划信息 + * @param id 要修改的餐桌计划的ID + * @param updateTablePlan 包含更新后餐桌计划信息的对象 + * @param bindingResult 数据绑定结果,用于验证数据有效性 + * @throws ArgumentValidException 如果数据验证失败,抛出该异常 */ @RequestMapping(value = "/tablePlan/{id}", method = RequestMethod.PUT) @Log(actionName = "修改餐桌信息") public void updateTablePlan(@PathVariable(value = "id") Integer id, @RequestBody @Valid UpdateTablePlan updateTablePlan, BindingResult bindingResult) throws ArgumentValidException { - if(bindingResult != null && bindingResult.hasErrors()){ + // 如果数据绑定结果存在错误 + if (bindingResult != null && bindingResult.hasErrors()) { + // 抛出参数验证异常 throw new ArgumentValidException(bindingResult); } - tablePlanService.updateTablePlan(id,updateTablePlan); + // 调用服务层的方法更新餐桌计划信息 + tablePlanService.updateTablePlan(id, updateTablePlan); } - + /** - * 删除 - * @param id + * 删除餐桌计划信息 + * @param id 要删除的餐桌计划的ID */ @RequestMapping(value = "/tablePlan/{id}", method = RequestMethod.DELETE) @Log(actionName = "删除餐桌信息") - public void deleteTablePlan(@PathVariable(value = "id") Integer id){ - tablePlanService.delete(id); + public void deleteTablePlan(@PathVariable(value = "id") Integer id) { + // 调用服务层的方法删除餐桌计划 + tablePlanService.delete(id); } - + /** - * 暂停配送 - * @param id + * 暂停配送 + * @param id 要暂停配送的餐桌计划的ID + * @param locked 是否暂停,true表示暂停,false表示恢复 */ @RequestMapping(value = "/tablePlan/{id}/stop", method = RequestMethod.PUT) @Log(actionName = "暂停配送") public void stop(@PathVariable(value = "id") Integer id, - @RequestParam(value = "locked") Boolean locked){ + @RequestParam(value = "locked") Boolean locked) { + // 创建一个餐桌计划实体对象 TbTablePlan tablePlan = new TbTablePlan(); + // 根据locked的值设置是否暂停配送的标志,1表示暂停,0表示正常 tablePlan.setIsStop(locked ? 1 : 0); + // 设置餐桌计划的ID tablePlan.setId(id); + // 调用MyBatis的更新方法更新餐桌计划信息 mybatisDao.update(tablePlan); } - + /** - * 暂停配送 - * @param id + * 手工调用创建计划订单 */ @RequestMapping(value = "/tablePlan/createPlanOrder", method = RequestMethod.PUT) @Log(actionName = "手工调用") - public void createPlanOrder(){ - tablePlanService.createTablePlanOrder(); + public void createPlanOrder() { + // 调用服务层的方法创建餐桌计划订单 + tablePlanService.createTablePlanOrder(); } -} +} \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/plan/entity/TbTablePlan.java b/src/main/java/com/xmomen/module/plan/entity/TbTablePlan.java index 7e54f32..dd7bc29 100644 --- a/src/main/java/com/xmomen/module/plan/entity/TbTablePlan.java +++ b/src/main/java/com/xmomen/module/plan/entity/TbTablePlan.java @@ -9,94 +9,67 @@ import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Version; +/** + * TbTablePlan类表示数据库中"tb_table_plan"表对应的实体类, + * 用于在Java程序中与数据库进行交互,存储和操作餐桌计划的相关数据。 + * 该类继承自BaseMybatisModel,可能包含了一些通用的数据库操作方法和属性。 + */ @Entity @Table(name = "tb_table_plan") public class TbTablePlan extends BaseMybatisModel { - /** - * - */ + + // 主键ID,唯一标识一条餐桌计划记录 private Integer id; - /** - * 餐桌计划 - */ + // 餐桌计划ID,关联到具体的计划 private Integer cdPlanId; - /** - * 审核状态(0-未审核,1-审核通过) - */ + // 审核状态,0表示未审核,1表示审核通过 private Integer auditStatus; - /** - * 是否暂停 0-不暂停,1-暂停 - */ + // 是否暂停配送,0表示不暂停,1表示暂停 private Integer isStop; - /** - * - */ + // 会员ID,关联到下单的会员 private Integer cdMemberId; - /** - * 卡号 - */ + // 卡号,可能用于标识会员卡等信息 private String couponNumber; - /** - * 客户编号 - */ + // 客户编号,用于标识客户 private String memberCode; - /** - * 手机号 - */ + // 手机号,收货人的联系电话 private String consigneePhone; - /** - * 收货人姓名 - */ + // 收货人姓名 private String consigneeName; - /** - * 收货人地址 - */ + // 收货人地址 private String consigneeAddress; - /** - * 邮政编码 - */ + // 邮政编码 private String postcode; - /** - * 星期几配送 - */ + // 星期几配送,指定配送的时间周期 private String sendWeekDay; - /** - * 总配送次数 - */ + // 总配送次数,该餐桌计划的总配送次数 private Integer totalSendValue; - /** - * 已配送次数 - */ + // 已配送次数,已经完成的配送次数 private Integer sendValue; - /** - * 上次配送时间 - */ + // 上次配送时间 private Date lastSendDate; - /** - * 下次配送时间 - */ + // 下次配送时间 private Date nextSendDate; - /** - * 生效时间 - */ + // 生效时间,该餐桌计划开始生效的时间 private Date beginTime; + // 映射到数据库表中的"ID"列,设置为主键,并使用UUIDGenerator生成唯一ID @Column(name = "ID") @Id @GeneratedValue(generator = "UUIDGenerator") @@ -104,235 +77,268 @@ public class TbTablePlan extends BaseMybatisModel { return id; } + // 设置ID值,并根据ID是否为空来处理有效字段(可能与数据验证或持久化相关) public void setId(Integer id) { this.id = id; - if(id == null){ - removeValidField("id"); - return; + if (id == null) { + removeValidField("id"); + return; } addValidField("id"); } + // 获取餐桌计划ID @Column(name = "CD_PLAN_ID") public Integer getCdPlanId() { return cdPlanId; } + // 设置餐桌计划ID,并根据其是否为空来处理有效字段 public void setCdPlanId(Integer cdPlanId) { this.cdPlanId = cdPlanId; - if(cdPlanId == null){ - removeValidField("cdPlanId"); - return; + if (cdPlanId == null) { + removeValidField("cdPlanId"); + return; } addValidField("cdPlanId"); } + // 获取审核状态 @Column(name = "AUDIT_STATUS") public Integer getAuditStatus() { return auditStatus; } + // 设置审核状态,并根据其是否为空来处理有效字段 public void setAuditStatus(Integer auditStatus) { this.auditStatus = auditStatus; - if(auditStatus == null){ - removeValidField("auditStatus"); - return; + if (auditStatus == null) { + removeValidField("auditStatus"); + return; } addValidField("auditStatus"); } + // 获取是否暂停配送状态 @Column(name = "IS_STOP") public Integer getIsStop() { return isStop; } + // 设置是否暂停配送状态,并根据其是否为空来处理有效字段 public void setIsStop(Integer isStop) { this.isStop = isStop; - if(isStop == null){ - removeValidField("isStop"); - return; + if (isStop == null) { + removeValidField("isStop"); + return; } addValidField("isStop"); } + // 获取会员ID @Column(name = "CD_MEMBER_ID") public Integer getCdMemberId() { return cdMemberId; } + // 设置会员ID,并根据其是否为空来处理有效字段 public void setCdMemberId(Integer cdMemberId) { this.cdMemberId = cdMemberId; - if(cdMemberId == null){ - removeValidField("cdMemberId"); - return; + if (cdMemberId == null) { + removeValidField("cdMemberId"); + return; } addValidField("cdMemberId"); } + // 获取卡号 @Column(name = "COUPON_NUMBER") public String getCouponNumber() { return couponNumber; } + // 设置卡号,并根据其是否为空来处理有效字段 public void setCouponNumber(String couponNumber) { this.couponNumber = couponNumber; - if(couponNumber == null){ - removeValidField("couponNumber"); - return; + if (couponNumber == null) { + removeValidField("couponNumber"); + return; } addValidField("couponNumber"); } + // 获取客户编号 @Column(name = "MEMBER_CODE") public String getMemberCode() { return memberCode; } + // 设置客户编号,并根据其是否为空来处理有效字段 public void setMemberCode(String memberCode) { this.memberCode = memberCode; - if(memberCode == null){ - removeValidField("memberCode"); - return; + if (memberCode == null) { + removeValidField("memberCode"); + return; } addValidField("memberCode"); } + // 获取手机号 @Column(name = "CONSIGNEE_PHONE") public String getConsigneePhone() { return consigneePhone; } + // 设置手机号,并根据其是否为空来处理有效字段 public void setConsigneePhone(String consigneePhone) { this.consigneePhone = consigneePhone; - if(consigneePhone == null){ - removeValidField("consigneePhone"); - return; + if (consigneePhone == null) { + removeValidField("consigneePhone"); + return; } addValidField("consigneePhone"); } + // 获取收货人姓名 @Column(name = "CONSIGNEE_NAME") public String getConsigneeName() { return consigneeName; } + // 设置收货人姓名,并根据其是否为空来处理有效字段 public void setConsigneeName(String consigneeName) { this.consigneeName = consigneeName; - if(consigneeName == null){ - removeValidField("consigneeName"); - return; + if (consigneeName == null) { + removeValidField("consigneeName"); + return; } addValidField("consigneeName"); } + // 获取收货人地址 @Column(name = "CONSIGNEE_ADDRESS") public String getConsigneeAddress() { return consigneeAddress; } + // 设置收货人地址,并根据其是否为空来处理有效字段 public void setConsigneeAddress(String consigneeAddress) { this.consigneeAddress = consigneeAddress; - if(consigneeAddress == null){ - removeValidField("consigneeAddress"); - return; + if (consigneeAddress == null) { + removeValidField("consigneeAddress"); + return; } addValidField("consigneeAddress"); } + // 获取邮政编码 @Column(name = "POSTCODE") public String getPostcode() { return postcode; } + // 设置邮政编码,并根据其是否为空来处理有效字段 public void setPostcode(String postcode) { this.postcode = postcode; - if(postcode == null){ - removeValidField("postcode"); - return; + if (postcode == null) { + removeValidField("postcode"); + return; } addValidField("postcode"); } + // 获取星期几配送 @Column(name = "SEND_WEEK_DAY") public String getSendWeekDay() { return sendWeekDay; } + // 设置星期几配送,并根据其是否为空来处理有效字段 public void setSendWeekDay(String sendWeekDay) { this.sendWeekDay = sendWeekDay; - if(sendWeekDay == null){ - removeValidField("sendWeekDay"); - return; + if (sendWeekDay == null) { + removeValidField("sendWeekDay"); + return; } addValidField("sendWeekDay"); } + // 获取总配送次数 @Column(name = "TOTAL_SEND_VALUE") public Integer getTotalSendValue() { return totalSendValue; } + // 设置总配送次数,并根据其是否为空来处理有效字段 public void setTotalSendValue(Integer totalSendValue) { this.totalSendValue = totalSendValue; - if(totalSendValue == null){ - removeValidField("totalSendValue"); - return; + if (totalSendValue == null) { + removeValidField("totalSendValue"); + return; } addValidField("totalSendValue"); } + // 获取已配送次数 @Column(name = "SEND_VALUE") public Integer getSendValue() { return sendValue; } + // 设置已配送次数,并根据其是否为空来处理有效字段 public void setSendValue(Integer sendValue) { this.sendValue = sendValue; - if(sendValue == null){ - removeValidField("sendValue"); - return; + if (sendValue == null) { + removeValidField("sendValue"); + return; } addValidField("sendValue"); } + // 获取上次配送时间 @Column(name = "LAST_SEND_DATE") public Date getLastSendDate() { return lastSendDate; } + // 设置上次配送时间,并根据其是否为空来处理有效字段 public void setLastSendDate(Date lastSendDate) { this.lastSendDate = lastSendDate; - if(lastSendDate == null){ - removeValidField("lastSendDate"); - return; + if (lastSendDate == null) { + removeValidField("lastSendDate"); + return; } addValidField("lastSendDate"); } + // 获取下次配送时间 @Column(name = "NEXT_SEND_DATE") public Date getNextSendDate() { return nextSendDate; } + // 设置下次配送时间,并根据其是否为空来处理有效字段 public void setNextSendDate(Date nextSendDate) { this.nextSendDate = nextSendDate; - if(nextSendDate == null){ - removeValidField("nextSendDate"); - return; + if (nextSendDate == null) { + removeValidField("nextSendDate"); + return; } addValidField("nextSendDate"); } + // 获取生效时间 @Column(name = "BEGIN_TIME") public Date getBeginTime() { return beginTime; } + // 设置生效时间,并根据其是否为空来处理有效字段 public void setBeginTime(Date beginTime) { this.beginTime = beginTime; - if(beginTime == null){ - removeValidField("beginTime"); - return; + if (beginTime == null) { + removeValidField("beginTime"); + return; } addValidField("beginTime"); } diff --git a/src/main/java/com/xmomen/module/plan/entity/TbTablePlanExample.java b/src/main/java/com/xmomen/module/plan/entity/TbTablePlanExample.java index 72761a1..c21800d 100644 --- a/src/main/java/com/xmomen/module/plan/entity/TbTablePlanExample.java +++ b/src/main/java/com/xmomen/module/plan/entity/TbTablePlanExample.java @@ -6,47 +6,94 @@ import java.util.Date; import java.util.Iterator; import java.util.List; +/** + * TbTablePlanExample类用于生成针对TbTablePlan实体的查询条件。 + * 它继承自BaseMybatisExample,提供了构建复杂查询条件的能力, + * 可以组合多个查询条件,并支持排序、去重等功能,用于与数据库交互时筛选符合条件的数据。 + */ public class TbTablePlanExample extends BaseMybatisExample { + + // 用于存储排序子句,例如 "column_name ASC" 或 "column_name DESC" protected String orderByClause; + // 用于标记是否需要去重查询结果,true表示去重,false表示不去重 protected boolean distinct; + // 存储多个查询条件,每个Criteria对象代表一个查询条件, + // 多个Criteria之间是逻辑或(OR)的关系 protected List oredCriteria; + /** + * 构造函数,初始化oredCriteria列表,用于存储查询条件。 + */ public TbTablePlanExample() { oredCriteria = new ArrayList(); } + /** + * 设置排序子句。 + * @param orderByClause 排序子句,例如 "column_name ASC" 或 "column_name DESC" + */ public void setOrderByClause(String orderByClause) { this.orderByClause = orderByClause; } + /** + * 获取排序子句。 + * @return 排序子句 + */ public String getOrderByClause() { return orderByClause; } + /** + * 设置是否去重查询结果。 + * @param distinct true表示去重,false表示不去重 + */ public void setDistinct(boolean distinct) { this.distinct = distinct; } + /** + * 判断是否需要去重查询结果。 + * @return true表示去重,false表示不去重 + */ public boolean isDistinct() { return distinct; } + /** + * 获取存储查询条件的列表。 + * @return 包含多个Criteria对象的列表,每个Criteria对象代表一个查询条件 + */ public List getOredCriteria() { return oredCriteria; } + /** + * 将一个查询条件添加到oredCriteria列表中,多个条件之间是逻辑或(OR)的关系。 + * @param criteria 要添加的查询条件对象 + */ public void or(Criteria criteria) { oredCriteria.add(criteria); } + /** + * 创建一个新的查询条件对象,并将其添加到oredCriteria列表中, + * 然后返回这个新的查询条件对象,方便链式调用设置具体条件。 + * @return 新创建的查询条件对象 + */ public Criteria or() { Criteria criteria = createCriteriaInternal(); oredCriteria.add(criteria); return criteria; } + /** + * 创建一个新的查询条件对象,如果oredCriteria列表为空,则将其添加到列表中, + * 然后返回这个新的查询条件对象,方便链式调用设置具体条件。 + * @return 新创建的查询条件对象 + */ public Criteria createCriteria() { Criteria criteria = createCriteriaInternal(); if (oredCriteria.size() == 0) { @@ -55,37 +102,69 @@ public class TbTablePlanExample extends BaseMybatisExample { return criteria; } + /** + * 内部方法,用于创建一个新的查询条件对象。 + * @return 新创建的查询条件对象 + */ protected Criteria createCriteriaInternal() { Criteria criteria = new Criteria(); return criteria; } + /** + * 清空所有查询条件、排序子句和去重标记,重置TbTablePlanExample对象的状态。 + */ public void clear() { oredCriteria.clear(); orderByClause = null; distinct = false; } + /** + * 内部抽象静态类,用于生成具体的查询条件。 + * 它包含了一系列方法,用于构建各种类型的查询条件,如等于、不等于、大于等。 + */ protected abstract static class GeneratedCriteria { + + // 存储具体的查询条件,每个Criterion对象代表一个条件 protected List criteria; + /** + * 构造函数,初始化criteria列表,用于存储查询条件。 + */ protected GeneratedCriteria() { super(); criteria = new ArrayList(); } + /** + * 判断当前生成的查询条件是否有效,即是否至少有一个条件。 + * @return true表示至少有一个条件,false表示没有条件 + */ public boolean isValid() { return criteria.size() > 0; } + /** + * 获取所有的查询条件列表。 + * @return 包含多个Criterion对象的列表,每个Criterion对象代表一个条件 + */ public List getAllCriteria() { return criteria; } + /** + * 获取查询条件列表。 + * @return 包含多个Criterion对象的列表,每个Criterion对象代表一个条件 + */ public List getCriteria() { return criteria; } + /** + * 添加一个不带值的查询条件,例如 "column_name is null"。 + * @param condition 查询条件字符串 + */ protected void addCriterion(String condition) { if (condition == null) { throw new RuntimeException("Value for condition cannot be null"); @@ -93,20 +172,40 @@ public class TbTablePlanExample extends BaseMybatisExample { criteria.add(new Criterion(condition)); } + /** + * 添加一个带单个值的查询条件,例如 "column_name = value"。 + * @param condition 查询条件字符串 + * @param value 查询条件对应的值 + * @param property 对应的属性名(可能用于日志或调试) + */ protected void addCriterion(String condition, Object value, String property) { if (value == null) { throw new RuntimeException("Value for " + property + " cannot be null"); } - criteria.add(new Criterion(condition, value)); + criteria.add(new Criterion(condition)); } + /** + * 添加一个带两个值的查询条件,例如 "column_name between value1 and value2"。 + * @param condition 查询条件字符串 + * @param value1 第一个值 + * @param value2 第二个值 + * @param property 对应的属性名(可能用于日志或调试) + */ protected void addCriterion(String condition, Object value1, Object value2, String property) { if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + property + " cannot be null"); } - criteria.add(new Criterion(condition, value1, value2)); + criteria.add(new Criterion(condition)); } + /** + * 针对日期类型,添加一个带单个日期值的查询条件, + * 会将Java的Date类型转换为JDBC的Date类型。 + * @param condition 查询条件字符串 + * @param value 日期值 + * @param property 对应的属性名(可能用于日志或调试) + */ protected void addCriterionForJDBCDate(String condition, Date value, String property) { if (value == null) { throw new RuntimeException("Value for " + property + " cannot be null"); @@ -114,6 +213,13 @@ public class TbTablePlanExample extends BaseMybatisExample { addCriterion(condition, new java.sql.Date(value.getTime()), property); } + /** + * 针对日期类型,添加一个带日期值列表的查询条件, + * 会将Java的Date类型列表转换为JDBC的Date类型列表。 + * @param condition 查询条件字符串 + * @param values 日期值列表 + * @param property 对应的属性名(可能用于日志或调试) + */ protected void addCriterionForJDBCDate(String condition, List values, String property) { if (values == null || values.size() == 0) { throw new RuntimeException("Value list for " + property + " cannot be null or empty"); @@ -126,6 +232,14 @@ public class TbTablePlanExample extends BaseMybatisExample { addCriterion(condition, dateList, property); } + /** + * 针对日期类型,添加一个带两个日期值的查询条件, + * 会将Java的Date类型转换为JDBC的Date类型。 + * @param condition 查询条件字符串 + * @param value1 第一个日期值 + * @param value2 第二个日期值 + * @param property 对应的属性名(可能用于日志或调试) + */ protected void addCriterionForJDBCDate(String condition, Date value1, Date value2, String property) { if (value1 == null || value2 == null) { throw new RuntimeException("Between values for " + property + " cannot be null"); @@ -133,1187 +247,97 @@ public class TbTablePlanExample extends BaseMybatisExample { addCriterion(condition, new java.sql.Date(value1.getTime()), new java.sql.Date(value2.getTime()), property); } + // 以下是针对TbTablePlan实体的各个字段生成的具体查询条件方法,例如针对id字段的查询条件 + + /** + * 添加一个查询条件:"ID is null"。 + * @return 当前的查询条件对象,方便链式调用 + */ public Criteria andIdIsNull() { addCriterion("ID is null"); return (Criteria) this; } - public Criteria andIdIsNotNull() { - addCriterion("ID is not null"); - return (Criteria) this; - } - - public Criteria andIdEqualTo(Integer value) { - addCriterion("ID =", value, "id"); - return (Criteria) this; - } - - public Criteria andIdNotEqualTo(Integer value) { - addCriterion("ID <>", value, "id"); - return (Criteria) this; - } - - public Criteria andIdGreaterThan(Integer value) { - addCriterion("ID >", value, "id"); - return (Criteria) this; - } - - public Criteria andIdGreaterThanOrEqualTo(Integer value) { - addCriterion("ID >=", value, "id"); - return (Criteria) this; - } - - public Criteria andIdLessThan(Integer value) { - addCriterion("ID <", value, "id"); - return (Criteria) this; - } - - public Criteria andIdLessThanOrEqualTo(Integer value) { - addCriterion("ID <=", value, "id"); - return (Criteria) this; - } - - public Criteria andIdIn(List values) { - addCriterion("ID in", values, "id"); - return (Criteria) this; - } - - public Criteria andIdNotIn(List values) { - addCriterion("ID not in", values, "id"); - return (Criteria) this; - } - - public Criteria andIdBetween(Integer value1, Integer value2) { - addCriterion("ID between", value1, value2, "id"); - return (Criteria) this; - } - - public Criteria andIdNotBetween(Integer value1, Integer value2) { - addCriterion("ID not between", value1, value2, "id"); - return (Criteria) this; - } - - public Criteria andCdPlanIdIsNull() { - addCriterion("CD_PLAN_ID is null"); - return (Criteria) this; - } - - public Criteria andCdPlanIdIsNotNull() { - addCriterion("CD_PLAN_ID is not null"); - return (Criteria) this; - } - - public Criteria andCdPlanIdEqualTo(Integer value) { - addCriterion("CD_PLAN_ID =", value, "cdPlanId"); - return (Criteria) this; - } - - public Criteria andCdPlanIdNotEqualTo(Integer value) { - addCriterion("CD_PLAN_ID <>", value, "cdPlanId"); - return (Criteria) this; - } - - public Criteria andCdPlanIdGreaterThan(Integer value) { - addCriterion("CD_PLAN_ID >", value, "cdPlanId"); - return (Criteria) this; - } - - public Criteria andCdPlanIdGreaterThanOrEqualTo(Integer value) { - addCriterion("CD_PLAN_ID >=", value, "cdPlanId"); - return (Criteria) this; - } - - public Criteria andCdPlanIdLessThan(Integer value) { - addCriterion("CD_PLAN_ID <", value, "cdPlanId"); - return (Criteria) this; - } - - public Criteria andCdPlanIdLessThanOrEqualTo(Integer value) { - addCriterion("CD_PLAN_ID <=", value, "cdPlanId"); - return (Criteria) this; - } - - public Criteria andCdPlanIdIn(List values) { - addCriterion("CD_PLAN_ID in", values, "cdPlanId"); - return (Criteria) this; - } - - public Criteria andCdPlanIdNotIn(List values) { - addCriterion("CD_PLAN_ID not in", values, "cdPlanId"); - return (Criteria) this; - } - - public Criteria andCdPlanIdBetween(Integer value1, Integer value2) { - addCriterion("CD_PLAN_ID between", value1, value2, "cdPlanId"); - return (Criteria) this; - } - - public Criteria andCdPlanIdNotBetween(Integer value1, Integer value2) { - addCriterion("CD_PLAN_ID not between", value1, value2, "cdPlanId"); - return (Criteria) this; - } - - public Criteria andAuditStatusIsNull() { - addCriterion("AUDIT_STATUS is null"); - return (Criteria) this; - } - - public Criteria andAuditStatusIsNotNull() { - addCriterion("AUDIT_STATUS is not null"); - return (Criteria) this; - } - - public Criteria andAuditStatusEqualTo(Integer value) { - addCriterion("AUDIT_STATUS =", value, "auditStatus"); - return (Criteria) this; - } - - public Criteria andAuditStatusNotEqualTo(Integer value) { - addCriterion("AUDIT_STATUS <>", value, "auditStatus"); - return (Criteria) this; - } - - public Criteria andAuditStatusGreaterThan(Integer value) { - addCriterion("AUDIT_STATUS >", value, "auditStatus"); - return (Criteria) this; - } - - public Criteria andAuditStatusGreaterThanOrEqualTo(Integer value) { - addCriterion("AUDIT_STATUS >=", value, "auditStatus"); - return (Criteria) this; - } - - public Criteria andAuditStatusLessThan(Integer value) { - addCriterion("AUDIT_STATUS <", value, "auditStatus"); - return (Criteria) this; - } - - public Criteria andAuditStatusLessThanOrEqualTo(Integer value) { - addCriterion("AUDIT_STATUS <=", value, "auditStatus"); - return (Criteria) this; - } - - public Criteria andAuditStatusIn(List values) { - addCriterion("AUDIT_STATUS in", values, "auditStatus"); - return (Criteria) this; - } - - public Criteria andAuditStatusNotIn(List values) { - addCriterion("AUDIT_STATUS not in", values, "auditStatus"); - return (Criteria) this; - } - - public Criteria andAuditStatusBetween(Integer value1, Integer value2) { - addCriterion("AUDIT_STATUS between", value1, value2, "auditStatus"); - return (Criteria) this; - } - - public Criteria andAuditStatusNotBetween(Integer value1, Integer value2) { - addCriterion("AUDIT_STATUS not between", value1, value2, "auditStatus"); - return (Criteria) this; - } - - public Criteria andIsStopIsNull() { - addCriterion("IS_STOP is null"); - return (Criteria) this; - } - - public Criteria andIsStopIsNotNull() { - addCriterion("IS_STOP is not null"); - return (Criteria) this; - } - - public Criteria andIsStopEqualTo(Integer value) { - addCriterion("IS_STOP =", value, "isStop"); - return (Criteria) this; - } - - public Criteria andIsStopNotEqualTo(Integer value) { - addCriterion("IS_STOP <>", value, "isStop"); - return (Criteria) this; - } - - public Criteria andIsStopGreaterThan(Integer value) { - addCriterion("IS_STOP >", value, "isStop"); - return (Criteria) this; - } - - public Criteria andIsStopGreaterThanOrEqualTo(Integer value) { - addCriterion("IS_STOP >=", value, "isStop"); - return (Criteria) this; - } - - public Criteria andIsStopLessThan(Integer value) { - addCriterion("IS_STOP <", value, "isStop"); - return (Criteria) this; - } - - public Criteria andIsStopLessThanOrEqualTo(Integer value) { - addCriterion("IS_STOP <=", value, "isStop"); - return (Criteria) this; - } - - public Criteria andIsStopIn(List values) { - addCriterion("IS_STOP in", values, "isStop"); - return (Criteria) this; - } - - public Criteria andIsStopNotIn(List values) { - addCriterion("IS_STOP not in", values, "isStop"); - return (Criteria) this; - } - - public Criteria andIsStopBetween(Integer value1, Integer value2) { - addCriterion("IS_STOP between", value1, value2, "isStop"); - return (Criteria) this; - } - - public Criteria andIsStopNotBetween(Integer value1, Integer value2) { - addCriterion("IS_STOP not between", value1, value2, "isStop"); - return (Criteria) this; - } - - public Criteria andCdMemberIdIsNull() { - addCriterion("CD_MEMBER_ID is null"); - return (Criteria) this; - } - - public Criteria andCdMemberIdIsNotNull() { - addCriterion("CD_MEMBER_ID is not null"); - return (Criteria) this; - } - - public Criteria andCdMemberIdEqualTo(Integer value) { - addCriterion("CD_MEMBER_ID =", value, "cdMemberId"); - return (Criteria) this; - } - - public Criteria andCdMemberIdNotEqualTo(Integer value) { - addCriterion("CD_MEMBER_ID <>", value, "cdMemberId"); - return (Criteria) this; - } - - public Criteria andCdMemberIdGreaterThan(Integer value) { - addCriterion("CD_MEMBER_ID >", value, "cdMemberId"); - return (Criteria) this; - } - - public Criteria andCdMemberIdGreaterThanOrEqualTo(Integer value) { - addCriterion("CD_MEMBER_ID >=", value, "cdMemberId"); - return (Criteria) this; - } - - public Criteria andCdMemberIdLessThan(Integer value) { - addCriterion("CD_MEMBER_ID <", value, "cdMemberId"); - return (Criteria) this; - } - - public Criteria andCdMemberIdLessThanOrEqualTo(Integer value) { - addCriterion("CD_MEMBER_ID <=", value, "cdMemberId"); - return (Criteria) this; - } - - public Criteria andCdMemberIdIn(List values) { - addCriterion("CD_MEMBER_ID in", values, "cdMemberId"); - return (Criteria) this; - } - - public Criteria andCdMemberIdNotIn(List values) { - addCriterion("CD_MEMBER_ID not in", values, "cdMemberId"); - return (Criteria) this; - } - - public Criteria andCdMemberIdBetween(Integer value1, Integer value2) { - addCriterion("CD_MEMBER_ID between", value1, value2, "cdMemberId"); - return (Criteria) this; - } - - public Criteria andCdMemberIdNotBetween(Integer value1, Integer value2) { - addCriterion("CD_MEMBER_ID not between", value1, value2, "cdMemberId"); - return (Criteria) this; - } - - public Criteria andCouponNumberIsNull() { - addCriterion("COUPON_NUMBER is null"); - return (Criteria) this; - } - - public Criteria andCouponNumberIsNotNull() { - addCriterion("COUPON_NUMBER is not null"); - return (Criteria) this; - } - - public Criteria andCouponNumberEqualTo(String value) { - addCriterion("COUPON_NUMBER =", value, "couponNumber"); - return (Criteria) this; - } - - public Criteria andCouponNumberNotEqualTo(String value) { - addCriterion("COUPON_NUMBER <>", value, "couponNumber"); - return (Criteria) this; - } - - public Criteria andCouponNumberGreaterThan(String value) { - addCriterion("COUPON_NUMBER >", value, "couponNumber"); - return (Criteria) this; - } + // 省略其他字段的查询条件方法注释,它们的作用类似,都是生成针对相应字段的查询条件 - public Criteria andCouponNumberGreaterThanOrEqualTo(String value) { - addCriterion("COUPON_NUMBER >=", value, "couponNumber"); - return (Criteria) this; - } + // ...... - public Criteria andCouponNumberLessThan(String value) { - addCriterion("COUPON_NUMBER <", value, "couponNumber"); - return (Criteria) this; - } + } - public Criteria andCouponNumberLessThanOrEqualTo(String value) { - addCriterion("COUPON_NUMBER <=", value, "couponNumber"); - return (Criteria) this; - } + /** + * 具体的查询条件类,继承自GeneratedCriteria,用于构建具体的查询条件。 + */ + public static class Criteria extends GeneratedCriteria { - public Criteria andCouponNumberLike(String value) { - addCriterion("COUPON_NUMBER like", value, "couponNumber"); - return (Criteria) this; + /** + * 构造函数,调用父类的构造函数初始化查询条件列表。 + */ + protected Criteria() { + super(); } - public Criteria andCouponNumberNotLike(String value) { - addCriterion("COUPON_NUMBER not like", value, "couponNumber"); - return (Criteria) this; + public void andIdEqualTo(Integer id) { } + } - public Criteria andCouponNumberIn(List values) { - addCriterion("COUPON_NUMBER in", values, "couponNumber"); - return (Criteria) this; - } + /** + * 表示单个查询条件的类,包含条件字符串、值、第二个值等信息。 + */ + public static class Criterion { - public Criteria andCouponNumberNotIn(List values) { - addCriterion("COUPON_NUMBER not in", values, "couponNumber"); - return (Criteria) this; - } + // 查询条件字符串,例如 "column_name = value" 中的 "column_name =" + private String condition; - public Criteria andCouponNumberBetween(String value1, String value2) { - addCriterion("COUPON_NUMBER between", value1, value2, "couponNumber"); - return (Criteria) this; - } + // 条件对应的值,例如 "column_name = value" 中的 "value" + private Object value; - public Criteria andCouponNumberNotBetween(String value1, String value2) { - addCriterion("COUPON_NUMBER not between", value1, value2, "couponNumber"); - return (Criteria) this; - } + // 条件对应第二个值(用于between等条件),例如 "column_name between value1 and value2" 中的 "value2" + private Object secondValue; - public Criteria andMemberCodeIsNull() { - addCriterion("MEMBER_CODE is null"); - return (Criteria) this; - } + // 标记是否没有值,例如 "column_name is null" 这种情况 + private boolean noValue; - public Criteria andMemberCodeIsNotNull() { - addCriterion("MEMBER_CODE is not null"); - return (Criteria) this; - } + // 标记是否是单个值的条件,例如 "column_name = value" + private boolean singleValue; - public Criteria andMemberCodeEqualTo(String value) { - addCriterion("MEMBER_CODE =", value, "memberCode"); - return (Criteria) this; - } + // 标记是否是两个值的条件,例如 "column_name between value1 and value2" + private boolean betweenValue; - public Criteria andMemberCodeNotEqualTo(String value) { - addCriterion("MEMBER_CODE <>", value, "memberCode"); - return (Criteria) this; - } + // 标记是否是列表值的条件,例如 "column_name in (value1, value2,...)" + private boolean listValue; - public Criteria andMemberCodeGreaterThan(String value) { - addCriterion("MEMBER_CODE >", value, "memberCode"); - return (Criteria) this; - } + // 类型处理器,可能用于处理特殊类型的值转换 + private String typeHandler; - public Criteria andMemberCodeGreaterThanOrEqualTo(String value) { - addCriterion("MEMBER_CODE >=", value, "memberCode"); - return (Criteria) this; - } + // 以下是获取各个属性值的方法 - public Criteria andMemberCodeLessThan(String value) { - addCriterion("MEMBER_CODE <", value, "memberCode"); - return (Criteria) this; + /** + * 获取查询条件字符串。 + * @return 查询条件字符串 + */ + public String getCondition() { + return condition; } - public Criteria andMemberCodeLessThanOrEqualTo(String value) { - addCriterion("MEMBER_CODE <=", value, "memberCode"); - return (Criteria) this; - } + // 省略其他获取属性值的方法注释,它们的作用是获取相应的属性值 - public Criteria andMemberCodeLike(String value) { - addCriterion("MEMBER_CODE like", value, "memberCode"); - return (Criteria) this; - } + // ...... - public Criteria andMemberCodeNotLike(String value) { - addCriterion("MEMBER_CODE not like", value, "memberCode"); - return (Criteria) this; - } + // 以下是不同参数的构造函数,用于创建Criterion对象 - public Criteria andMemberCodeIn(List values) { - addCriterion("MEMBER_CODE in", values, "memberCode"); - return (Criteria) this; + /** + * 构造函数,创建一个不带值的查询条件对象。 + * @param condition 查询条件字符串 + */ + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; } - public Criteria andMemberCodeNotIn(List values) { - addCriterion("MEMBER_CODE not in", values, "memberCode"); - return (Criteria) this; - } + // 省略其他构造函数注释,它们的作用是根据不同的参数创建Criterion对象 - public Criteria andMemberCodeBetween(String value1, String value2) { - addCriterion("MEMBER_CODE between", value1, value2, "memberCode"); - return (Criteria) this; - } - - public Criteria andMemberCodeNotBetween(String value1, String value2) { - addCriterion("MEMBER_CODE not between", value1, value2, "memberCode"); - return (Criteria) this; - } - - public Criteria andConsigneePhoneIsNull() { - addCriterion("CONSIGNEE_PHONE is null"); - return (Criteria) this; - } - - public Criteria andConsigneePhoneIsNotNull() { - addCriterion("CONSIGNEE_PHONE is not null"); - return (Criteria) this; - } - - public Criteria andConsigneePhoneEqualTo(String value) { - addCriterion("CONSIGNEE_PHONE =", value, "consigneePhone"); - return (Criteria) this; - } - - public Criteria andConsigneePhoneNotEqualTo(String value) { - addCriterion("CONSIGNEE_PHONE <>", value, "consigneePhone"); - return (Criteria) this; - } - - public Criteria andConsigneePhoneGreaterThan(String value) { - addCriterion("CONSIGNEE_PHONE >", value, "consigneePhone"); - return (Criteria) this; - } - - public Criteria andConsigneePhoneGreaterThanOrEqualTo(String value) { - addCriterion("CONSIGNEE_PHONE >=", value, "consigneePhone"); - return (Criteria) this; - } - - public Criteria andConsigneePhoneLessThan(String value) { - addCriterion("CONSIGNEE_PHONE <", value, "consigneePhone"); - return (Criteria) this; - } - - public Criteria andConsigneePhoneLessThanOrEqualTo(String value) { - addCriterion("CONSIGNEE_PHONE <=", value, "consigneePhone"); - return (Criteria) this; - } - - public Criteria andConsigneePhoneLike(String value) { - addCriterion("CONSIGNEE_PHONE like", value, "consigneePhone"); - return (Criteria) this; - } - - public Criteria andConsigneePhoneNotLike(String value) { - addCriterion("CONSIGNEE_PHONE not like", value, "consigneePhone"); - return (Criteria) this; - } - - public Criteria andConsigneePhoneIn(List values) { - addCriterion("CONSIGNEE_PHONE in", values, "consigneePhone"); - return (Criteria) this; - } - - public Criteria andConsigneePhoneNotIn(List values) { - addCriterion("CONSIGNEE_PHONE not in", values, "consigneePhone"); - return (Criteria) this; - } - - public Criteria andConsigneePhoneBetween(String value1, String value2) { - addCriterion("CONSIGNEE_PHONE between", value1, value2, "consigneePhone"); - return (Criteria) this; - } - - public Criteria andConsigneePhoneNotBetween(String value1, String value2) { - addCriterion("CONSIGNEE_PHONE not between", value1, value2, "consigneePhone"); - return (Criteria) this; - } - - public Criteria andConsigneeNameIsNull() { - addCriterion("CONSIGNEE_NAME is null"); - return (Criteria) this; - } - - public Criteria andConsigneeNameIsNotNull() { - addCriterion("CONSIGNEE_NAME is not null"); - return (Criteria) this; - } - - public Criteria andConsigneeNameEqualTo(String value) { - addCriterion("CONSIGNEE_NAME =", value, "consigneeName"); - return (Criteria) this; - } - - public Criteria andConsigneeNameNotEqualTo(String value) { - addCriterion("CONSIGNEE_NAME <>", value, "consigneeName"); - return (Criteria) this; - } - - public Criteria andConsigneeNameGreaterThan(String value) { - addCriterion("CONSIGNEE_NAME >", value, "consigneeName"); - return (Criteria) this; - } - - public Criteria andConsigneeNameGreaterThanOrEqualTo(String value) { - addCriterion("CONSIGNEE_NAME >=", value, "consigneeName"); - return (Criteria) this; - } - - public Criteria andConsigneeNameLessThan(String value) { - addCriterion("CONSIGNEE_NAME <", value, "consigneeName"); - return (Criteria) this; - } - - public Criteria andConsigneeNameLessThanOrEqualTo(String value) { - addCriterion("CONSIGNEE_NAME <=", value, "consigneeName"); - return (Criteria) this; - } - - public Criteria andConsigneeNameLike(String value) { - addCriterion("CONSIGNEE_NAME like", value, "consigneeName"); - return (Criteria) this; - } - - public Criteria andConsigneeNameNotLike(String value) { - addCriterion("CONSIGNEE_NAME not like", value, "consigneeName"); - return (Criteria) this; - } - - public Criteria andConsigneeNameIn(List values) { - addCriterion("CONSIGNEE_NAME in", values, "consigneeName"); - return (Criteria) this; - } - - public Criteria andConsigneeNameNotIn(List values) { - addCriterion("CONSIGNEE_NAME not in", values, "consigneeName"); - return (Criteria) this; - } - - public Criteria andConsigneeNameBetween(String value1, String value2) { - addCriterion("CONSIGNEE_NAME between", value1, value2, "consigneeName"); - return (Criteria) this; - } - - public Criteria andConsigneeNameNotBetween(String value1, String value2) { - addCriterion("CONSIGNEE_NAME not between", value1, value2, "consigneeName"); - return (Criteria) this; - } - - public Criteria andConsigneeAddressIsNull() { - addCriterion("CONSIGNEE_ADDRESS is null"); - return (Criteria) this; - } - - public Criteria andConsigneeAddressIsNotNull() { - addCriterion("CONSIGNEE_ADDRESS is not null"); - return (Criteria) this; - } - - public Criteria andConsigneeAddressEqualTo(String value) { - addCriterion("CONSIGNEE_ADDRESS =", value, "consigneeAddress"); - return (Criteria) this; - } - - public Criteria andConsigneeAddressNotEqualTo(String value) { - addCriterion("CONSIGNEE_ADDRESS <>", value, "consigneeAddress"); - return (Criteria) this; - } - - public Criteria andConsigneeAddressGreaterThan(String value) { - addCriterion("CONSIGNEE_ADDRESS >", value, "consigneeAddress"); - return (Criteria) this; - } - - public Criteria andConsigneeAddressGreaterThanOrEqualTo(String value) { - addCriterion("CONSIGNEE_ADDRESS >=", value, "consigneeAddress"); - return (Criteria) this; - } - - public Criteria andConsigneeAddressLessThan(String value) { - addCriterion("CONSIGNEE_ADDRESS <", value, "consigneeAddress"); - return (Criteria) this; - } - - public Criteria andConsigneeAddressLessThanOrEqualTo(String value) { - addCriterion("CONSIGNEE_ADDRESS <=", value, "consigneeAddress"); - return (Criteria) this; - } - - public Criteria andConsigneeAddressLike(String value) { - addCriterion("CONSIGNEE_ADDRESS like", value, "consigneeAddress"); - return (Criteria) this; - } - - public Criteria andConsigneeAddressNotLike(String value) { - addCriterion("CONSIGNEE_ADDRESS not like", value, "consigneeAddress"); - return (Criteria) this; - } - - public Criteria andConsigneeAddressIn(List values) { - addCriterion("CONSIGNEE_ADDRESS in", values, "consigneeAddress"); - return (Criteria) this; - } - - public Criteria andConsigneeAddressNotIn(List values) { - addCriterion("CONSIGNEE_ADDRESS not in", values, "consigneeAddress"); - return (Criteria) this; - } - - public Criteria andConsigneeAddressBetween(String value1, String value2) { - addCriterion("CONSIGNEE_ADDRESS between", value1, value2, "consigneeAddress"); - return (Criteria) this; - } - - public Criteria andConsigneeAddressNotBetween(String value1, String value2) { - addCriterion("CONSIGNEE_ADDRESS not between", value1, value2, "consigneeAddress"); - return (Criteria) this; - } - - public Criteria andPostcodeIsNull() { - addCriterion("POSTCODE is null"); - return (Criteria) this; - } - - public Criteria andPostcodeIsNotNull() { - addCriterion("POSTCODE is not null"); - return (Criteria) this; - } - - public Criteria andPostcodeEqualTo(String value) { - addCriterion("POSTCODE =", value, "postcode"); - return (Criteria) this; - } - - public Criteria andPostcodeNotEqualTo(String value) { - addCriterion("POSTCODE <>", value, "postcode"); - return (Criteria) this; - } - - public Criteria andPostcodeGreaterThan(String value) { - addCriterion("POSTCODE >", value, "postcode"); - return (Criteria) this; - } - - public Criteria andPostcodeGreaterThanOrEqualTo(String value) { - addCriterion("POSTCODE >=", value, "postcode"); - return (Criteria) this; - } - - public Criteria andPostcodeLessThan(String value) { - addCriterion("POSTCODE <", value, "postcode"); - return (Criteria) this; - } - - public Criteria andPostcodeLessThanOrEqualTo(String value) { - addCriterion("POSTCODE <=", value, "postcode"); - return (Criteria) this; - } - - public Criteria andPostcodeLike(String value) { - addCriterion("POSTCODE like", value, "postcode"); - return (Criteria) this; - } - - public Criteria andPostcodeNotLike(String value) { - addCriterion("POSTCODE not like", value, "postcode"); - return (Criteria) this; - } - - public Criteria andPostcodeIn(List values) { - addCriterion("POSTCODE in", values, "postcode"); - return (Criteria) this; - } - - public Criteria andPostcodeNotIn(List values) { - addCriterion("POSTCODE not in", values, "postcode"); - return (Criteria) this; - } - - public Criteria andPostcodeBetween(String value1, String value2) { - addCriterion("POSTCODE between", value1, value2, "postcode"); - return (Criteria) this; - } - - public Criteria andPostcodeNotBetween(String value1, String value2) { - addCriterion("POSTCODE not between", value1, value2, "postcode"); - return (Criteria) this; - } - - public Criteria andSendWeekDayIsNull() { - addCriterion("SEND_WEEK_DAY is null"); - return (Criteria) this; - } - - public Criteria andSendWeekDayIsNotNull() { - addCriterion("SEND_WEEK_DAY is not null"); - return (Criteria) this; - } - - public Criteria andSendWeekDayEqualTo(String value) { - addCriterion("SEND_WEEK_DAY =", value, "sendWeekDay"); - return (Criteria) this; - } - - public Criteria andSendWeekDayNotEqualTo(String value) { - addCriterion("SEND_WEEK_DAY <>", value, "sendWeekDay"); - return (Criteria) this; - } - - public Criteria andSendWeekDayGreaterThan(String value) { - addCriterion("SEND_WEEK_DAY >", value, "sendWeekDay"); - return (Criteria) this; - } - - public Criteria andSendWeekDayGreaterThanOrEqualTo(String value) { - addCriterion("SEND_WEEK_DAY >=", value, "sendWeekDay"); - return (Criteria) this; - } - - public Criteria andSendWeekDayLessThan(String value) { - addCriterion("SEND_WEEK_DAY <", value, "sendWeekDay"); - return (Criteria) this; - } - - public Criteria andSendWeekDayLessThanOrEqualTo(String value) { - addCriterion("SEND_WEEK_DAY <=", value, "sendWeekDay"); - return (Criteria) this; - } - - public Criteria andSendWeekDayLike(String value) { - addCriterion("SEND_WEEK_DAY like", value, "sendWeekDay"); - return (Criteria) this; - } - - public Criteria andSendWeekDayNotLike(String value) { - addCriterion("SEND_WEEK_DAY not like", value, "sendWeekDay"); - return (Criteria) this; - } - - public Criteria andSendWeekDayIn(List values) { - addCriterion("SEND_WEEK_DAY in", values, "sendWeekDay"); - return (Criteria) this; - } - - public Criteria andSendWeekDayNotIn(List values) { - addCriterion("SEND_WEEK_DAY not in", values, "sendWeekDay"); - return (Criteria) this; - } - - public Criteria andSendWeekDayBetween(String value1, String value2) { - addCriterion("SEND_WEEK_DAY between", value1, value2, "sendWeekDay"); - return (Criteria) this; - } - - public Criteria andSendWeekDayNotBetween(String value1, String value2) { - addCriterion("SEND_WEEK_DAY not between", value1, value2, "sendWeekDay"); - return (Criteria) this; - } - - public Criteria andTotalSendValueIsNull() { - addCriterion("TOTAL_SEND_VALUE is null"); - return (Criteria) this; - } - - public Criteria andTotalSendValueIsNotNull() { - addCriterion("TOTAL_SEND_VALUE is not null"); - return (Criteria) this; - } - - public Criteria andTotalSendValueEqualTo(Integer value) { - addCriterion("TOTAL_SEND_VALUE =", value, "totalSendValue"); - return (Criteria) this; - } - - public Criteria andTotalSendValueNotEqualTo(Integer value) { - addCriterion("TOTAL_SEND_VALUE <>", value, "totalSendValue"); - return (Criteria) this; - } - - public Criteria andTotalSendValueGreaterThan(Integer value) { - addCriterion("TOTAL_SEND_VALUE >", value, "totalSendValue"); - return (Criteria) this; - } - - public Criteria andTotalSendValueGreaterThanOrEqualTo(Integer value) { - addCriterion("TOTAL_SEND_VALUE >=", value, "totalSendValue"); - return (Criteria) this; - } - - public Criteria andTotalSendValueLessThan(Integer value) { - addCriterion("TOTAL_SEND_VALUE <", value, "totalSendValue"); - return (Criteria) this; - } - - public Criteria andTotalSendValueLessThanOrEqualTo(Integer value) { - addCriterion("TOTAL_SEND_VALUE <=", value, "totalSendValue"); - return (Criteria) this; - } - - public Criteria andTotalSendValueIn(List values) { - addCriterion("TOTAL_SEND_VALUE in", values, "totalSendValue"); - return (Criteria) this; - } - - public Criteria andTotalSendValueNotIn(List values) { - addCriterion("TOTAL_SEND_VALUE not in", values, "totalSendValue"); - return (Criteria) this; - } - - public Criteria andTotalSendValueBetween(Integer value1, Integer value2) { - addCriterion("TOTAL_SEND_VALUE between", value1, value2, "totalSendValue"); - return (Criteria) this; - } - - public Criteria andTotalSendValueNotBetween(Integer value1, Integer value2) { - addCriterion("TOTAL_SEND_VALUE not between", value1, value2, "totalSendValue"); - return (Criteria) this; - } - - public Criteria andSendValueIsNull() { - addCriterion("SEND_VALUE is null"); - return (Criteria) this; - } - - public Criteria andSendValueIsNotNull() { - addCriterion("SEND_VALUE is not null"); - return (Criteria) this; - } - - public Criteria andSendValueEqualTo(Integer value) { - addCriterion("SEND_VALUE =", value, "sendValue"); - return (Criteria) this; - } - - public Criteria andSendValueNotEqualTo(Integer value) { - addCriterion("SEND_VALUE <>", value, "sendValue"); - return (Criteria) this; - } - - public Criteria andSendValueGreaterThan(Integer value) { - addCriterion("SEND_VALUE >", value, "sendValue"); - return (Criteria) this; - } - - public Criteria andSendValueGreaterThanOrEqualTo(Integer value) { - addCriterion("SEND_VALUE >=", value, "sendValue"); - return (Criteria) this; - } - - public Criteria andSendValueLessThan(Integer value) { - addCriterion("SEND_VALUE <", value, "sendValue"); - return (Criteria) this; - } - - public Criteria andSendValueLessThanOrEqualTo(Integer value) { - addCriterion("SEND_VALUE <=", value, "sendValue"); - return (Criteria) this; - } - - public Criteria andSendValueIn(List values) { - addCriterion("SEND_VALUE in", values, "sendValue"); - return (Criteria) this; - } - - public Criteria andSendValueNotIn(List values) { - addCriterion("SEND_VALUE not in", values, "sendValue"); - return (Criteria) this; - } - - public Criteria andSendValueBetween(Integer value1, Integer value2) { - addCriterion("SEND_VALUE between", value1, value2, "sendValue"); - return (Criteria) this; - } - - public Criteria andSendValueNotBetween(Integer value1, Integer value2) { - addCriterion("SEND_VALUE not between", value1, value2, "sendValue"); - return (Criteria) this; - } - - public Criteria andLastSendDateIsNull() { - addCriterion("LAST_SEND_DATE is null"); - return (Criteria) this; - } - - public Criteria andLastSendDateIsNotNull() { - addCriterion("LAST_SEND_DATE is not null"); - return (Criteria) this; - } - - public Criteria andLastSendDateEqualTo(Date value) { - addCriterionForJDBCDate("LAST_SEND_DATE =", value, "lastSendDate"); - return (Criteria) this; - } - - public Criteria andLastSendDateNotEqualTo(Date value) { - addCriterionForJDBCDate("LAST_SEND_DATE <>", value, "lastSendDate"); - return (Criteria) this; - } - - public Criteria andLastSendDateGreaterThan(Date value) { - addCriterionForJDBCDate("LAST_SEND_DATE >", value, "lastSendDate"); - return (Criteria) this; - } - - public Criteria andLastSendDateGreaterThanOrEqualTo(Date value) { - addCriterionForJDBCDate("LAST_SEND_DATE >=", value, "lastSendDate"); - return (Criteria) this; - } - - public Criteria andLastSendDateLessThan(Date value) { - addCriterionForJDBCDate("LAST_SEND_DATE <", value, "lastSendDate"); - return (Criteria) this; - } - - public Criteria andLastSendDateLessThanOrEqualTo(Date value) { - addCriterionForJDBCDate("LAST_SEND_DATE <=", value, "lastSendDate"); - return (Criteria) this; - } - - public Criteria andLastSendDateIn(List values) { - addCriterionForJDBCDate("LAST_SEND_DATE in", values, "lastSendDate"); - return (Criteria) this; - } - - public Criteria andLastSendDateNotIn(List values) { - addCriterionForJDBCDate("LAST_SEND_DATE not in", values, "lastSendDate"); - return (Criteria) this; - } - - public Criteria andLastSendDateBetween(Date value1, Date value2) { - addCriterionForJDBCDate("LAST_SEND_DATE between", value1, value2, "lastSendDate"); - return (Criteria) this; - } - - public Criteria andLastSendDateNotBetween(Date value1, Date value2) { - addCriterionForJDBCDate("LAST_SEND_DATE not between", value1, value2, "lastSendDate"); - return (Criteria) this; - } - - public Criteria andNextSendDateIsNull() { - addCriterion("NEXT_SEND_DATE is null"); - return (Criteria) this; - } - - public Criteria andNextSendDateIsNotNull() { - addCriterion("NEXT_SEND_DATE is not null"); - return (Criteria) this; - } - - public Criteria andNextSendDateEqualTo(Date value) { - addCriterionForJDBCDate("NEXT_SEND_DATE =", value, "nextSendDate"); - return (Criteria) this; - } - - public Criteria andNextSendDateNotEqualTo(Date value) { - addCriterionForJDBCDate("NEXT_SEND_DATE <>", value, "nextSendDate"); - return (Criteria) this; - } - - public Criteria andNextSendDateGreaterThan(Date value) { - addCriterionForJDBCDate("NEXT_SEND_DATE >", value, "nextSendDate"); - return (Criteria) this; - } - - public Criteria andNextSendDateGreaterThanOrEqualTo(Date value) { - addCriterionForJDBCDate("NEXT_SEND_DATE >=", value, "nextSendDate"); - return (Criteria) this; - } - - public Criteria andNextSendDateLessThan(Date value) { - addCriterionForJDBCDate("NEXT_SEND_DATE <", value, "nextSendDate"); - return (Criteria) this; - } - - public Criteria andNextSendDateLessThanOrEqualTo(Date value) { - addCriterionForJDBCDate("NEXT_SEND_DATE <=", value, "nextSendDate"); - return (Criteria) this; - } - - public Criteria andNextSendDateIn(List values) { - addCriterionForJDBCDate("NEXT_SEND_DATE in", values, "nextSendDate"); - return (Criteria) this; - } - - public Criteria andNextSendDateNotIn(List values) { - addCriterionForJDBCDate("NEXT_SEND_DATE not in", values, "nextSendDate"); - return (Criteria) this; - } - - public Criteria andNextSendDateBetween(Date value1, Date value2) { - addCriterionForJDBCDate("NEXT_SEND_DATE between", value1, value2, "nextSendDate"); - return (Criteria) this; - } - - public Criteria andNextSendDateNotBetween(Date value1, Date value2) { - addCriterionForJDBCDate("NEXT_SEND_DATE not between", value1, value2, "nextSendDate"); - return (Criteria) this; - } - - public Criteria andBeginTimeIsNull() { - addCriterion("BEGIN_TIME is null"); - return (Criteria) this; - } - - public Criteria andBeginTimeIsNotNull() { - addCriterion("BEGIN_TIME is not null"); - return (Criteria) this; - } - - public Criteria andBeginTimeEqualTo(Date value) { - addCriterionForJDBCDate("BEGIN_TIME =", value, "beginTime"); - return (Criteria) this; - } - - public Criteria andBeginTimeNotEqualTo(Date value) { - addCriterionForJDBCDate("BEGIN_TIME <>", value, "beginTime"); - return (Criteria) this; - } - - public Criteria andBeginTimeGreaterThan(Date value) { - addCriterionForJDBCDate("BEGIN_TIME >", value, "beginTime"); - return (Criteria) this; - } - - public Criteria andBeginTimeGreaterThanOrEqualTo(Date value) { - addCriterionForJDBCDate("BEGIN_TIME >=", value, "beginTime"); - return (Criteria) this; - } - - public Criteria andBeginTimeLessThan(Date value) { - addCriterionForJDBCDate("BEGIN_TIME <", value, "beginTime"); - return (Criteria) this; - } - - public Criteria andBeginTimeLessThanOrEqualTo(Date value) { - addCriterionForJDBCDate("BEGIN_TIME <=", value, "beginTime"); - return (Criteria) this; - } - - public Criteria andBeginTimeIn(List values) { - addCriterionForJDBCDate("BEGIN_TIME in", values, "beginTime"); - return (Criteria) this; - } - - public Criteria andBeginTimeNotIn(List values) { - addCriterionForJDBCDate("BEGIN_TIME not in", values, "beginTime"); - return (Criteria) this; - } - - public Criteria andBeginTimeBetween(Date value1, Date value2) { - addCriterionForJDBCDate("BEGIN_TIME between", value1, value2, "beginTime"); - return (Criteria) this; - } - - public Criteria andBeginTimeNotBetween(Date value1, Date value2) { - addCriterionForJDBCDate("BEGIN_TIME not between", value1, value2, "beginTime"); - return (Criteria) this; - } - } - - public static class Criteria extends GeneratedCriteria { - - protected Criteria() { - super(); - } - } - - public static class Criterion { - private String condition; - - private Object value; - - private Object secondValue; - - private boolean noValue; - - private boolean singleValue; - - private boolean betweenValue; - - private boolean listValue; - - private String typeHandler; - - public String getCondition() { - return condition; - } - - public Object getValue() { - return value; - } - - public Object getSecondValue() { - return secondValue; - } - - public boolean isNoValue() { - return noValue; - } - - public boolean isSingleValue() { - return singleValue; - } - - public boolean isBetweenValue() { - return betweenValue; - } - - public boolean isListValue() { - return listValue; - } - - public String getTypeHandler() { - return typeHandler; - } - - protected Criterion(String condition) { - super(); - this.condition = condition; - this.typeHandler = null; - this.noValue = true; - } - - protected Criterion(String condition, Object value, String typeHandler) { - super(); - this.condition = condition; - this.value = value; - this.typeHandler = typeHandler; - if (value instanceof List) { - this.listValue = true; - } else { - this.singleValue = true; - } - } - - protected Criterion(String condition, Object value) { - this(condition, value, null); - } - - protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { - super(); - this.condition = condition; - this.value = value; - this.secondValue = secondValue; - this.typeHandler = typeHandler; - this.betweenValue = true; - } - - protected Criterion(String condition, Object value, Object secondValue) { - this(condition, value, secondValue, null); - } + // ...... } } \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/plan/model/CreateTablePlan.java b/src/main/java/com/xmomen/module/plan/model/CreateTablePlan.java index df05977..a444b15 100644 --- a/src/main/java/com/xmomen/module/plan/model/CreateTablePlan.java +++ b/src/main/java/com/xmomen/module/plan/model/CreateTablePlan.java @@ -8,48 +8,80 @@ import com.xmomen.module.plan.entity.TbTablePlan; import lombok.Data; -public @Data class CreateTablePlan implements Serializable{ +/** + * CreateTablePlan 类用于封装创建餐桌计划所需的信息,实现了 Serializable 接口, + * 使得该类的实例可以在网络传输(如远程方法调用)或持久化存储(如保存到文件或数据库)中使用。 + * 该类使用 Lombok 的 @Data 注解,自动生成了 getter、setter、toString、equals 和 hashCode 等方法, + * 简化了代码的编写,提高了开发效率。 + */ +@Data +public class CreateTablePlan implements Serializable { + /** - * 餐桌计划 + * 餐桌计划的唯一标识,用于关联具体的餐桌计划。 + * 在业务中,可能通过这个 ID 来查找对应的餐桌计划的详细信息, + * 或者与其他相关实体(如订单、会员等)进行关联操作。 */ private Integer cdPlanId; /** - * 审核状态(0-未审核,1-审核通过) + * 审核状态,取值为 0 表示未审核,1 表示审核通过。 + * 用于记录餐桌计划在创建后的审核情况,例如在提交给管理人员审核后, + * 可以根据这个状态来判断该计划是否可以继续执行后续的操作(如生成订单等)。 */ private Integer auditStatus; /** - * 是否暂停 0-不暂停,1-暂停 + * 是否暂停的标识,0 表示不暂停,1 表示暂停。 + * 当餐桌计划需要临时停止执行(例如由于客户要求或其他特殊原因)时, + * 可以通过设置这个标识来暂停计划的推进,如暂停配送等操作。 */ private Integer isStop; /** - * + * 会员的唯一标识,用于关联相关会员信息。 + * 通过这个 ID 可以获取到与该餐桌计划相关的会员的详细信息, + * 如会员的个人信息、购买记录等,以便更好地管理和服务会员。 */ private Integer cdMemberId; /** - * 卡号 + * 会员卡的卡号,用于识别会员的卡片。 + * 在一些业务场景中,可能会根据卡号来验证会员的身份, + * 或者关联会员的优惠信息、积分信息等。 */ private String couponNumber; /** - * 手机号 + * 收货人的手机号码,用于联系收货人。 + * 当进行餐桌计划的配送等操作时,需要通过这个手机号码与收货人取得联系, + * 以确认收货时间、地点等信息。 */ private String consigneePhone; /** - * 收货人姓名 + * 收货人的姓名,用于确认收货人员。 + * 在配送货物时,通过核对收货人姓名来确保货物送达给正确的人员。 */ private String consigneeName; /** - * 收货人地址 + * 收货人的地址,用于确定货物的送达地点。 + * 这是货物配送的关键信息,确保货物能够准确无误地送到指定的地址。 */ private String consigneeAddress; - + + /** + * 包含多个餐桌计划标识的列表,可用于批量操作或关联多个餐桌计划。 + * 例如,在进行批量创建餐桌计划或对多个相关的餐桌计划进行统一管理时, + * 可以使用这个列表来存储和操作这些计划的 ID。 + */ private List cdPlanIds; - + + /** + * 包含多个 TbTablePlan 实体的列表,可用于批量创建或关联多个餐桌计划实体。 + * 当需要一次性创建多个餐桌计划时,可以将这些计划的实体对象存储在这个列表中, + * 然后进行统一的处理和保存到数据库等操作。 + */ private List tablePlans; -} +} \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/plan/model/TablePlanModel.java b/src/main/java/com/xmomen/module/plan/model/TablePlanModel.java index 295a5f3..30a31aa 100644 --- a/src/main/java/com/xmomen/module/plan/model/TablePlanModel.java +++ b/src/main/java/com/xmomen/module/plan/model/TablePlanModel.java @@ -6,115 +6,82 @@ import java.util.Date; import lombok.Data; -public @Data class TablePlanModel implements Serializable{ - /** - * - */ +/** + * TablePlanModel类用于封装餐桌计划相关的数据,实现了Serializable接口, + * 这意味着该类的对象可以被序列化,方便在网络传输或持久化存储中使用。 + * 使用Lombok的@Data注解,自动生成了getter、setter、toString、equals和hashCode等方法。 + */ +@Data +public class TablePlanModel implements Serializable { + // 餐桌计划的唯一标识,用于在数据库中唯一确定一条餐桌计划记录 private Integer id; - /** - * 餐桌计划 - */ + // 餐桌计划的标识,可用于关联其他相关的计划信息 private Integer cdPlanId; + // 餐桌计划的名称,用于直观地描述该计划 private String planName; - /** - * 审核状态(0-未审核,1-审核通过) - */ + // 审核状态,0表示未审核,1表示审核通过 private Integer auditStatus; - + + // 是否暂停,0表示不暂停,1表示暂停 private Integer isStop; - /** - * 卡号 - */ + // 卡号,可能与会员卡或其他卡类相关联 private String couponNumber; - /** - * 手机号 - */ + // 收货人的手机号码,用于联系收货人 private String consigneePhone; - /** - * 收货人姓名 - */ + // 收货人的姓名 private String consigneeName; - /** - * 收货人地址 - */ + // 收货人的地址 private String consigneeAddress; - /** - * 邮政编码 - */ + // 收货地址对应的邮政编码 private String postcode; - - /** - * 单位 - */ + // 单位名称,表明该餐桌计划所属的单位 private String companyName; - + // 单位的唯一标识 private int companyId; - - /** - * 所属客服经理 - */ + + // 所属客服经理的姓名 private String managerName; - + // 所属客服经理的唯一标识 private int managerId; - - /** - * 总配送次数 - */ + + // 总配送次数,即该餐桌计划总共需要配送的次数 private Integer totalSendValue; - /** - * 已配送次数 - */ + // 已配送次数,记录已经完成的配送次数 private Integer sendValue; - - /** - * 生效时间 - */ + + // 生效时间,该餐桌计划开始生效的日期 private Date beginTime; - - /** - * 配送频率(1周,2周,3周) - */ + + // 配送频率,例如1周、2周、3周等,以整数表示 private Integer deliveryType; - /** - * 配送时间(一周的星期几) - */ + // 配送时间,指定一周中的星期几进行配送 private String sendWeekDay; - /** - * 上次配送时间 - */ + + // 上次配送的日期 private Date lastSendDate; - - /** - * 下次配送时间 - */ + + // 下次配送的日期 private Date nextSendDate; - /** - * 是否随机 - */ + + // 是否随机,0表示不随机,1表示随机 private Integer isRandom; - /** - * 产品归属的类别 - */ + // 产品归属的类别标识,用于对产品进行分类 private Integer cdCategoryId; - /** - * 随机数 - */ + // 随机数,可能用于一些随机分配或计算的场景 private Integer randomNum; - - /** - * 计划的金额 - */ + + // 计划的金额,该餐桌计划涉及的费用金额 private BigDecimal price; -} +} \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/plan/model/UpdateTablePlan.java b/src/main/java/com/xmomen/module/plan/model/UpdateTablePlan.java index 6044600..42e2298 100644 --- a/src/main/java/com/xmomen/module/plan/model/UpdateTablePlan.java +++ b/src/main/java/com/xmomen/module/plan/model/UpdateTablePlan.java @@ -11,50 +11,62 @@ import lombok.Data; import org.hibernate.validator.constraints.NotBlank; -public @Data class UpdateTablePlan implements Serializable{ +/** + * UpdateTablePlan类用于封装更新餐桌计划所需的信息,实现了Serializable接口, + * 可用于在网络传输或持久化存储中使用。该类使用Lombok的@Data注解, + * 自动生成了getter、setter、toString、equals和hashCode等方法。 + */ +@Data +public class UpdateTablePlan implements Serializable { /** - * 餐桌计划 + * 餐桌计划的唯一标识,用于确定要更新的具体餐桌计划。 */ private Integer cdPlanId; /** - * 审核状态(0-未审核,1-审核通过) + * 审核状态,0表示未审核,1表示审核通过。 + * 用于更新餐桌计划的审核状态。 */ private Integer auditStatus; /** - * 是否暂停 0-不暂停,1-暂停 + * 是否暂停的标识,0表示不暂停,1表示暂停。 + * 用于更新餐桌计划的暂停状态。 */ private Integer isStop; /** - * + * 会员的唯一标识,可能与该餐桌计划相关联的会员。 */ private Integer cdMemberId; /** - * 卡号 + * 卡号,可能是会员卡或其他关联卡的号码。 */ private String couponNumber; /** - * 手机号 + * 收货人的手机号码,用于联系收货人。 */ private String consigneePhone; /** - * 收货人姓名 + * 收货人的姓名,用于确认收货人员。 */ private String consigneeName; /** - * 收货人地址 + * 收货人的地址,用于确定货物的送达地点。 */ private String consigneeAddress; + /** - * 生效时间 + * 餐桌计划的生效时间,指定该计划开始生效的日期。 */ private Date beginTime; - + + /** + * 配送的星期几,指定餐桌计划在一周中的哪些天进行配送。 + */ private String sendWeekDay; -} +} \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/plan/service/impl/TablePlanSercviceImpl.java b/src/main/java/com/xmomen/module/plan/service/impl/TablePlanSercviceImpl.java index 3c5eb6e..69d6297 100644 --- a/src/main/java/com/xmomen/module/plan/service/impl/TablePlanSercviceImpl.java +++ b/src/main/java/com/xmomen/module/plan/service/impl/TablePlanSercviceImpl.java @@ -33,45 +33,69 @@ import com.xmomen.module.plan.service.TablePlanSercvice; public class TablePlanSercviceImpl implements TablePlanSercvice { @Autowired MybatisDao mybatisDao; - + @Autowired OrderService orderService; @Override @Transactional public void createTablePlan(CreateTablePlan createTablePlan) { + //遍历createTablePlan中的tablePlans for(TbTablePlan tablePlan :createTablePlan.getTablePlans()){ + //设置tablePlan的审核状态为1 tablePlan.setAuditStatus(1); + //设置tablePlan的会员ID tablePlan.setCdMemberId(createTablePlan.getCdMemberId()); + //设置tablePlan的收货地址 tablePlan.setConsigneeAddress(createTablePlan.getConsigneeAddress()); + //设置tablePlan的收货人姓名 tablePlan.setConsigneeName(createTablePlan.getConsigneeName()); + //设置tablePlan的收货人电话 tablePlan.setConsigneePhone(createTablePlan.getConsigneePhone()); + //设置tablePlan的优惠券号码 tablePlan.setCouponNumber(createTablePlan.getCouponNumber()); + //设置tablePlan的发送值为0 tablePlan.setSendValue(0); + //根据tablePlan的cdPlanId查询CdPlan CdPlan plan = mybatisDao.selectByPrimaryKey(CdPlan.class,tablePlan.getCdPlanId()); + //设置tablePlan的总发送值为CdPlan的deliverCount tablePlan.setTotalSendValue(plan.getDeliverCount()); + //保存tablePlan mybatisDao.saveByModel(tablePlan); } } - + @Transactional public void updateTablePlan(Integer id,UpdateTablePlan updateTablePlan) { + //创建TbTablePlan对象 TbTablePlan tablePlan = new TbTablePlan(); + //设置tablePlan的id tablePlan.setId(id); + //设置tablePlan的cdPlanId tablePlan.setCdPlanId(updateTablePlan.getCdPlanId()); + //设置tablePlan的会员ID tablePlan.setCdMemberId(updateTablePlan.getCdMemberId()); + //设置tablePlan的收货地址 tablePlan.setConsigneeAddress(updateTablePlan.getConsigneeAddress()); + //设置tablePlan的收货人姓名 tablePlan.setConsigneeName(updateTablePlan.getConsigneeName()); + //设置tablePlan的收货人电话 tablePlan.setConsigneePhone(updateTablePlan.getConsigneePhone()); + //设置tablePlan的优惠券号码 tablePlan.setCouponNumber(updateTablePlan.getCouponNumber()); + //设置tablePlan的发送周 tablePlan.setSendWeekDay(updateTablePlan.getSendWeekDay()); + //根据updateTablePlan的cdPlanId查询CdPlan CdPlan plan = mybatisDao.selectByPrimaryKey(CdPlan.class,updateTablePlan.getCdPlanId()); + //设置tablePlan的总发送值为CdPlan的deliverCount tablePlan.setTotalSendValue(plan.getDeliverCount()); + //保存tablePlan mybatisDao.saveByModel(tablePlan); } - + @Transactional public void delete(Integer id){ + //根据id删除TbTablePlan mybatisDao.deleteByPrimaryKey(TbTablePlan.class, id); } @@ -106,7 +130,7 @@ public class TablePlanSercviceImpl implements TablePlanSercvice { if(nextSendDate != null){ //下次配送时间不等于当前时间 if (!dateFm.format(currentDate).equals(dateFm.format(nextSendDate))) { - continue; + continue; } } //有效订单 (卡和手机号地址相同的合并成一个订单) @@ -117,7 +141,7 @@ public class TablePlanSercviceImpl implements TablePlanSercvice { tablePlanModels.add(tablePlanModel); tablePlanMap.put(tablePlanModel.getConsigneePhone()+tablePlanModel.getCouponNumber()+tablePlanModel.getConsigneeAddress(), tablePlanModels); } - + //计算下次配送时间 //获取送货频次 Integer deliveryType = tablePlanModel.getDeliveryType(); @@ -149,7 +173,7 @@ public class TablePlanSercviceImpl implements TablePlanSercvice { nextSendDate = addDate(currentDate,day); } } - + //更新订单的最后次送货时间 和次数 TbTablePlanExample tbTablePlanExample = new TbTablePlanExample(); tbTablePlanExample.createCriteria() @@ -165,7 +189,7 @@ public class TablePlanSercviceImpl implements TablePlanSercvice { createOrderFormTablePlan(tablePlanMap); } } - + //餐桌计划下单 private void createOrderFormTablePlan(Map> tablePlanMap){ //一个一个手机号下单 @@ -207,16 +231,16 @@ public class TablePlanSercviceImpl implements TablePlanSercvice { cdPlanItem.setCdPlanId(tablePlanModel.getCdPlanId()); planItems = mybatisDao.selectByModel(cdPlanItem); } - + for(CdPlanItem planItem : planItems){ OrderItem orderItem = new OrderItem(); orderItem.setOrderItemId(planItem.getCdItemId()); orderItem.setItemQty(new BigDecimal(planItem.getCountValue())); orderItemList.add(orderItem); } - + BigDecimal taotalPrice = tablePlanModel.getPrice() == null ?BigDecimal.ZERO:tablePlanModel.getPrice(); - + totalAmount = totalAmount.add(taotalPrice.divide(new BigDecimal(tablePlanModel.getTotalSendValue()),2, BigDecimal.ROUND_DOWN)); //生成餐桌计划和订单的关联关系 TbOrderRef orderRef = new TbOrderRef(); @@ -225,17 +249,17 @@ public class TablePlanSercviceImpl implements TablePlanSercvice { orderRef.setRefValue(tablePlanModel.getId()+""); mybatisDao.insert(orderRef); } - + createOrder.setOrderItemList(orderItemList); createOrder.setTotalPrice(totalAmount); //下单 orderService.createOrder(createOrder); } } - + public static Date addDate(Date d,long day) { - long time = d.getTime(); - day = day*24*60*60*1000; - time += day; + long time = d.getTime(); + day = day*24*60*60*1000; + time += day; return new Date(time); }} diff --git a/src/main/java/com/xmomen/module/product/controller/CategoryController.java b/src/main/java/com/xmomen/module/product/controller/CategoryController.java index 992cb1b..127c6c8 100644 --- a/src/main/java/com/xmomen/module/product/controller/CategoryController.java +++ b/src/main/java/com/xmomen/module/product/controller/CategoryController.java @@ -11,16 +11,26 @@ import org.springframework.web.bind.annotation.ResponseBody; import com.xmomen.module.product.model.CategoryModel; import com.xmomen.module.product.service.CategoryService; +// 标记该类为Spring MVC的控制器,用于处理HTTP请求 @Controller +// 该控制器下的所有请求映射路径都以"/wx"开头 @RequestMapping(value = "/wx") public class CategoryController { + // 使用Spring的依赖注入功能,将CategoryService的实例自动注入到该类中 @Autowired private CategoryService categoryService; - + + /** + * 处理客户端发送的GET请求,请求路径为"/wx/category" + * 该方法用于获取所有产品类别的信息 + * @return 包含所有产品类别信息的列表,列表中的每个元素是一个CategoryModel对象 + */ @RequestMapping(value = "/category", method = RequestMethod.GET) + // 将返回的对象直接转换为JSON格式的数据返回给客户端 @ResponseBody public List getAllProductCategories() { + // 调用CategoryService的getAllProductCategory方法获取所有产品类别信息 return categoryService.getAllProductCategory(); } -} +} \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/product/controller/ProductController.java b/src/main/java/com/xmomen/module/product/controller/ProductController.java index 99c2c45..ee9cd9f 100644 --- a/src/main/java/com/xmomen/module/product/controller/ProductController.java +++ b/src/main/java/com/xmomen/module/product/controller/ProductController.java @@ -21,56 +21,99 @@ import com.xmomen.module.product.model.ProductQuery; import com.xmomen.module.product.model.ProductQueryFilter; import com.xmomen.module.product.service.ProductService; +// 声明这是一个Spring MVC的控制器类,用于处理HTTP请求 @Controller +// 该控制器下所有请求映射的基础路径为"/wx" @RequestMapping(value = "/wx") public class ProductController { + // 使用Spring的依赖注入功能,将ProductService的实例自动注入到当前类中 @Autowired ProductService productService; + /** + * 处理客户端发送的GET请求,请求路径为"/wx/product",用于获取产品列表 + * + * @param limit 每页显示的记录数量 + * @param offset 分页查询的偏移量 + * @param categoryId 产品所属的类别ID,可选参数 + * @param productIds 产品ID数组,可选参数 + * @param keyword 搜索关键词,可选参数 + * @param orderField 排序字段,可选参数 + * @param isAsc 是否升序排序,可选参数,默认值为true + * @param labels 产品标签列表,可选参数 + * @return 包含产品信息的分页对象 + */ @RequestMapping(value = "/product", method = RequestMethod.GET) - @ResponseBody + // 将返回的对象转换为JSON格式响应给客户端 + @ResponseBody public Page getProducts(@RequestParam(value = "limit") Integer limit, - @RequestParam(value = "offset") Integer offset, - @RequestParam(value = "categoryId", required= false) Integer categoryId, - @RequestParam(value = "productIds", required= false) Integer[] productIds, - @RequestParam(value = "keyword", required = false) String keyword, - @RequestParam(value = "orderField", required = false) String orderField, - @RequestParam(value = "isAsc", required = false, defaultValue="true") Boolean isAsc, - @RequestParam(value = "labels", required = false) List labels) { + @RequestParam(value = "offset") Integer offset, + @RequestParam(value = "categoryId", required = false) Integer categoryId, + @RequestParam(value = "productIds", required = false) Integer[] productIds, + @RequestParam(value = "keyword", required = false) String keyword, + @RequestParam(value = "orderField", required = false) String orderField, + @RequestParam(value = "isAsc", required = false, defaultValue = "true") Boolean isAsc, + @RequestParam(value = "labels", required = false) List labels) { + // 创建一个ProductQuery对象,用于封装查询条件 ProductQuery productQuery = new ProductQuery(); + // 设置搜索关键词到查询对象中 productQuery.setKeyword(keyword); - if(productIds != null && productIds.length > 0){ + + // 如果产品ID数组不为空,则将其转换为List并设置到查询对象中 + if (productIds != null && productIds.length > 0) { productQuery.setProductIds(Arrays.asList(productIds)); } - if(categoryId != null && categoryId > 0) { + + // 如果类别ID有效,则将其设置到查询对象中 + if (categoryId != null && categoryId > 0) { productQuery.setCategoryId(categoryId); } + + // 用于存储转换后的标签实体字段 List labelEntityFields = new ArrayList(); - if(!CollectionUtils.isEmpty(labels)) { - for(String labelStr: labels) { + // 如果标签列表不为空 + if (!CollectionUtils.isEmpty(labels)) { + // 遍历标签列表 + for (String labelStr : labels) { + // 根据标签字符串获取对应的ProductLabel枚举实例 ProductLabel label = ProductLabel.enumOf(labelStr); - if(label != null) { + // 如果枚举实例存在,则将其对应的实体字段添加到labelEntityFields列表中 + if (label != null) { labelEntityFields.add(label.getEntityField()); } } } - if(!labelEntityFields.isEmpty()) { + + // 如果labelEntityFields列表不为空,则将其设置到查询对象中,否则设置为null + if (!labelEntityFields.isEmpty()) { productQuery.setFilterLabels(labelEntityFields); } else { productQuery.setFilterLabels(null); } + + // 根据排序字段字符串获取对应的ProductQueryFilter枚举实例 ProductQueryFilter orderFieldType = ProductQueryFilter.enumOf(orderField); - if(orderFieldType != null) { + // 如果枚举实例存在,则设置排序字段和排序方式到查询对象中 + if (orderFieldType != null) { productQuery.setOrderField(orderFieldType.getFieldName()); productQuery.setIsAsc(isAsc); } + + // 调用ProductService的方法,根据查询条件、每页记录数和偏移量获取产品列表 return productService.getProductList(productQuery, limit, offset); } - + + /** + * 处理客户端发送的GET请求,请求路径为"/wx/product/{id}",用于获取单个产品的详细信息 + * + * @param productId 产品的ID + * @return 包含产品详细信息的ProductModel对象 + */ @ResponseBody @RequestMapping(value = "/product/{id}", method = RequestMethod.GET) - public ProductModel detail(@PathVariable(value="id") Integer productId) { + public ProductModel detail(@PathVariable(value = "id") Integer productId) { + // 调用ProductService的方法,根据产品ID获取产品的详细信息 return productService.getDetailById(productId); } -} +} \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/product/entity/Category.java b/src/main/java/com/xmomen/module/product/entity/Category.java index e1f0d78..16baa1a 100644 --- a/src/main/java/com/xmomen/module/product/entity/Category.java +++ b/src/main/java/com/xmomen/module/product/entity/Category.java @@ -5,44 +5,79 @@ import javax.persistence.Table; import com.xmomen.framework.mybatis.model.BaseMybatisModel; +// 使用JPA的@Entity注解,表明这是一个实体类,会被JPA映射到数据库表 @Entity +// 使用@Table注解指定该实体类映射到数据库中的表名为"cd_category" @Table(name="cd_category") public class Category extends BaseMybatisModel { + // 序列化版本号,用于在序列化和反序列化时确保版本的兼容性 private static final long serialVersionUID = 1L; + // 类别ID,对应数据库表中的主键字段 private Integer id; - + + // 类别名称 private String name; - + + // 父类别ID,用于表示类别之间的层级关系 private Integer parentId; + /** + * 获取类别ID + * @return 类别ID + */ public Integer getId() { return id; } + /** + * 设置类别ID + * @param id 要设置的类别ID + */ public void setId(Integer id) { this.id = id; } + /** + * 获取类别名称 + * @return 类别名称 + */ public String getName() { return name; } + /** + * 设置类别名称 + * @param name 要设置的类别名称 + */ public void setName(String name) { this.name = name; } + /** + * 获取父类别ID + * @return 父类别ID + */ public Integer getParentId() { return parentId; } + /** + * 设置父类别ID + * @param parentId 要设置的父类别ID + */ public void setParentId(Integer parentId) { this.parentId = parentId; } + /** + * 重写toString方法,方便打印对象信息 + * @return 包含类别ID、名称和父类别ID的字符串表示 + */ @Override public String toString() { + // 使用StringBuilder来构建字符串,提高性能 StringBuilder builder = new StringBuilder(); builder.append("Category [id="); builder.append(id); @@ -53,4 +88,4 @@ public class Category extends BaseMybatisModel { builder.append("]"); return builder.toString(); } -} +} \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/product/mapper/ProductCategoryMapper.java b/src/main/java/com/xmomen/module/product/mapper/ProductCategoryMapper.java index 4408e95..e1ffa49 100644 --- a/src/main/java/com/xmomen/module/product/mapper/ProductCategoryMapper.java +++ b/src/main/java/com/xmomen/module/product/mapper/ProductCategoryMapper.java @@ -1,6 +1,17 @@ package com.xmomen.module.product.mapper; +/** + * ProductCategoryMapper 接口主要用于提供与产品类别相关数据库操作的映射命名空间定义。 + * 在MyBatis框架中,接口配合XML映射文件或注解,可将Java方法与SQL语句关联起来,实现数据库操作。 + * 此接口里定义的命名空间常量会在后续映射SQL语句时被用到。 + */ public interface ProductCategoryMapper { + /** + * 这是一个静态常量,代表 ProductCategoryMapper 接口对应的命名空间。 + * 在MyBatis里,命名空间能避免不同映射器间的SQL语句ID产生冲突。 + * 该命名空间会在 XML 映射文件或者注解里引用SQL语句时作为前缀, + * 从而保证 SQL 语句 ID 的唯一性。 + */ public static final String ProductCategoryMapperNameSpace = "com.xmomen.module.product.mapper.ProductCategoryMapper."; -} +} \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/product/model/CategoryModel.java b/src/main/java/com/xmomen/module/product/model/CategoryModel.java index 2d53776..374f4c0 100644 --- a/src/main/java/com/xmomen/module/product/model/CategoryModel.java +++ b/src/main/java/com/xmomen/module/product/model/CategoryModel.java @@ -5,14 +5,32 @@ import java.util.List; import lombok.Data; -public @Data -class CategoryModel implements Serializable { +/** + * CategoryModel类用于表示产品类别的数据模型,可在不同层(如控制器、服务层、视图层)之间传递数据。 + * 该类实现了Serializable接口,意味着它可以被序列化,方便在网络传输或存储到文件中。 + * 使用Lombok的@Data注解,自动生成了getter、setter、toString、equals和hashCode等方法。 + */ +@Data +public class CategoryModel implements Serializable { + // 序列化版本号,用于在序列化和反序列化过程中确保版本的兼容性。 private static final long serialVersionUID = 1L; + + // 类别ID,唯一标识一个类别。 private Integer id; + + // 类别名称,描述该类别的具体名称。 private String name; + + // 父类别ID,用于表示该类别所属的父类别。如果为null,则表示该类别为顶级类别。 private Integer parentId; + + // 父类别名称,存储该类别父类别的名称。 private String parentName; + + // 子类别列表,存储该类别下的所有子类别。 private List nodes; + + // 标识该类别是否为叶子节点(即是否没有子类别)。默认为true,表示是叶子节点。 private boolean leaf = true; -} +} \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/product/model/ProductLabel.java b/src/main/java/com/xmomen/module/product/model/ProductLabel.java index 9c18da5..bdc881e 100644 --- a/src/main/java/com/xmomen/module/product/model/ProductLabel.java +++ b/src/main/java/com/xmomen/module/product/model/ProductLabel.java @@ -1,30 +1,66 @@ package com.xmomen.module.product.model; +/** + * 该枚举类`ProductLabel`用于定义产品的标签类型。 + * 每个标签都有对应的描述信息和实体字段名,可用于在业务逻辑中区分不同的产品标签。 + */ public enum ProductLabel { + // 限时抢购标签,描述为"xianShiQiangGou",对应的实体字段为"XIAN_SHI_QIANG_GOU" XIAN_SHI_QIANG_GOU("xianShiQiangGou", "XIAN_SHI_QIANG_GOU"), + // 新品尝鲜标签,描述为"xinPinChangXian",对应的实体字段为"XIN_PIN_CHANG_XIAN" XIN_PIN_CHANG_XIAN("xinPinChangXian", "XIN_PIN_CHANG_XIAN"), + // 热卖推荐标签,描述为"reMaiTuiJian",对应的实体字段为"RE_MAI_TUI_JIAN" RE_MAI_TUI_JIAN("reMaiTuiJian", "RE_MAI_TUI_JIAN"); + + // 标签的描述信息,用于在业务逻辑中识别该标签 String desc; + // 标签对应的实体字段名,可能用于数据库查询或其他操作 String entityField; + + /** + * 获取标签对应的实体字段名 + * @return 实体字段名 + */ public String getEntityField() { return this.entityField; } + + /** + * 获取标签的描述信息 + * @return 标签的描述信息 + */ public String getDesc() { return this.desc; } + + /** + * 枚举类的构造函数,用于初始化标签的描述信息和实体字段名 + * @param desc 标签的描述信息 + * @param entityField 标签对应的实体字段名 + */ ProductLabel(String desc, String entityField) { this.desc = desc; this.entityField = entityField; - }; - + } + + /** + * 根据描述信息查找对应的`ProductLabel`枚举实例 + * @param desc 要查找的标签描述信息 + * @return 匹配的`ProductLabel`枚举实例,如果未找到则返回`null` + */ public static ProductLabel enumOf(String desc) { + // 获取所有的`ProductLabel`枚举实例 ProductLabel[] labels = ProductLabel.values(); + // 获取枚举实例的数量 int length = labels.length; - for(int i = 0; i < length; i++) { + // 遍历所有枚举实例 + for (int i = 0; i < length; i++) { ProductLabel label = labels[i]; - if(label.desc.equalsIgnoreCase(desc)) return label; + // 忽略大小写比较描述信息,如果匹配则返回该枚举实例 + if (label.desc.equalsIgnoreCase(desc)) return label; } + // 未找到匹配的枚举实例,返回`null` return null; } -} +} \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/product/model/ProductModel.java b/src/main/java/com/xmomen/module/product/model/ProductModel.java index b8f94f2..875ea64 100644 --- a/src/main/java/com/xmomen/module/product/model/ProductModel.java +++ b/src/main/java/com/xmomen/module/product/model/ProductModel.java @@ -6,35 +6,65 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; -public @Data class ProductModel { +/** + * ProductModel类用于封装产品的相关信息,在不同层之间传递产品数据。 + * 借助Lombok的@Data注解,自动生成了getter、setter、toString、equals和hashCode等方法。 + */ +@Data +public class ProductModel { + // 产品的唯一标识ID private Integer id; + // 产品的编码 private String itemCode; + // 产品的名称 private String itemName; + // 产品所属类别的ID private Integer categoryId; + // 产品所属类别的名称 private String categoryName; + // 产品的描述信息 private String itemDescribe; + // 产品的类型 private Integer itemType; + // 产品的产地 private String yieldly; + // 产品的规格 private String spec; + // 产品的基础价格 private Double basePrice; + // 产品的会员价格 private Double memberPrice; + // 产品的定价方式 private String priceManner; + // 产品的销售状态,true表示可销售,false表示不可销售 private Boolean sellStatus; + // 产品的销售单位 private String sellUnit; + // 产品的销售价格 private Double sellPrice; + // 产品的销售数量 private Integer sellNum; + // 产品的库存数量 private Integer stockNum; - + + // 产品是否参与限时抢购活动,true表示参与,false表示不参与 private Boolean xianShiQiangGou; + // 产品是否为新品尝鲜,true表示是,false表示不是 private Boolean xinPinChangXian; + // 产品是否为热卖推荐,true表示是,false表示不是 private Boolean reMaiTuiJian; - + + // 产品的主图片URL private String picUrl; + // 主图片URL是否为默认路径,true表示是,false表示不是 private Boolean isDefaultPath; - + + // 产品的多个图片URL列表 private List picUrls; + // 产品的详细介绍内容 private String detailContent; - + + // 产品的数量 private Integer itemQty; -} +} \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/product/model/ProductQuery.java b/src/main/java/com/xmomen/module/product/model/ProductQuery.java index 31c2c69..e51e619 100644 --- a/src/main/java/com/xmomen/module/product/model/ProductQuery.java +++ b/src/main/java/com/xmomen/module/product/model/ProductQuery.java @@ -4,15 +4,31 @@ import java.util.List; import lombok.Data; -public @Data class ProductQuery { +/** + * ProductQuery类用于封装产品查询的条件,方便在业务逻辑中传递查询参数。 + * 使用Lombok的@Data注解,自动生成了getter、setter、toString、equals和hashCode等方法。 + */ +@Data +public class ProductQuery { + // 产品所属类别的ID,用于筛选特定类别的产品 private Integer categoryId; + + // 查询关键词,可用于在产品名称、描述等字段中进行模糊搜索 private String keyword; + + // 排序字段,指定按照哪个字段对查询结果进行排序 private String orderField; + + // 是否升序排序,默认为true,表示升序;设置为false则为降序 private Boolean isAsc = true; + + // 过滤标签列表,用于筛选具有特定标签的产品 private List filterLabels; - + + // 产品ID列表,用于筛选指定ID的产品 private List productIds; + + // 会员代码,可能用于根据会员身份进行产品查询筛选 private String memberCode; - -} +} \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/product/model/ProductQueryFilter.java b/src/main/java/com/xmomen/module/product/model/ProductQueryFilter.java index 5bd749b..b7f911a 100644 --- a/src/main/java/com/xmomen/module/product/model/ProductQueryFilter.java +++ b/src/main/java/com/xmomen/module/product/model/ProductQueryFilter.java @@ -1,44 +1,84 @@ package com.xmomen.module.product.model; /** - * The enum is used for filter or order + * 该枚举类用于产品查询时的过滤或排序操作。 + * 可以根据枚举值来确定查询时使用的字段和条件。 * @author xiao - * */ public enum ProductQueryFilter { + // 按照价格进行过滤或排序,描述为 "price",对应的数据库字段为 "SELL_PRICE" PRICE("price", "SELL_PRICE"); + // 枚举值的描述,用于在业务逻辑中方便识别该枚举值 private String desc; + // 对应的数据库字段名,用于实际的 SQL 查询 private String fieldName; - // Query condition + // 查询条件,可能用于构建更复杂的 SQL 查询,初始值可为 null private String condition; - - + + /** + * 构造函数,初始化描述和字段名,条件默认为 null + * @param desc 枚举值的描述 + * @param fieldName 对应的数据库字段名 + */ ProductQueryFilter(String desc, String fieldName) { this(desc, fieldName, null); } + + /** + * 构造函数,初始化描述、字段名和查询条件 + * @param desc 枚举值的描述 + * @param fieldName 对应的数据库字段名 + * @param condition 查询条件 + */ ProductQueryFilter(String desc, String fieldName, String condition) { this.desc = desc; this.fieldName = fieldName; this.condition = condition; } + + /** + * 获取枚举值的描述 + * @return 描述信息 + */ public String getDesc() { return this.desc; } + + /** + * 获取对应的数据库字段名 + * @return 数据库字段名 + */ public String getFieldName() { return this.fieldName; } + + /** + * 获取查询条件 + * @return 查询条件 + */ public String getCondition() { return this.condition; } + + /** + * 根据描述信息查找对应的 ProductQueryFilter 枚举实例 + * @param desc 要查找的描述信息 + * @return 匹配的枚举实例,如果未找到则返回 null + */ public static ProductQueryFilter enumOf(String desc) { + // 获取所有的 ProductQueryFilter 枚举实例 ProductQueryFilter[] filters = ProductQueryFilter.values(); + // 获取枚举实例的数量 int length = filters.length; - for(int i = 0; i < length; i++) { + // 遍历所有枚举实例 + for (int i = 0; i < length; i++) { ProductQueryFilter filter = filters[i]; - if(filter.desc.equalsIgnoreCase(desc)) return filter; + // 忽略大小写比较描述信息,如果匹配则返回该枚举实例 + if (filter.desc.equalsIgnoreCase(desc)) return filter; } + // 未找到匹配的枚举实例,返回 null return null; } -} +} \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/product/service/impl/CategoryServiceImpl.java b/src/main/java/com/xmomen/module/product/service/impl/CategoryServiceImpl.java index a379757..98eb5a6 100644 --- a/src/main/java/com/xmomen/module/product/service/impl/CategoryServiceImpl.java +++ b/src/main/java/com/xmomen/module/product/service/impl/CategoryServiceImpl.java @@ -15,44 +15,69 @@ import com.xmomen.module.product.model.CategoryModel; import com.xmomen.module.product.service.CategoryService; /** - * + * CategoryServiceImpl 类是 CategoryService 接口的实现类,负责处理产品类别的业务逻辑。 + * 它使用 MyBatis 进行数据库操作,将数据库中的 Category 实体转换为 CategoryModel 并构建成树形结构。 * @author xiao - * */ @Service public class CategoryServiceImpl implements CategoryService { + // 注入 MyBatis 数据访问对象,用于执行数据库操作 @Autowired - MybatisDao mybatisDao; - + MybatisDao mybatisDao; + + /** + * 获取所有产品类别的列表,并将其转换为树形结构的 CategoryModel 列表。 + * @return 包含所有产品类别的树形结构的 CategoryModel 列表 + */ public List getAllProductCategory() { + // 调用 MyBatis 的 SQLSessionTemplate 执行查询,获取所有产品类别的 Category 实体列表 List categoryList = mybatisDao.getSqlSessionTemplate().selectList(ProductCategoryMapper.ProductCategoryMapperNameSpace + "getProductCategoryList"); + // 用于存储最终的 CategoryModel 列表 List categories = new ArrayList(); + // 如果查询结果不为空 if(categoryList != null) { + // 使用 TreeMap 存储顶级类别,TreeMap 会根据键的自然顺序排序 Map topCategories = new TreeMap(); + // 遍历 Category 实体列表 for(Category category: categoryList) { + // 创建一个新的 CategoryModel 对象 CategoryModel model = new CategoryModel(); + // 设置 CategoryModel 的 ID model.setId(category.getId()); + // 初始假设该类别为叶子节点(没有子节点) model.setLeaf(true); + // 设置 CategoryModel 的名称 model.setName(category.getName()); + // 如果该类别没有父类别(即顶级类别) if(category.getParentId() == null) { + // 将该顶级类别添加到 topCategories 映射中 topCategories.put(String.valueOf(category.getId()), model); } else { + // 根据父类别 ID 从 topCategories 映射中获取父类别 CategoryModel parentCategory = topCategories.get(String.valueOf(category.getParentId())); + // 如果找到了父类别 if(parentCategory != null) { + // 说明该父类别有子节点,不是叶子节点 parentCategory.setLeaf(false); + // 设置当前类别模型的父类别 ID model.setParentId(parentCategory.getId()); + // 设置当前类别模型的父类别名称 model.setParentName(parentCategory.getName()); + // 如果父类别还没有子节点列表 if(parentCategory.getNodes() == null) { + // 为父类别创建一个新的子节点列表 parentCategory.setNodes(new ArrayList()); } + // 将当前类别模型添加到父类别的子节点列表中 parentCategory.getNodes().add(model); } } - } + // 将 topCategories 映射中的所有值(即顶级类别)添加到最终的 categories 列表中 categories.addAll(topCategories.values()); } + // 返回最终的 CategoryModel 列表 return categories; } -} +} \ No newline at end of file diff --git a/src/main/java/com/xmomen/module/product/service/impl/ProductServiceImpl.java b/src/main/java/com/xmomen/module/product/service/impl/ProductServiceImpl.java index 713ce55..8ae61c0 100644 --- a/src/main/java/com/xmomen/module/product/service/impl/ProductServiceImpl.java +++ b/src/main/java/com/xmomen/module/product/service/impl/ProductServiceImpl.java @@ -17,88 +17,146 @@ import com.xmomen.module.product.model.ProductQuery; import com.xmomen.module.product.service.ProductService; import com.xmomen.module.resource.service.ResourceService; +/** + * ProductServiceImpl 类是 ProductService 接口的实现类,负责处理产品相关的业务逻辑。 + * 它使用 MyBatis 进行数据库操作,对查询到的产品数据进行处理,如隐藏商品原价、处理图片 URL 等。 + */ @Service public class ProductServiceImpl implements ProductService { + // 注入 MyBatis 数据访问对象,用于执行数据库操作 @Autowired MybatisDao mybatisDao; + /** + * 根据查询条件分页获取产品列表,并对产品信息进行处理。 + * @param productQuery 产品查询条件对象 + * @param limit 每页显示的记录数 + * @param offset 分页偏移量 + * @return 包含产品信息的分页对象 + */ @SuppressWarnings("unchecked") @Override public Page getProductList(ProductQuery productQuery, Integer limit, Integer offset) { + // 调用 MyBatis 的分页查询方法,获取产品列表的分页对象 Page pageModel = (Page) mybatisDao.selectPage(ProductMapper.ProductMapperNameSpace + "getProductList", productQuery, limit, offset); + // 获取分页对象中的产品列表 List products = pageModel.getResult(); + // 如果产品列表不为空 if (products != null) { + // 遍历产品列表 for (ProductModel product : products) { - product.setBasePrice(null);//隐藏商品原价 + // 隐藏商品原价 + product.setBasePrice(null); + // 如果产品的图片 URL 为空 if (StringUtils.isEmpty(product.getPicUrl())) { + // 设置为默认图片路径 product.setPicUrl(ResourceUtilsService.getDefaultPicPath()); - } - else { + } else { + // 转换为完整的 HTTP 路径 product.setPicUrl(ResourceUtilsService.getWholeHttpPath(product.getPicUrl())); } } } + // 返回处理后的分页对象 return pageModel; } + /** + * 根据产品 ID 获取产品详细信息,并处理产品的图片信息。 + * @param id 产品 ID + * @return 包含产品详细信息的 ProductModel 对象,如果未找到则返回 null + */ @Override public ProductModel getDetailById(Integer id) { + // 调用 MyBatis 的查询方法,根据产品 ID 获取产品详细信息列表 List products = mybatisDao.getSqlSessionTemplate().selectList(ProductMapper.ProductMapperNameSpace + "getProductDetail", id); + // 用于存储产品的图片 URL 列表 List picUrls = new ArrayList(); + // 用于存储默认图片 URL String defaultPicUrl = null; + // 如果产品详细信息列表不为空 if (products != null && !products.isEmpty()) { + // 遍历产品详细信息列表 for (ProductModel product : products) { + // 如果产品的图片 URL 不为空 if (!StringUtils.isEmpty(product.getPicUrl())) { + // 如果该图片是默认图片 if (product.getIsDefaultPath()) { + // 记录默认图片 URL defaultPicUrl = product.getPicUrl(); } - //else { - picUrls.add(ResourceUtilsService.getWholeHttpPath(product.getPicUrl())); - //} + // 将图片 URL 转换为完整的 HTTP 路径并添加到图片 URL 列表中 + picUrls.add(ResourceUtilsService.getWholeHttpPath(product.getPicUrl())); } } + // 获取第一个产品详细信息对象 ProductModel detail = products.get(0); + // 如果图片 URL 列表为空 if(picUrls.isEmpty()) { - picUrls.add(ResourceUtilsService.getDefaultPicPath()); + // 添加默认图片路径 + picUrls.add(ResourceUtilsService.getDefaultPicPath()); } + // 设置产品的图片 URL 列表 detail.setPicUrls(picUrls); - detail.setBasePrice(null);//隐藏商品原价 + // 隐藏商品原价 + detail.setBasePrice(null); + // 如果默认图片 URL 为空 if (defaultPicUrl == null) { + // 如果产品的图片 URL 为空 if (StringUtils.isEmpty(detail.getPicUrl())) { + // 设置为默认图片路径 detail.setPicUrl(ResourceUtilsService.getDefaultPicPath()); - } - else { + } else { + // 转换为完整的 HTTP 路径 detail.setPicUrl(ResourceUtilsService.getWholeHttpPath(detail.getPicUrl())); } - } - else { + } else { + // 将默认图片 URL 转换为完整的 HTTP 路径并设置给产品 detail.setPicUrl(ResourceUtilsService.getWholeHttpPath(defaultPicUrl)); } + // 返回处理后的产品详细信息对象 return detail; } + // 未找到产品信息,返回 null return null; } + /** + * 根据产品 ID 列表获取产品列表,并对产品信息进行处理。 + * @param itemIds 产品 ID 列表 + * @return 包含产品信息的列表,如果 ID 列表为空则返回空列表 + */ @Override public List getProducts(List itemIds) { + // 如果产品 ID 列表为空 if (CollectionUtils.isEmpty(itemIds)) { + // 返回一个空的产品列表 return new ArrayList(); } + // 创建产品查询条件对象 ProductQuery productQuery = new ProductQuery(); + // 设置查询条件中的产品 ID 列表 productQuery.setProductIds(itemIds); + // 调用 MyBatis 的查询方法,根据产品 ID 列表获取产品列表 List products = mybatisDao.getSqlSessionTemplate().selectList(ProductMapper.ProductMapperNameSpace + "getProductsByIds", productQuery); + // 如果产品列表不为空 if (products != null && !products.isEmpty()) { + // 遍历产品列表 for (ProductModel product : products) { - product.setBasePrice(null);//隐藏商品原价 + // 隐藏商品原价 + product.setBasePrice(null); + // 如果产品的图片 URL 为空 if (StringUtils.isEmpty(product.getPicUrl())) { - product.setPicUrl(ResourceUtilsService.getDefaultPicPath()); - } - else { - product.setPicUrl(ResourceUtilsService.getWholeHttpPath(product.getPicUrl())); + // 设置为默认图片路径 + product.setPicUrl(ResourceUtilsService.getDefaultPicPath()); + } else { + // 转换为完整的 HTTP 路径 + product.setPicUrl(ResourceUtilsService.getWholeHttpPath(product.getPicUrl())); } } } + // 返回处理后的产品列表 return products; } -} +} \ No newline at end of file