春风项目四线(合箱线、总装线)
cl
2024-02-02 e0a2b80807cc52e80bf632adba9cfcb6357025aa
提交 | 用户 | 时间
fd2207 1 package ${packageName}.service.impl;
2
3 import java.util.List;
4 #foreach ($column in $columns)
5 #if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
6 import com.jcdm.common.utils.DateUtils;
7 #break
8 #end
9 #end
10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.stereotype.Service;
12 #if($table.sub)
13 import java.util.ArrayList;
14 import com.jcdm.common.utils.StringUtils;
15 import org.springframework.transaction.annotation.Transactional;
16 import ${packageName}.domain.${subClassName};
17 #end
18 import ${packageName}.mapper.${ClassName}Mapper;
19 import ${packageName}.domain.${ClassName};
20 import ${packageName}.service.I${ClassName}Service;
21
22 /**
23  * ${functionName}Service业务层处理
24  * 
25  * @author ${author}
26  * @date ${datetime}
27  */
28 @Service
29 public class ${ClassName}ServiceImpl implements I${ClassName}Service 
30 {
31     @Autowired
32     private ${ClassName}Mapper ${className}Mapper;
33
34     /**
35      * 查询${functionName}
36      * 
37      * @param ${pkColumn.javaField} ${functionName}主键
38      * @return ${functionName}
39      */
40     @Override
41     public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
42     {
43         return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
44     }
45
46     /**
47      * 查询${functionName}列表
48      * 
49      * @param ${className} ${functionName}
50      * @return ${functionName}
51      */
52     @Override
53     public List<${ClassName}> select${ClassName}List(${ClassName} ${className})
54     {
55         return ${className}Mapper.select${ClassName}List(${className});
56     }
57
58     /**
59      * 新增${functionName}
60      * 
61      * @param ${className} ${functionName}
62      * @return 结果
63      */
64 #if($table.sub)
65     @Transactional
66 #end
67     @Override
68     public int insert${ClassName}(${ClassName} ${className})
69     {
70 #foreach ($column in $columns)
71 #if($column.javaField == 'createTime')
72         ${className}.setCreateTime(DateUtils.getNowDate());
73 #end
74 #end
75 #if($table.sub)
76         int rows = ${className}Mapper.insert${ClassName}(${className});
77         insert${subClassName}(${className});
78         return rows;
79 #else
80         return ${className}Mapper.insert${ClassName}(${className});
81 #end
82     }
83
84     /**
85      * 修改${functionName}
86      * 
87      * @param ${className} ${functionName}
88      * @return 结果
89      */
90 #if($table.sub)
91     @Transactional
92 #end
93     @Override
94     public int update${ClassName}(${ClassName} ${className})
95     {
96 #foreach ($column in $columns)
97 #if($column.javaField == 'updateTime')
98         ${className}.setUpdateTime(DateUtils.getNowDate());
99 #end
100 #end
101 #if($table.sub)
102         ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
103         insert${subClassName}(${className});
104 #end
105         return ${className}Mapper.update${ClassName}(${className});
106     }
107
108     /**
109      * 批量删除${functionName}
110      * 
111      * @param ${pkColumn.javaField}s 需要删除的${functionName}主键
112      * @return 结果
113      */
114 #if($table.sub)
115     @Transactional
116 #end
117     @Override
118     public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s)
119     {
120 #if($table.sub)
121         ${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
122 #end
123         return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s);
124     }
125
126     /**
127      * 删除${functionName}信息
128      * 
129      * @param ${pkColumn.javaField} ${functionName}主键
130      * @return 结果
131      */
132 #if($table.sub)
133     @Transactional
134 #end
135     @Override
136     public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
137     {
138 #if($table.sub)
139         ${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
140 #end
141         return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
142     }
143 #if($table.sub)
144
145     /**
146      * 新增${subTable.functionName}信息
147      * 
148      * @param ${className} ${functionName}对象
149      */
150     public void insert${subClassName}(${ClassName} ${className})
151     {
152         List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
153         ${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
154         if (StringUtils.isNotNull(${subclassName}List))
155         {
156             List<${subClassName}> list = new ArrayList<${subClassName}>();
157             for (${subClassName} ${subclassName} : ${subclassName}List)
158             {
159                 ${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
160                 list.add(${subclassName});
161             }
162             if (list.size() > 0)
163             {
164                 ${className}Mapper.batch${subClassName}(list);
165             }
166         }
167     }
168 #end
169 }