Prechádzať zdrojové kódy

[chg] service和controller业务代码示例

wcz 5 rokov pred
rodič
commit
fa4d5d4476

+ 1 - 0
.gitignore

@@ -10,6 +10,7 @@
 .settings
 .springBeans
 .sts4-cache
+./logs
 
 ### IntelliJ IDEA ###
 .idea

+ 11 - 1
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/oa/controller/LiftCertificateController.java

@@ -3,6 +3,7 @@ package cn.com.ty.lift.enterprise.oa.controller;
 import cn.com.ty.lift.enterprise.oa.entity.LiftCertificate;
 import cn.com.ty.lift.enterprise.oa.service.LiftCertificateService;
 import cn.com.xwy.boot.web.dto.RestResponse;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -11,16 +12,25 @@ import org.springframework.web.bind.annotation.RestController;
 /**
  * Created by Administrator on 2019/11/26.
  */
+@Slf4j
 @RestController
 @RequestMapping("liftCertificate")
 public class LiftCertificateController {
     @Autowired
     private LiftCertificateService liftCertificateService;
 
+    /**
+     * @description 
+     * @date 2019/11/27 10:11
+     * @param
+     * @return
+     */
     @GetMapping("findOne")
     public RestResponse<LiftCertificate> findOne(Long id){
-        System.err.println("id: " + id);
+        log.info("id: " + id);
         LiftCertificate entity = liftCertificateService.findOne(id);
         return RestResponse.ok(entity);
     }
+
+
 }

+ 1 - 1
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/oa/entity/LiftCertificate.java

@@ -26,7 +26,7 @@ public class LiftCertificate {
 
 	private Date expirationDate;
 
-	private String type;
+	private String certificateType;
 
 	private Byte status;
 

+ 7 - 0
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/oa/mapper/LiftCertificateMapper.java

@@ -3,6 +3,11 @@ package cn.com.ty.lift.enterprise.oa.mapper;
 
 import cn.com.ty.lift.enterprise.oa.entity.LiftCertificate;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
 
 /**
  * MyBatis Mapper 接口 - 表:lift_certificate
@@ -21,4 +26,6 @@ public interface LiftCertificateMapper extends BaseMapper<LiftCertificate>{
 	int updateByPrimaryKeySelective(LiftCertificate record);
 
 	int updateByPrimaryKey(LiftCertificate record);
+
+	List<LiftCertificate> selectByTypeCondition(IPage<LiftCertificate> page, @Param("param") Map<String,Object> param);
 }

+ 132 - 5
lift-enterprise-service/src/main/resources/logback-spring.xml

@@ -1,8 +1,135 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<configuration
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://www.padual.com/java/logback.xsd"
+        debug="false" scan="true" scanPeriod="30 second">
 
-<configuration debug="false" scan="false">
-    <include resource="cn/com/xwy/boot/logging/logback/defaults.xml"/>
-    <!-- Level: ALL > TRACE > FATAL > DEBUG > INFO > WARN > ERROR > OFF -->
-    <Logger name="cn.com.ty.lift" level="DEBUG"/>
-    <root level="info"/>
+    <property name="PROJECT" value="lift-enterprise" />
+    <property name="ROOT" value="logs/${PROJECT}/" />
+    <property name="FILESIZE" value="50MB" />
+    <property name="MAXHISTORY" value="100" />
+    <timestamp key="DATETIME" datePattern="yyyy-MM-dd HH:mm:ss" />
+    <!-- 控制台打印 -->
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder charset="utf-8">
+            <pattern>[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
+            </pattern>
+        </encoder>
+    </appender>
+    <!-- ERROR 输入到文件,按日期和文件大小 -->
+    <appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <encoder charset="utf-8">
+            <pattern>[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
+            </pattern>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>ERROR</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${ROOT}%d/error.%i.log</fileNamePattern>
+            <maxHistory>${MAXHISTORY}</maxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy
+                    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>${FILESIZE}</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+    </appender>
+
+    <!-- WARN 输入到文件,按日期和文件大小 -->
+    <appender name="WARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <encoder charset="utf-8">
+            <pattern>[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
+            </pattern>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>WARN</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${ROOT}%d/warn.%i.log</fileNamePattern>
+            <maxHistory>${MAXHISTORY}</maxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>${FILESIZE}</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+    </appender>
+
+    <!-- INFO 输入到文件,按日期和文件大小 -->
+    <appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <encoder charset="utf-8">
+            <pattern>[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
+            </pattern>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>INFO</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${ROOT}%d/info.%i.log</fileNamePattern>
+            <maxHistory>${MAXHISTORY}</maxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>${FILESIZE}</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+    </appender>
+    <!-- DEBUG 输入到文件,按日期和文件大小 -->
+    <appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <encoder charset="utf-8">
+            <pattern>[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
+            </pattern>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>DEBUG</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${ROOT}%d/debug.%i.log</fileNamePattern>
+            <maxHistory>${MAXHISTORY}</maxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy
+                    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>${FILESIZE}</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+    </appender>
+    <!-- TRACE 输入到文件,按日期和文件大小 -->
+    <appender name="TRACE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <encoder charset="utf-8">
+            <pattern>[%-5level] %d{${DATETIME}} [%thread] %logger{36} - %m%n
+            </pattern>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>TRACE</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+        <rollingPolicy
+                class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${ROOT}%d/trace.%i.log</fileNamePattern>
+            <maxHistory>${MAXHISTORY}</maxHistory>
+            <timeBasedFileNamingAndTriggeringPolicy
+                    class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>${FILESIZE}</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+        </rollingPolicy>
+    </appender>
+
+    <!-- SQL相关日志输出-->
+    <logger name="org.apache.ibatis" level="INFO" additivity="true" />
+    <logger name="org.mybatis.spring" level="INFO" additivity="false" />
+    <logger name="com.github.miemiedev.mybatis.paginator" level="INFO" additivity="false" />
+
+    <!-- Logger 根目录 -->
+    <root level="INFO">
+        <appender-ref ref="STDOUT" />
+        <appender-ref ref="DEBUG" />
+        <appender-ref ref="ERROR" />
+        <appender-ref ref="WARN" />
+        <appender-ref ref="INFO" />
+        <appender-ref ref="TRACE" />
+    </root>
 </configuration>

+ 2 - 2
lift-enterprise-service/src/main/resources/mapper/LiftCertificateHistoryMapper.xml

@@ -13,8 +13,8 @@
 		<result column="content" property="content" jdbcType="LONGVARCHAR" />
 	</resultMap>
 
-	<sql id="Blob_Column_List" >
-		content
+	<sql id="Base_Column_List" >
+		id,mt_company_id,lift_certificate_id,owner_id,certificate_code,description,operator_id,operate_date,content
 	</sql>
 
 	<insert id="insert" parameterType="cn.com.ty.lift.enterprise.oa.entity.LiftCertificateHistory" >

+ 13 - 21
lift-enterprise-service/src/main/resources/mapper/LiftCertificateMapper.xml

@@ -7,28 +7,20 @@
 		<result column="code" property="code" jdbcType="CHAR" />
 		<result column="issuance_agency" property="issuanceAgency" jdbcType="VARCHAR" />
 		<result column="expiration_date" property="expirationDate" jdbcType="TIMESTAMP" />
-		<result column="type" property="type" jdbcType="VARCHAR" />
+		<result column="certificate_type" property="certificateType" jdbcType="VARCHAR" />
 		<result column="status" property="status" jdbcType="TINYINT" />
-	</resultMap>
-
-	<resultMap id="ResultMapWithBLOBs" type="cn.com.ty.lift.enterprise.oa.entity.LiftCertificate" extends="BaseResultMap" >
 		<result column="first_img_url" property="firstImgUrl" jdbcType="LONGVARCHAR" />
 		<result column="second_img_url" property="secondImgUrl" jdbcType="LONGVARCHAR" />
 	</resultMap>
 
-	<sql id="Base_Column_List" >
-		id, owner_id, code, issuance_agency, expiration_date, type, status
-	</sql>
 
-	<sql id="Blob_Column_List" >
-		first_img_url, second_img_url
+	<sql id="Base_Column_List" >
+		id, owner_id, code, issuance_agency, expiration_date, certificate_type, status,first_img_url, second_img_url
 	</sql>
 
-	<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Long" >
+	<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
 		select 
 		<include refid="Base_Column_List" />
-		,
-		<include refid="Blob_Column_List" />
 		from lift_certificate
 		where id = #{id,jdbcType=BIGINT}
 	</select>
@@ -40,11 +32,11 @@
 
 	<insert id="insert" parameterType="cn.com.ty.lift.enterprise.oa.entity.LiftCertificate" >
 		insert into lift_certificate (id, owner_id, code, 
-			issuance_agency, expiration_date, type, 
+			issuance_agency, expiration_date, certificate_type,
 			status, first_img_url, second_img_url
 			)
 		values (#{id,jdbcType=BIGINT}, #{ownerId,jdbcType=BIGINT}, #{code,jdbcType=CHAR}, 
-			#{issuanceAgency,jdbcType=VARCHAR}, #{expirationDate,jdbcType=TIMESTAMP}, #{type,jdbcType=VARCHAR}, 
+			#{issuanceAgency,jdbcType=VARCHAR}, #{expirationDate,jdbcType=TIMESTAMP}, #{certificate_type,jdbcType=VARCHAR},
 			#{status,jdbcType=TINYINT}, #{firstImgUrl,jdbcType=LONGVARCHAR}, #{secondImgUrl,jdbcType=LONGVARCHAR}
 			)
 	</insert>
@@ -67,8 +59,8 @@
 			<if test="expirationDate != null" >
 				expiration_date,
 			</if>
-			<if test="type != null" >
-				type,
+			<if test="certificateType != null" >
+				certificate_type,
 			</if>
 			<if test="status != null" >
 				status,
@@ -96,8 +88,8 @@
 			<if test="expirationDate != null" >
 				#{expirationDate,jdbcType=TIMESTAMP},
 			</if>
-			<if test="type != null" >
-				#{type,jdbcType=VARCHAR},
+			<if test="certificateType != null" >
+				#{certificate_type,jdbcType=VARCHAR},
 			</if>
 			<if test="status != null" >
 				#{status,jdbcType=TINYINT},
@@ -126,8 +118,8 @@
 			<if test="expirationDate != null" >
 				expiration_date = #{expirationDate,jdbcType=TIMESTAMP},
 			</if>
-			<if test="type != null" >
-				type = #{type,jdbcType=VARCHAR},
+			<if test="certificateType != null" >
+				certificate_type = #{certificateType,jdbcType=VARCHAR},
 			</if>
 			<if test="status != null" >
 				status = #{status,jdbcType=TINYINT},
@@ -148,7 +140,7 @@
 			code = #{code,jdbcType=CHAR},
 			issuance_agency = #{issuanceAgency,jdbcType=VARCHAR},
 			expiration_date = #{expirationDate,jdbcType=TIMESTAMP},
-			type = #{type,jdbcType=VARCHAR},
+			certificate_type = #{certificateType,jdbcType=VARCHAR},
 			status = #{status,jdbcType=TINYINT},
 			first_img_url = #{firstImgUrl,jdbcType=LONGVARCHAR},
 			second_img_url = #{secondImgUrl,jdbcType=LONGVARCHAR}