1 Star 0 Fork 0

starplatinum111 / js-util

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gen_java.js 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
starplatinum111 提交于 2022-06-03 15:38 . 收藏动画
class Shop{
constructor(shopInfo){
this.logo = shopInfo.shopLogo;
this.name = shopInfo.name;
this.fans = shopInfo.cFans;
this.sells = shopInfo.cSells;
this.score = shopInfo.score;
this.goodsCount = shopInfo.cGoods;
}
}
let commentInfo={
user:{
avatar:"",
uname:""
},
content:"",
created:"",
style:"",
images:[]
}
console.log("commentInfo");
console.log(commentInfo);
let shop=new Shop({})
let java_fields=""
// for (const field of shop) {
// console.log("field");
// console.log(field);
// }
function title(str){
// a = a[0].toUpperCase() + a.substr(1)
return str[0].toUpperCase() + str.substr(1)
}
// Func.name
// shop
// Shop.name
// 这个可以
for (const field in shop) {
console.log("field");
console.log(field);
// title
// js title
let fieldClsName= title(field)
// java_fields+=`${fieldClsName } ${field};\n`
java_fields+=`String ${field};\n`
// let val=shop[field]
}
console.log("java_fields");
console.log(java_fields);
console.log(shop);
let classStr=`
import lombok.Data;
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
public class ${Shop.name} {
${java_fields}
}`
console.log(classStr);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/starplatinum111/js-util.git
git@gitee.com:starplatinum111/js-util.git
starplatinum111
js-util
js-util
master

搜索帮助