Feat: Code gen V3 ok

This commit is contained in:
Owen 2024-12-23 00:01:22 +08:00
parent 32cadcbeae
commit 5907ab9605
5 changed files with 44 additions and 4 deletions

View File

@ -89,6 +89,11 @@ public class HaoKaProductRespVO {
@ExcelProperty("预估收益") @ExcelProperty("预估收益")
private String estimatedRevenue; private String estimatedRevenue;
@Schema(description = "生产方式", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty(value = "生产方式", converter = DictConvert.class)
@DictFormat("haoka_auto_type")
private Integer autoType;
@Schema(description = "上架") @Schema(description = "上架")
@ExcelProperty("上架") @ExcelProperty("上架")
private Boolean onSale; private Boolean onSale;
@ -101,4 +106,4 @@ public class HaoKaProductRespVO {
@ExcelProperty("创建时间") @ExcelProperty("创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;
} }

View File

@ -78,4 +78,6 @@ public class HaoKaProductSaveReqVO {
@Schema(description = "是否顶置") @Schema(description = "是否顶置")
private Boolean isTop; private Boolean isTop;
} @Schema(description = "生产方式")
private Integer autoType;
}

View File

@ -114,4 +114,10 @@ public class HaoKaProductDO extends BaseDO {
*/ */
private Long deptId; private Long deptId;
/**
* 生产方式
*
* 枚举
*/
private Integer autoType;
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.haoka.service.product; package cn.iocoder.yudao.module.haoka.service.product;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@ -7,6 +8,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import cn.iocoder.yudao.module.haoka.controller.admin.product.vo.*; import cn.iocoder.yudao.module.haoka.controller.admin.product.vo.*;
import cn.iocoder.yudao.module.haoka.dal.dataobject.product.HaoKaProductDO; import cn.iocoder.yudao.module.haoka.dal.dataobject.product.HaoKaProductDO;
import cn.iocoder.yudao.module.haoka.dal.dataobject.superiorproductconfig.SuperiorProductConfigDO; import cn.iocoder.yudao.module.haoka.dal.dataobject.superiorproductconfig.SuperiorProductConfigDO;
@ -27,7 +29,7 @@ import static cn.iocoder.yudao.module.haoka.enums.ErrorCodeConstants.*;
*/ */
@Service @Service
@Validated @Validated
public class HaoKaProductServiceImpl extends ServiceImpl<HaoKaProductMapper,HaoKaProductDO> implements HaoKaProductService { public class HaoKaProductServiceImpl extends ServiceImpl<HaoKaProductMapper, HaoKaProductDO> implements HaoKaProductService {
@Resource @Resource
private HaoKaProductMapper haoKaProductMapper; private HaoKaProductMapper haoKaProductMapper;
@ -49,6 +51,18 @@ public class HaoKaProductServiceImpl extends ServiceImpl<HaoKaProductMapper,HaoK
validateHaoKaProductExists(updateReqVO.getId()); validateHaoKaProductExists(updateReqVO.getId());
// 更新 // 更新
HaoKaProductDO updateObj = BeanUtils.toBean(updateReqVO, HaoKaProductDO.class); HaoKaProductDO updateObj = BeanUtils.toBean(updateReqVO, HaoKaProductDO.class);
// 校验生产方式
if (updateObj.getAutoType() != null && updateObj.getAutoType() == 2) {
List<SuperiorProductConfigDO> superiorProductConfigDOS =
superiorProductConfigMapper.selectList(
new LambdaQueryWrapperX<SuperiorProductConfigDO>()
.eqIfPresent(SuperiorProductConfigDO::getHaokaProductId,
updateReqVO.getId()));
if (superiorProductConfigDOS.isEmpty()) {
throw new IllegalArgumentException("该产品未配置自动生产模块,请先配置自动生产!");
}
}
haoKaProductMapper.updateById(updateObj); haoKaProductMapper.updateById(updateObj);
} }
@ -106,7 +120,6 @@ public class HaoKaProductServiceImpl extends ServiceImpl<HaoKaProductMapper,HaoK
} }
private void validateSuperiorProductConfigExists(Long id) { private void validateSuperiorProductConfigExists(Long id) {
if (superiorProductConfigMapper.selectById(id) == null) { if (superiorProductConfigMapper.selectById(id) == null) {
throw exception(SUPERIOR_PRODUCT_CONFIG_NOT_EXISTS); throw exception(SUPERIOR_PRODUCT_CONFIG_NOT_EXISTS);

View File

@ -0,0 +1,14 @@
alter table haoka_product
add column `auto_type` int(11) NOT NULL default 1 COMMENT '生产方式';
-- '生产方式' -- 枚举 haoka_auto_type:中国移动,中国联通,中国电信,中国广电,虚拟运营商
INSERT INTO `system_dict_type` (`name`, `type`, `status`, `remark`, `creator`, `updater`, `deleted`)
VALUES ('运营商', 'haoka_auto_type', 0, '', '1', '1', b'0');
INSERT INTO `system_dict_data` (`sort`, `label`, `value`, `dict_type`, `status`, `color_type`,
`css_class`, `remark`, `creator`, `updater`,
`deleted`)
VALUES (1, '手动生产', '1', 'haoka_auto_type', 0, '', '', NULL, '', '', b'0'),
(2, '自动生产', '2', 'haoka_auto_type', 0, '', '', NULL, '', '', b'0');