Skip to content

Commit

Permalink
移除废弃方法
Browse files Browse the repository at this point in the history
  • Loading branch information
hykes committed Oct 14, 2020
1 parent d6a0bb1 commit 640bfb5
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ out/
.idea
*.iml
*.zip
*.DS_Store

build/
.gradle
.sandbox
gradle.properties
gradle.properties
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright © 2019 CodeGen
Copyright © 2020 CodeGen

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ https://www.jetbrains.com/help/idea/meet-intellij-idea.html
* [IceMimosa](https://github.com/IceMimosa)

## License
Copyright © 2019 [MIT License](https://github.com/hykes/CodeGen/blob/master/LICENSE)
Copyright © 2020 [MIT License](https://github.com/hykes/CodeGen/blob/master/LICENSE)


20 changes: 11 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "gradle.plugin.org.jetbrains.intellij.plugins:gradle-intellij-plugin:0.4.3"
classpath "gradle.plugin.org.jetbrains.intellij.plugins:gradle-intellij-plugin:0.4.21"
}
}

plugins {
id 'org.jetbrains.intellij' version '0.4.3'
id 'java'
id 'org.jetbrains.intellij' version '0.4.21'
}

group 'me.hehaiyang.codegen'
version '1.3.0'
version '1.3.2'

sourceCompatibility = 1.8
targetCompatibility = 1.8

apply plugin: 'idea'
apply plugin: 'org.jetbrains.intellij'
apply plugin: "org.jetbrains.intellij"
apply plugin: 'java'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenLocal()
Expand All @@ -34,8 +36,8 @@ dependencies {
}

intellij {
// version '2017.3.1'
localPath ideaSDKlocalPath
pluginName 'CodeGen'
sandboxDirectory = project.rootDir.canonicalPath + "/.sandbox"
plugins = ['java']
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun May 05 15:28:40 CST 2019
#Sun Jul 26 21:46:05 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ public Component getTreeCellRendererComponent(JTree tree, Object value,
if (obj instanceof CodeRoot) {
CodeRoot node = (CodeRoot) obj;
DefaultTreeCellRenderer tempCellRenderer = new DefaultTreeCellRenderer();
tempCellRenderer.setOpenIcon(AllIcons.Nodes.JavaModuleRoot);
tempCellRenderer.setClosedIcon(AllIcons.Nodes.JavaModuleRoot);
tempCellRenderer.setLeafIcon(AllIcons.Nodes.JavaModuleRoot);
tempCellRenderer.setOpenIcon(AllIcons.Nodes.JavaModule);
tempCellRenderer.setClosedIcon(AllIcons.Nodes.JavaModule);
tempCellRenderer.setLeafIcon(AllIcons.Nodes.JavaModule);
return tempCellRenderer.getTreeCellRendererComponent(tree, node.getName(), selected, expanded, false, row, hasFocus);
}
else if (obj instanceof CodeGroup) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private List<AnAction> getMultipleActions(DefaultMutableTreeNode selectedNode) {
class CodeRootAddAction extends AnAction {

public CodeRootAddAction() {
super("Code Root", null, AllIcons.Nodes.JavaModuleRoot);
super("Code Root", null, AllIcons.Nodes.JavaModule);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.ui.PackageChooser;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.JavaDirectoryService;
Expand Down Expand Up @@ -63,9 +64,9 @@ public void actionPerformed(ActionEvent e) {
descriptor.setShowFileSystemRoots(false);
descriptor.setDescription("Select output path");
descriptor.setHideIgnored(true);
descriptor.setRoots(project.getBaseDir());
descriptor.setRoots(ProjectRootManager.getInstance(project).getContentRoots());
descriptor.setForcedToUseIdeaFileChooser(true);
VirtualFile virtualFile = FileChooser.chooseFile(descriptor, project, project.getBaseDir());
VirtualFile virtualFile = FileChooser.chooseFile(descriptor, project, project.getProjectFile());
if (Objects.nonNull(virtualFile)) {
String output = virtualFile.getPath();
PsiDirectory psiDirectory = PsiDirectoryFactory.getInstance(project).createDirectory(virtualFile);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/github/hykes/codegen/utils/PsiUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiClass;
Expand Down Expand Up @@ -86,9 +87,9 @@ public static PsiDirectory createDirectory(Project project, String title, String
descriptor.setShowFileSystemRoots(false);
descriptor.setDescription(description);
descriptor.setHideIgnored(true);
descriptor.setRoots(project.getBaseDir());
descriptor.setRoots(ProjectRootManager.getInstance(project).getContentRoots());
descriptor.setForcedToUseIdeaFileChooser(true);
VirtualFile file = FileChooser.chooseFile(descriptor, project, project.getBaseDir());
VirtualFile file = FileChooser.chooseFile(descriptor, project, project.getProjectFile());
if(Objects.isNull(file)){
Messages.showInfoMessage("Cancel " + title, "Error");
return null;
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin>
<id>me.hehaiyang.codegen</id>
<name>CodeGen</name>
<version>1.3.1</version>
<version>1.3.2</version>
<vendor email="[email protected]" url="https://github.com/hykes">hykes</vendor>

<description><![CDATA[
Expand Down Expand Up @@ -39,6 +39,7 @@
<depends>com.intellij.modules.lang</depends>
-->
<depends optional="true" config-file="withDatabase.xml">com.intellij.database</depends>
<depends>com.intellij.modules.java</depends>
<!--<depends optional="true">com.intellij.modules.ultimate</depends>-->

<extensions defaultExtensionNs="com.intellij">
Expand Down
125 changes: 125 additions & 0 deletions src/main/resources/mapper/AppQuotationProductsMapper.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?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">
<!--
~
~ @author [ your email ]
~ @date 2020-10-12 23:14:50
~ Created by CodeGen .
-->

<mapper namespace="AppQuotationProducts">
<resultMap id="AppQuotationProductsMap" type="AppQuotationProducts">
<id property="id" column="id"/>
<result property="quotationId" column="quotation_id"/>
<result property="productId" column="product_id"/>
<result property="createdAt" column="created_at"/>
<result property="updatedAt" column="updated_at"/>
</resultMap>

<sql id="table_name">
app_quotation_products
</sql>

<sql id="columns_all">
id,
<include refid="columns_exclude_id"/>
</sql>

<sql id="columns_exclude_id">
`quotation_id`, `product_id`, created_at, updated_at
</sql>

<sql id="values_exclude_id">
#{quotationId}, #{productId}, now(), now()
</sql>

<sql id="criteria">
<where>
<if test="quotationId != null">AND `quotation_id` = #{quotationId}</if>
<if test="productId != null">AND `product_id` = #{productId}</if>
<if test="createdAt != null">AND <![CDATA[created_at >= #{createdAt}]]> </if>
<if test="updatedAt != null">AND <![CDATA[updated_at < #{updatedAt}]]> </if>
</where>
</sql>

<insert id="create" parameterType="AppQuotationProducts" useGeneratedKeys="true" keyProperty="id">
INSERT INTO
<include refid="table_name"/>
(<include refid="columns_exclude_id"/>)
VALUES
(<include refid="values_exclude_id"/>)
</insert>

<insert id="creates" parameterType="AppQuotationProducts" useGeneratedKeys="true">
INSERT INTO
<include refid="table_name"/>
(<include refid="columns_exclude_id"/>)
VALUES
<foreach collection="list" item="i" index="index" separator=",">
(#{i.quotationId}, #{i.productId}, now(), now())
</foreach>
</insert>

<select id="findById" parameterType="long" resultMap="AppQuotationProductsMap">
SELECT
<include refid="columns_all"/>
FROM
<include refid="table_name"/>
WHERE id = #{id} LIMIT 1
</select>

<select id="findByIds" parameterType="list" resultMap="AppQuotationProductsMap">
SELECT
<include refid="columns_all"/>
FROM
<include refid="table_name"/>
WHERE id IN
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
</select>

<update id="update" parameterType="AppQuotationProducts">
UPDATE
<include refid="table_name"/>
<set>
<if test="quotationId != null">`quotation_id` = #{quotationId},</if>
<if test="productId != null">`product_id` = #{productId},</if>
updated_at = now()
</set>
WHERE id = #{id}
</update>

<delete id="delete" parameterType="long">
DELETE FROM
<include refid="table_name"/>
WHERE id = #{id}
</delete>

<select id="count" parameterType="map" resultType="long">
SELECT COUNT(1)
FROM
<include refid="table_name"/>
<include refid="criteria"/>
</select>

<select id="paging" parameterType="map" resultMap="AppQuotationProductsMap">
SELECT
<include refid="columns_all"/>
FROM
<include refid="table_name"/>
<include refid="criteria"/>
ORDER BY `id` DESC
LIMIT #{offset}, #{limit}
</select>

<select id="list" parameterType="map" resultMap="AppQuotationProductsMap">
SELECT
<include refid="columns_all"/>
FROM
<include refid="table_name"/>
<include refid="criteria"/>
ORDER BY `id` DESC
</select>

</mapper>

0 comments on commit 640bfb5

Please sign in to comment.