IDEA??????????????EasyCode

网友投稿 430 2023-01-20

IDEA----??EasyCode

IDEA----??EasyCode

1--IntelliJ IDEA --??maven-?

2------

3---?EasyCode-?

file->settings->plugins -?Easy Code

----Install ----?? ------IDEA??

------?? file->settings->Other settings --??Easy Code--??

4--Easy Code-? -------? ------

5------??

6----------------

-?IDEA--Datbase->----??->-?Data Source.->mysql

7----

-------?mysql8---------?jdbc:mysql://localhost:3306/table?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=false

8------

9--springboot--pom.xml-?

org.springframework.boot

spring-boot-starter-web

org.mybatis.spring.boot

mybatis-spring-boot-starter

1.3.2

mysql

mysql-connector-java

5.1.38

--??mybatis--------

10--Easy Code-? ---?entity,controller,service??serviceimpl,dao

--??->Easy Code->Generate Code

Module----??

package:------??

Template:---?

11--All------------------??OK

12---?

entity.java--

##---?

$!define

$!init

##-------------?

#save("/entity", ".java")

##------??

#setPackageSuffix("entity")

##--------??

$!autoImport

import java.io.Serializable;

import lombok.Data;

##--------

#tableComment("--")

@Data

public class $!{tableInfo.name} implements Serializable {

private static final long serialVersionUID = $!tool.serial();

#foreach($column in $tableInfo.fullColumn)

#if(${column.comment})/**

* ${column.comment}

*/#end

private $!{tool.getClsNameByFullName($column.type)} $!{column.name};

#end

}

controller--controller.java---?

##----

#set($tableName = $tool.append($tableInfo.name, "Controller"))

##--??

$!callback.setFileName($tool.append($tableName, ".java"))

$!callback.setSavePath($tool.append($tableInfo.savePath, "/controller"))

##--??

#if(!$tableInfo.pkColumn.isEmpty())

#set($pk = $tableInfo.pkColumn.get(0))

#end

#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}controller;

import lombok.extern.slf4j.Slf4j;

import com.github.pagehelper.PageInfo;

import $!{tableInfo.savePackageName}.response.PageResult;

import $!{tableInfo.savePackageName}.response.Result;

import $!{tableInfo.savePackageName}.response.StatusCode;

import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};

import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;

import org.springframework.web.bind.annotation.*;

import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;

import java.util.List;

import java.util.Objects;

/**

* $!{tableInfo.comment}($!{tableInfo.name})--

*

* @author protagonist

* @since $!time.currTime()

*/

@RestController

@Slf4j

@RequestMapping("/$!tool.firstLowerCase($tableInfo.name)")

public class $!{tableName} {

/**

* --??

*/

@Resource

private $!{tableInfo.name}Service $!tool.firstLowerCase($tableInfo.name)ServiceImpl;

/**

* ------??

*

* @param $!pk.name -?

* @return --??

*/

@GetMapping(value = "/get/{$!pk.name}")

public Result selectOne(@PathVariable("$!pk.name") $!pk.shortType $!pk.name) {

$tableInfo.name result = $!{tool.firstLowerCase($tableInfo.name)}ServiceImpl.selectById(id);

if(Objects.nonNull(result)){

return new Result<>(true,StatusCode.OK,"--??",result);

}

return new Result<>(true,StatusCode.ERROR,"--??");

}

/**

* ----

*

* @param $!tool.firstLowerCase($tableInfo.name) --

* @return Result-?

*/

@PostMapping(value = "/insert")

public Result insert(@RequestBody $tableInfo.name $!tool.firstLowerCase($tableInfo.name)) {

int result = $!{tool.firstLowerCase($tableInfo.name)}ServiceImpl.insert($!tool.firstLowerCase($tableInfo.name));

if (result > 0) {

return new Result<>(true,StatusCode.OK,"--??",result);

}

return new Result<>(true,StatusCode.ERROR,"--??");

}

/**

* ----

*

* @param $!tool.firstLowerCase($tableInfo.name) --

* @return Result-?

*/

@PutMapping(value = "/update")

public Result update(@RequestBody $tableInfo.name $!tool.firstLowerCase($tableInfo.name)) {

$tableInfo.name result = $!{tool.firstLowerCase($tableInfo.name)}ServiceImpl.update($!tool.firstLowerCase($tableInfo.name));

if (Objects.nonNull(result)) {

return new Result<>(true,StatusCode.OK,"--??",result);

}

return new Result<>(true,StatusCode.ERROR,"--??");

}

/**

* ----

*

* @param $!pk.name -?

* @return Result-?

*/

@DeleteMapping(value = "/delete/{$!pk.name}")

public Result delete(@PathVariable("$!pk.name") $!pk.shortType $!pk.name) {

int result = $!{tool.firstLowerCase($tableInfo.name)}ServiceImpl.deleteById($!pk.name);

if (result > 0) {

return new Result<>(true,StatusCode.OK,"--??",result);

}

return new Result<>(true,StatusCode.ERROR,"--??");

}

/**

* --??

*

* @return Result-?

*/

@GetMapping(value = "/selectAll")

public Result> selectAll() {

List<$tableInfo.name> $!tool.firstLowerCase($tableInfo.name)s = $!{tool.firstLowerCase($tableInfo.name)}ServiceImpl.selectAll();

if (CollectionUtils.isEmpty($!tool.firstLowerCase($tableInfo.name)s)) {

return new Result<>(true,StatusCode.ERROR,"-----?");

}

return new Result<>(true,StatusCode.OK,"-----?",$!tool.firstLowerCase($tableInfo.name)s);

}

/**

* --??

*

* @param current -- --------??

* @param size -----?

* @return Result-?

*/

@GetMapping(value = "/selectPage/{current}/{size}")

public Result selectPage(@PathVariable("current") Integer current,@PathVariable("size") Integer size) {

PageInfo<$tableInfo.name> page = $!{tool.firstLowerCase($tableInfo.name)}ServiceImpl.selectPage(current, size);

if (Objects.nonNull(page)) {

return new Result<>(true,StatusCode.OK,"-----?",new PageResult<>(page.getTotal(),page.getList()));

}

return new Result<>(true,StatusCode.ERROR,"-----?");

}

}

service-?:service.java ---?

##----

#set($tableName = $tool.append($tableInfo.name, "Service"))

##--??

$!callback.setFileName($tool.append($tableName, ".java"))

$!callback.setSavePath($tool.append($tableInfo.savePath, "/service"))

##--??

#if(!$tableInfo.pkColumn.isEmpty())

#set($pk = $tableInfo.pkColumn.get(0))

#end

#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service;

import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};

import java.util.List;

import com.github.pagehelper.PageInfo;

/**

* $!{tableInfo.comment}($!{tableInfo.name})---?

*

* @author protagonist

* @since $!time.currTime()

*/

public interface $!{tableName} {

/**

* -?ID----

*

* @param $!pk.name -?

* @return --??

*/

$!{tableInfo.name} selectById($!pk.shortType $!pk.name);

/**

* --??

*

* @param current --

* @param size -----?

* @return --??

*/

PageInfo<$!{tableInfo.name}> selectPage(int current, int size);

/**

* --??

*

* @return --??

*/

List<$!{tableInfo.name}> selectAll();

/**

* --------

*

* @param $!tool.firstLowerCase($!{tableInfo.name}) --??

* @return --??

*/

List<$!{tableInfo.name}> selectList($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));

/**

* --??

*

* @param $!tool.firstLowerCase($!{tableInfo.name}) --??

* @return --??

*/

int insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));

/**

* --??

*

* @param $!tool.firstLowerCase($!{tableInfo.name})s ----??

* @return --??

*/

int batchInsert(List<$!{tableInfo.name}> $!tool.firstLowerCase($!{tableInfo.name})s);

/**

* --??

*

* @param $!tool.firstLowerCase($!{tableInfo.name}) --??

* @return -?

*/

$!{tableInfo.name} update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));

/**

* -----?

*

* @param $!pk.name -?

* @return --??

*/

int deleteById($!pk.shortType $!pk.name);

/**

* ----

*

* @return --??

*/

int count();

}

serviceImpl --:serviceImpl .java---?

##----

#set($tableName = $tool.append($tableInfo.name, "ServiceImpl"))

##--??

$!callback.setFileName($tool.append($tableName, ".java"))

$!callback.setSavePath($tool.append($tableInfo.savePath, "/service/impl"))

##--??

#if(!$tableInfo.pkColumn.isEmpty())

#set($pk = $tableInfo.pkColumn.get(0))

#end

#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}service.impl;

import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};

import $!{tableInfo.savePackageName}.dao.$!{tableInfo.name}Dao;

import $!{tableInfo.savePackageName}.service.$!{tableInfo.name}Service;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;

import com.github.pagehelper.PageInfo;

import javax.annotation.Resource;

import java.util.List;

/**

* $!{tableInfo.comment}($!{tableInfo.name}??)---?

*

* @author protagonist

* @since $!time.currTime()

*/

@Service("$!tool.firstLowerCase($!{tableInfo.name})ServiceImpl")

public class $!{tableName} implements $!{tableInfo.name}Service {

@Resource

private $!{tableInfo.name}Dao $!tool.firstLowerCase($!{tableInfo.name})Dao;

/**

* -?ID----

*

* @param $!pk.name -?

* @return --??

*/

@Override

public $!{tableInfo.name} selectById($!pk.shortType $!pk.name) {

return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.selectById($!pk.name);

}

/**

* --??

*

* @param current --

* @param size ----

* @return --??

*/

@Override

public PageInfo<$!{tableInfo.name}> selectPage(int current, int size) {

PageHelper.startPage(current,size);

List<$!{tableInfo.name}> dataList = $!{tool.firstLowerCase($!{tableInfo.name})}Dao.selectAll();

return new PageInfo<>(dataList);

}

/**

* --??

*

* @return ----??

*/

@Override

public List<$!{tableInfo.name}> selectAll() {

return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.selectAll();

}

/**

* ----

*

* @return ----??

*/

@Override

public List<$!{tableInfo.name}> selectList($!{tableInfo.name} $!{tool.firstLowerCase($!{tableInfo.name})}) {

return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.selectList($!{tool.firstLowerCase($!{tableInfo.name})});

}

/**

* --??

*

* @param $!tool.firstLowerCase($!{tableInfo.name}) --??

* @return --??

*/

@Override

@Transactional

public int insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {

return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.insert($!tool.firstLowerCase($!{tableInfo.name}));

}

/**

* --??

*

* @param $!tool.firstLowerCase($!{tableInfo.name})s ----??

* @return ---?

*/

@Override

@Transactional

public int batchInsert(List<$!{tableInfo.name}> $!tool.firstLowerCase($!{tableInfo.name})s) {

return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.batchInsert($!tool.firstLowerCase($!{tableInfo.name})s);

}

/**

* --??

*

* @param $!tool.firstLowerCase($!{tableInfo.name}) --??

* @return --??

*/

@Override

@Transactional

public $!{tableInfo.name} update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name})) {

this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.update($!tool.firstLowerCase($!{tableInfo.name}));

return this.selectById($!{tool.firstLowerCase($!{tableInfo.name})}.get$!tool.firstUpperCase($pk.name)());

}

/**

* -----?

*

* @param $!pk.name -?

* @return --??

*/

@Override

@Transactional

public int deleteById($!pk.shortType $!pk.name) {

return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.deleteById($!pk.name);

}

/**

* ----

*

* @return --??

*/

@Override

public int count(){

return this.$!{tool.firstLowerCase($!{tableInfo.name})}Dao.count();

}

}

dao-?dao.java--??

##----

#set($tableName = $tool.append($tableInfo.name, "Dao"))

##--??

$!callback.setFileName($tool.append($tableName, ".java"))

$!callback.setSavePath($tool.append($tableInfo.savePath, "/dao"))

##--??

#if(!$tableInfo.pkColumn.isEmpty())

#set($pk = $tableInfo.pkColumn.get(0))

#end

#if($tableInfo.savePackageName)package $!{tableInfo.savePackageName}.#{end}dao;

import $!{tableInfo.savePackageName}.entity.$!{tableInfo.name};

import org.apache.ibatis.annotations.Mapper;

import org.apache.ibatis.annotations.Param;

import java.util.List;

/**

* $!{tableInfo.comment}($!{tableInfo.name})----??

*

* @author protagonist

* @since $!time.currTime()

*/

@Mapper

public interface $!{tableName} {

/**

* -?ID----

*

* @param $!pk.name -?

* @return --??

*/

$!{tableInfo.name} selectById($!pk.shortType $!pk.name);

/**

* --??

*

* @return --??

*/

List<$!{tableInfo.name}> selectAll();

/**

* --------

*

* @param $!tool.firstLowerCase($!{tableInfo.name}) --??

* @return --??

*/

List<$!{tableInfo.name}> selectList($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));

/**

* --??

*

* @param $!tool.firstLowerCase($!{tableInfo.name}) --??

* @return --??

*/

int insert($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));

/**

* --??

*

* @param $!tool.firstLowerCase($!{tableInfo.nameItYXbNhjXW})s ----??

* @return --??

*/

int batchInsert(List<$!{tableInfo.name}> $!tool.firstLowerCase($!{tableInfo.name})s);

/**

* --??

*

* @param $!tool.firstLowerCase($!{tableInfo.name}) --??

* @return --??

*/

int update($!{tableInfo.name} $!tool.firstLowerCase($!{tableInfo.name}));

/**

* -----?

*

* @param $!pk.name -?

* @return --??

*/

int deleteById($!pk.shortType $!pk.name);

/**

* ----

*

* @return --??

*/

int count();

}

mapper.xml---?

##-?mybatis-?

$!mybatisSupport

##-------?

$!callback.setFileName($tool.append($!{tableInfo.name}, "Dao.xml"))

$!callback.setSavePath($tool.append($modulePath, "/src/main/resources/mapper"))

##--??

#if(!$tableInfo.pkColumn.isEmpty())

#set($pk = $tableInfo.pkColumn.get(0))

#end

#foreach($column in $tableInfo.fullColumn)

#end

#allSqlColumn()

select

from $!tableInfo.obj.name

where $!pk.obj.name = #{$!pk.name}

select

from $!tableInfo.obj.name

select

from $!tableInfo.obj.name

#foreach($column in $tableInfo.fullColumn)

and $!column.obj.name = #{$!column.name}

#end

insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.fullColumn)$!column.obj.name#if($velocityHasNext), #end#end)

values ( #foreach($column in $tableInfo.fullColumn)#{$!{column.name}}#if($velocityHasNext), #end#end)

insert into $!{tableInfo.obj.name}(#foreach($column in $tableInfo.fullColumn)$!column.obj.name#if($velocityHasNext), #end#end)

values

(

#foreach($column in $tableInfo.fullColumn)

#{item.$!{column.name}}#if($velocityHasNext), #end

#end

)

update $!{tableInfo.obj.parent.name}.$!{tableInfo.obj.name}

#foreach($column in $tableInfo.otherColumn)

$!column.obj.name = #{$!column.name},

#end

where $!pk.obj.name = #{$!pk.name}

delete from $!{tableInfo.obj.name} where $!pk.obj.name = #{$!pk.name}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:购物小程序生态(基于微信小程序的购物系统)
下一篇:pwa版(pwa版微博下载)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~