create java program by some value
prepare
.sh
rm -rf src \
&& mkdir -p src/main/java/com/xxx/xxx/controller \
&& mkdir src/main/java/com/xxx/xxx/service \
&& mkdir src/main/java/com/xxx/xxx/mapper \
&& mkdir -p src/main/resources/com/xxx/xxx/mapper
spring controller/service/mapper/xml
.sh
PRG_UID=FUNC01 \
&& PROJECT_PATH=com/xxx/xxx \
&& PROJECT_PATHW=com.xxx.xxx \
&& SUFFIX_C=Controller.java \
&& SUFFIX_CP=controller \
&& SUFFIX_S=Service.java \
&& SUFFIX_SP=service \
&& SUFFIX_M=Mapper.java \
&& SUFFIX_MX=Mapper.xml \
&& SUFFIX_MP=mapper \
&& touch src/main/java/$PROJECT_PATH/$SUFFIX_CP/$PRG_UID$SUFFIX_C \
&& touch src/main/java/$PROJECT_PATH/$SUFFIX_SP/$PRG_UID$SUFFIX_S \
&& touch src/main/java/$PROJECT_PATH/$SUFFIX_MP/$PRG_UID$SUFFIX_M \
&& touch src/main/resources/$PROJECT_PATH/$SUFFIX_MP/$PRG_UID$SUFFIX_MX \
&& cat - << EOF >> src/main/java/$PROJECT_PATH/$SUFFIX_CP/$PRG_UID$SUFFIX_C
package $PROJECT_PATHW.$SUFFIX_CP;
import $PROJECT_PATHW.$SUFFIX_SP.$PRG_UID$SUFFIX_S;
@Controller
public class $PRG_UID$SUFFIX_C {
/** service */
@Autowired
private $PRG_UID$SUFFIX_S service;
}
EOF
cat - << EOF >> src/main/java/$PROJECT_PATH/$SUFFIX_SP/$PRG_UID$SUFFIX_S
package $PROJECT_PATHW.$SUFFIX_SP;
import $PROJECT_PATHW.$SUFFIX_MP.$PRG_UID$SUFFIX_M;
@Service
public class $PRG_UID$SUFFIX_S {
/** mapper */
@Autowired
private $PRG_UID$SUFFIX_M mapper;
}
EOF
cat - << EOF >> src/main/java/$PROJECT_PATH/$SUFFIX_MP/$PRG_UID$SUFFIX_M
package $PROJECT_PATHW.$SUFFIX_MP;
@Mapper
public interface $PRG_UID$SUFFIX_M {
}
EOF
and edit import by you IDE
fix crlf for windows
.bat
set SAKURA_EXE='C:¥Program Files (x86)¥sakura¥sakura.exe'
set PRIJECT_ROOT_NAME=xxx
set PROJECT_COMMON_PATH=com¥xxx¥xxx
set PRG_UID=FUNC01
cd %userprofile%¥git¥%PRIJECT_ROOT_NAME%
cd src¥main¥java¥%PROJECT_COMMON_PATH%
%SAKURA_EXE% controller¥%FUNC01%Controller.java
%SAKURA_EXE% service¥%FUNC01%Service.java
%SAKURA_EXE% mapper¥%FUNC01%Mapper.java
cd src¥main¥resources¥%PROJECT_COMMON_PATH%
%SAKURA_EXE% mapper¥%FUNC01%Mapper.xml
open_by_explorer.bat
set PRIJECT_ROOT_NAME=xxx
set PROJECT_COMMON_PATH=com¥xxx¥xxx
explorer %userprofile%¥git¥%PRIJECT_ROOT_NAME%¥src¥main¥java¥%PROJECT_COMMON_PATH%¥controller
explorer %userprofile%¥git¥%PRIJECT_ROOT_NAME%¥src¥main¥java¥%PROJECT_COMMON_PATH%¥service
explorer %userprofile%¥git¥%PRIJECT_ROOT_NAME%¥src¥main¥java¥%PROJECT_COMMON_PATH%¥mapper
explorer %userprofile%¥git¥%PRIJECT_ROOT_NAME%¥src¥main¥resources¥%PROJECT_COMMON_PATH%mapper
(spread sheet) dto
paste on A1
.tsv
型 物理名 論理名
String id ああ ="/** "&C2&" */"&CHAR(10)&"private "&A2&" "&B2&";"
String name いい ="/** "&C3&" */"&CHAR(10)&"private "&A3&" "&B3&";"
String test うう ="/** "&C4&" */"&CHAR(10)&"private "&A4&" "&B4&";"
(spread sheet) mapper interface
paste on A1
.tsv
interface名 testAceFunc 戻り型 List<String> 答え javadoc
型 物理名 論理名 ="public "&D1&" "&B1&"(" /**
String userId あああ ="@Param("""&B3&""") "&A3&" "&B3&"," =" * @param "&B3&" "&C3
String tetId いいい ="@Param("""&B4&""") "&A4&" "&B4&"," =" * @param "&B4&" "&C4
String nameId ううう ="@Param("""&B5&""") "&A5&" "&B5&"," =" * @param "&B5&" "&C5
String eeeId えええ ="@Param("""&B6&""") "&A6&" "&B6&"," =" * @param "&B6&" "&C6
); * @return 取得結果
*/
(spread sheet) sql xml
.xml
<select id="interfaceName" resultType="EntityName">
SELECT
*
FROM
table_name tn
WHERE
user_id = #{userId}
AND user_id = #{userId}
</select>
class EntityA {
private String id;
private String title;
private List<EntityB> posts;
}
.xml
<resultMap id="mapmap" type="EntityA">
<id property="id" column="blog_id" />
<result property="title" column="blog_title"/>
<collection property="posts" ofType="EntityB">
<id property="id" column="post_id"/>
<result property="subject" column="post_subject"/>
<result property="body" column="post_body"/>
</collection>
</resultMap>
<select id="selectBlog" resultMap="mapmap">
SELECT
B.id as blog_id,
B.title as blog_title,
B.author_id as blog_author_id, -- ignore
P.id as post_id, -- in list
P.subject as post_subject, -- in list
P.body as post_body -- in list
FROM
Blog B
LEFT OUTER JOIN
Post P
ON
B.id = P.blog_id
WHERE
B.id = #{id}
</select>