首页 > 其他分享 >PDManer 模板创建

PDManer 模板创建

时间:2024-11-19 16:44:29浏览次数:3  
标签:创建 defKey entity field PDManer var blankline 模板 beanClass

 Entity层

{{  var today=new Date();
    var fullYear=today.getFullYear();
    var month=today.getMonth() + 1;
    var days=today.getDate();
    
    var pkVarName = "undefinedId";
    var pkDataType = "String";
    it.entity.fields.forEach(function(field){
        if(field.primaryKey){
            pkVarName = it.func.camel(field.defKey,false);
            pkDataType = field["type"];
            return;
        }
    });
    
    var pkgName = it.entity.env.base.nameSpace;
    var beanClass = it.entity.env.base.codeRoot;
    var beanVarName = beanClass.charAt(0).toLowerCase()+beanClass.slice(1);
    var serviceClass = beanClass+'Service';
    var serviceVarName= beanVarName+'Service';
    
}}package {{=pkgName}}.entity;
$blankline
import java.time.LocalDateTime;
import lombok.Data;
import {{=pkgName}}.entity.*;
import java.math.BigDecimal;
$blankline
 
 /**
 * {{=it.entity.defName}};{{=it.entity.comment}}
 * @author : heimi
 * @date : {{=fullYear}}-{{=month}}-{{=days}}
 */
 
@Data
public class {{=beanClass}} extends BaseEntity {
{{~it.entity.fields:field:index}}
    /** {{=it.func.join(field.defName,field.comment,';')}} */
    private {{=field.type}} {{=field.defKey}} ;
{{~}}
$blankline
 
}

Dao层(Mapper)

{{  var today=new Date();
    var fullYear=today.getFullYear();
    var month=today.getMonth() + 1;
    var days=today.getDate();
    
    var pkVarName = "undefinedId";
    var pkDataType = "String";
    it.entity.fields.forEach(function(field){
        if(field.primaryKey){
            pkVarName = it.func.camel(field.defKey,false);
            pkDataType = field["type"];
            return;
        }
    });
    
    var pkgName = it.entity.env.base.nameSpace;
    var beanClass = it.entity.env.base.codeRoot;
    var beanVarName = beanClass.charAt(0).toLowerCase()+beanClass.slice(1);
    var serviceClass = beanClass+'Service';
    var serviceVarName= beanVarName+'Service';
    
}}package {{=pkgName}}.dao;
$blankline
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import cn.xzh.smart.core.annotataion.PageX;
import {{=pkgName}}.entity.*;
$blankline
 
 /**
 * {{=it.entity.defName}};({{=it.entity.defKey}})表数据库访问层
 * @author : heimi
 * @date : {{=fullYear}}-{{=month}}-{{=days}}
 */
@Mapper
public interface {{=beanClass}}Dao {
 
 
    @PageX
    List<{{=beanClass}}> select({{=beanClass}}Query query);
 
    Integer insert({{=beanClass}} {{=beanVarName}});
    
    Integer insertBatch(List<{{=beanClass}}> {{=beanVarName}}s);
 
    Integer update({{=beanClass}} {{=beanVarName}});
 
    Integer delete(Integer id);
 
 
}

Service层

{{  var today=new Date();
    var fullYear=today.getFullYear();
    var month=today.getMonth() + 1;
    var days=today.getDate();
    
    var pkVarName = "undefinedId";
    var pkVarNameU = "UndefinedId";
    var pkDataType = "String";
    it.entity.fields.forEach(function(field){
        if(field.primaryKey){
            pkVarName = it.func.camel(field.defKey,false);
            pkVarNameU = it.func.camel(field.defKey,true);
            pkDataType = field["type"];
            return;
        }
    });
    
    var pkgName = it.entity.env.base.nameSpace;
    var beanClass = it.entity.env.base.codeRoot;
    var beanVarName = beanClass.charAt(0).toLowerCase()+beanClass.slice(1);
    var serviceClass = beanClass+'Service';
    var serviceVarName= beanVarName+'Service';
    var daoName = beanVarName+'Dao';
    
}}package {{=pkgName}}.service;
$blankline
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import {{=pkgName}}.entity.*;
import {{=pkgName}}.dao.{{=beanClass}}Dao;
import java.util.List;
 
 /**
 * {{=it.entity.defName}};({{=it.entity.defKey}})表服务实现类
 * @author : heimi
 * @date : {{=fullYear}}-{{=month}}-{{=days}}
 */
@Service
public class {{=serviceClass}} {
   
     $blankline
    @Autowired
    private {{=beanClass}}Dao {{=daoName}};
    $blankline
    
    public List<{{=beanClass}}> select({{=beanClass}}Query query) {
        return {{=daoName}}.select(query);
    }
    $blankline
    public Integer insert({{=beanClass}} {{=beanVarName}}) {
        return {{=daoName}}.insert({{=beanVarName}});
    }
    $blankline
    public Integer update({{=beanClass}} {{=beanVarName}}) {
        return {{=daoName}}.update({{=beanVarName}});
    }
    $blankline
    public Integer delete(Integer id) {
        return {{=daoName}}.delete(id);
    }
    
    
    
 
}

Controller层

{{  var today=new Date();
    var fullYear=today.getFullYear();
    var month=today.getMonth() + 1;
    var days=today.getDate();
    
    var pkVarName = "undefinedId";
    var pkDataType = "String";
    it.entity.fields.forEach(function(field){
        if(field.primaryKey){
            pkVarName = it.func.camel(field.defKey,false);
            pkDataType = field["type"];
            return;
        }
    });
    
    var pkgName = it.entity.env.base.nameSpace;
    var beanClass = it.entity.env.base.codeRoot;
    var beanVarName = beanClass.charAt(0).toLowerCase()+beanClass.slice(1);
    var serviceClass = beanClass+'Service';
    var serviceVarName= beanVarName+'Service';
    
}}package {{=pkgName}}.controller;
$blankline
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import {{=pkgName}}.entity.*;
import {{=pkgName}}.service.{{=serviceClass}};
import java.util.List;
$blankline
 
 /**
 * {{=it.entity.defName}};({{=it.entity.defKey}})控制层
 * @author : heimi
 * @date : {{=fullYear}}-{{=month}}-{{=days}}
 */
 
@RestController
@RequestMapping("/api/{{=beanVarName}}")
public class {{=beanClass}}Controller{
    @Autowired
    private {{=serviceClass}} {{=serviceVarName}};
    $blankline
    /** 
     * 查询接口
     */
     @GetMapping
     public List<{{=beanClass}}> select({{=beanClass}}Query query){
       
        return {{=serviceVarName}}.select(query);
    }
    
    $blankline
    
    @PostMapping 
    public Integer insert(@RequestBody {{=beanClass}} product){
       return {{=serviceVarName}}.insert(product);
    }
    $blankline
    @PutMapping 
    public Integer update(@RequestBody {{=beanClass}} product){
        return {{=serviceVarName}}.update(product);
    }
    $blankline
    @DeleteMapping
    public Integer delete(Integer id){
        return {{=serviceVarName}}.delete(id);
    }
   
}

Mapper.xml

{{  var today=new Date();
    var fullYear=today.getFullYear();
    var month=today.getMonth() + 1;
    var days=today.getDate();
    
    var pkVarName = "undefinedId";
    var pkDataType = "String";
    var pkField = "UNDEFINED_ID";
    it.entity.fields.forEach(function(field){
        if(field.primaryKey){
            pkField = field.defKey;
            pkVarName = it.func.camel(field.defKey,false);
            pkDataType = field["type"];
            return;
        }
    });
    
    var pkgName = it.entity.env.base.nameSpace;
    var beanClass = it.entity.env.base.codeRoot;
    var beanVarName = beanClass.charAt(0).toLowerCase()+beanClass.slice(1);
    var serviceClass = beanClass+'Service';
    var serviceVarName= beanVarName+'Service';
    
}}<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="{{=pkgName}}.dao.{{=beanClass}}Dao">
    <resultMap type="{{=pkgName}}.entity.{{=beanClass}}" id="{{=beanClass}}Map">
    {{~it.entity.fields:field:index}}
        <result property="{{=field.defKey}}" column="{{=field.defKey}}" />
    {{~}}
    </resultMap>
    $blankline
 
    $blankline
    <!--通用查询-->
    <select id="select" resultMap="{{=beanClass}}Map">
        select
            {{=it.entity.fields.map(function(e,i){return e.defKey}).join(',')}}
        from {{=it.entity.defKey}}
        <where>
        {{~it.entity.fields:field:index}}
            <if test="{{=field.defKey}} != null and {{=field.defKey}} != ''">
                and {{=field.defKey}} = #{{{=field.defKey}}}
            </if>
        {{~}}
        </where>
       
    </select>
    $blankline
 
    <!--新增数据-->
    <insert id="insert" keyProperty="{{=pkField}}" useGeneratedKeys="true">
        insert into {{=it.entity.defKey}}({{=it.entity.fields.map(function(e,i){return e.defKey}).join(',')}})
        values ({{=it.entity.fields.map(function(e,i){return '#{'+e.defKey+'}'}).join(',')}})
    </insert>
    $blankline
    <!-- 批量新增数据 -->
    <insert id="insertBatch" keyProperty="{{=pkField}}" useGeneratedKeys="true">
        insert into {{=it.entity.defKey}}({{=it.entity.fields.map(function(e,i){return e.defKey}).join(',')}})
        values
        <foreach collection="entities" item="entity" separator=",">
            ({{=it.entity.fields.map(function(e,i){return '#{entity.'+e.defKey+'}'}).join(',')}})
        </foreach>
    </insert>
  
    $blankline
    <!-- 更新数据 -->
    <update id="update">
        update {{=it.entity.defKey}}
        <set>
        {{~it.entity.fields:field:index}}
            <if test="{{=field.defKey}} != null and {{=field.defKey}} != ''">
                {{=field.defKey}} = #{{{=field.defKey}}},
            </if>
        {{~}}
        </set>
        where {{=pkField}} = #{{{=pkVarName}}}
    </update>
    $blankline
    <!--通过主键软删除-->
    <update id="delete">
        update  {{=it.entity.defKey}} set status = 0 where {{=pkField}} = #{{{=pkVarName}}}
    </update>
</mapper>

标签:创建,defKey,entity,field,PDManer,var,blankline,模板,beanClass
From: https://blog.csdn.net/2301_78701299/article/details/143887902

相关文章

  • 实验4 类的组合、继承、模板类、标准库
    实验任务二源码:1#include<iostream>2#include<vector>3#include<string>4#include<algorithm>5#include<numeric>6#include<iomanip>78usingstd::vector;9usingstd::string;10usingstd::......
  • 类的组合、继承、模板类、标准库
    任务2GradeCalc.hpp1#include<iostream>2#include<vector>3#include<string>4#include<algorithm>5#include<numeric>6#include<iomanip>78usingstd::vector;9usingstd::string;10using......
  • HyperWorks一维单元创建与模型连接管理
    在HyperWorks的有限元分析中,一维单元是非常重要的概念。我们可以使用一维单元连接节点,或将不匹配的网格部件进行连接,进行载荷施加,以及用于建立焊接,螺栓,铆钉等等各类工程中经常运用的模型连接方式。一维单元的类型是非常多的。有简单的刚性连接单元,有包含复杂截面的梁单元,也有可以......
  • DevExpress WinForms中文教程:Data Grid - 如何创建和管理数据?
    在本教程中您将学习如何在代码中为网格控件创建数据源,还将看到如何应用数据属性使网格应用适当的编辑模式、单元格编辑器和输入验证规则。P.S:DevExpressWinForms拥有180+组件和UI库,能为WindowsForms平台创建具有影响力的业务解决方案。DevExpressWinForms能完美构建流畅、美观......
  • .gitignore模板
    当然,这里提供一个更详细的.gitignore模板,这个模板涵盖了多种编程语言和开发工具,你可以根据需要进行调整:#忽略编译生成的文件*.o*.obj*.exe*.dll*.class*.jar*.pyc__pycache__/*.pyo*.pyd*.node*.coffee*.rbc*.o*.gch*.gem*.lock*.log*.db*.db3*.sqlit......
  • PbootCMS 模板利用宝塔面板计划任务执行自动推送网址到百度
    新建PHP文件:在站点根目录新建一个PHP文件,例如 baidu.php,并复制以下代码:<?phpheader('Content-Type:text/html;charset=utf-8');/**只需修改这里面的两个链接**/$xml_url="https://你的站点/sitemap.xml";//这里修改你站点的XML地图链接$baidu_api='http......
  • java 创建线程的三种方法(Thread,Runnable,Callable)ExecutorService
    1.继承Thread类2.实现Runnable接口3.实现Callable接口4.线程池1.继承Thread类packagecom.chen;//创建线程的方式:继承Thread,重写run(),调用start()开启线程//注意,线程开启不一定立即执行,由cpu调度执行publicclassTestThread2extendsThread{@Overridepublicvoid......
  • centos7创建逻辑卷
    1.fdisk/dev/sdb 创建分区 2. p:查看分区n:创建新分区p(1-4):1输入起始号码2048开始扇区+1600M结束扇区w保存3. l 查看分区类型8e 设置成lvm格式。4.创建物理卷  pvcreate/dev/sdb1查看物理卷pvdisplay/dev/sdb15. 创建卷组 vgcreatenpgroup/d......
  • 实验4 类的组合、继承、模板类、标准库
    实验任务1:实验代码:1#include<iostream>23usingstd::cout;4usingstd::endl;56//类A的定义7classA{8public:9A(intx0,inty0);10voiddisplay()const;1112private:13intx,y;14};1516A::A(intx0,inty0):x{x0......
  • Oracle手工创建数据库和多环境变量下如何连接指定的数据库
    Oracle手工创建数据库(hefeidb)Oracle创建数据库的方法有三种:dbca、静默方式、手工建库三种方法,这里演示手工建库的方式,适用在不能运行dbca的环境下面创建库:1设置环境变量(新增一个)su-oraclecd/home/oraclecp.bash_profile.bash_profile.fgzcdbvi.bash_profileif......