Commit 525f8e03caaa56ec16b1b865bb084000e06eb6e3

Authored by 房远帅
2 parents 6e8ac083 d83edebf

Merge branch 'master_after20' into master_cj_zq

@@ -20,6 +20,7 @@ import io.swagger.annotations.ApiOperation; @@ -20,6 +20,7 @@ import io.swagger.annotations.ApiOperation;
20 import com.lframework.starter.common.utils.CollectionUtil; 20 import com.lframework.starter.common.utils.CollectionUtil;
21 import io.swagger.annotations.Api; 21 import io.swagger.annotations.Api;
22 import org.springframework.beans.factory.annotation.Autowired; 22 import org.springframework.beans.factory.annotation.Autowired;
  23 +import org.springframework.scheduling.annotation.Scheduled;
23 import org.springframework.validation.annotation.Validated; 24 import org.springframework.validation.annotation.Validated;
24 import org.springframework.web.bind.annotation.*; 25 import org.springframework.web.bind.annotation.*;
25 26
@@ -106,4 +107,14 @@ public class CorePersonnelController extends DefaultBaseController { @@ -106,4 +107,14 @@ public class CorePersonnelController extends DefaultBaseController {
106 107
107 return InvokeResultBuilder.success(); 108 return InvokeResultBuilder.success();
108 } 109 }
  110 +
  111 + @Scheduled(cron = "0 0 0 1 1 ?")
  112 + @ApiOperation("自动更新年龄")
  113 + @GetMapping("/updateAge")
  114 + public InvokeResult<Void> updateAge() {
  115 +
  116 + corePersonnelService.updateAge();
  117 +
  118 + return InvokeResultBuilder.success();
  119 + }
109 } 120 }
@@ -17,6 +17,7 @@ import com.lframework.starter.common.exceptions.impl.DefaultClientException; @@ -17,6 +17,7 @@ import com.lframework.starter.common.exceptions.impl.DefaultClientException;
17 import io.swagger.annotations.ApiOperation; 17 import io.swagger.annotations.ApiOperation;
18 import com.lframework.starter.common.utils.CollectionUtil; 18 import com.lframework.starter.common.utils.CollectionUtil;
19 import io.swagger.annotations.Api; 19 import io.swagger.annotations.Api;
  20 +import org.springframework.scheduling.annotation.Scheduled;
20 import org.springframework.web.bind.annotation.DeleteMapping; 21 import org.springframework.web.bind.annotation.DeleteMapping;
21 import org.springframework.beans.factory.annotation.Autowired; 22 import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.validation.annotation.Validated; 23 import org.springframework.validation.annotation.Validated;
@@ -106,4 +107,14 @@ public class CorePersonnelHistoryController extends DefaultBaseController { @@ -106,4 +107,14 @@ public class CorePersonnelHistoryController extends DefaultBaseController {
106 107
107 return InvokeResultBuilder.success(); 108 return InvokeResultBuilder.success();
108 } 109 }
  110 +
  111 + @Scheduled(cron = "0 0 0 1 1 ?")
  112 + @ApiOperation("自动更新年龄")
  113 + @GetMapping("/updateAge")
  114 + public InvokeResult<Void> updateAge() {
  115 +
  116 + corePersonnelHistoryService.updateAge();
  117 +
  118 + return InvokeResultBuilder.success();
  119 + }
109 } 120 }
@@ -242,6 +242,15 @@ public class CorePersonnelHistoryServiceImpl extends BaseMpServiceImpl<CorePerso @@ -242,6 +242,15 @@ public class CorePersonnelHistoryServiceImpl extends BaseMpServiceImpl<CorePerso
242 return data; 242 return data;
243 } 243 }
244 244
  245 + @OpLog(type = OtherOpLogType.class, name = "年龄自动+1,ID:{}", params = {"#id"})
  246 + @Transactional(rollbackFor = Exception.class)
  247 + @Override
  248 + public void updateAge() {
  249 +
  250 + getBaseMapper().updateAge();
  251 + }
  252 +
  253 +
245 @CacheEvict(value = CorePersonnelHistory.CACHE_NAME, key = "@cacheVariables.tenantId() + #key") 254 @CacheEvict(value = CorePersonnelHistory.CACHE_NAME, key = "@cacheVariables.tenantId() + #key")
246 @Override 255 @Override
247 public void cleanCacheByKey(Serializable key) { 256 public void cleanCacheByKey(Serializable key) {
@@ -146,6 +146,14 @@ public class CorePersonnelServiceImpl extends BaseMpServiceImpl<CorePersonnelMap @@ -146,6 +146,14 @@ public class CorePersonnelServiceImpl extends BaseMpServiceImpl<CorePersonnelMap
146 getBaseMapper().deleteById(id); 146 getBaseMapper().deleteById(id);
147 } 147 }
148 148
  149 + @OpLog(type = OtherOpLogType.class, name = "年龄自动+1,ID:{}", params = {"#id"})
  150 + @Transactional(rollbackFor = Exception.class)
  151 + @Override
  152 + public void updateAge() {
  153 +
  154 + getBaseMapper().updateAge();
  155 + }
  156 +
149 @CacheEvict(value = CorePersonnel.CACHE_NAME, key = "@cacheVariables.tenantId() + #key") 157 @CacheEvict(value = CorePersonnel.CACHE_NAME, key = "@cacheVariables.tenantId() + #key")
150 @Override 158 @Override
151 public void cleanCacheByKey(Serializable key) { 159 public void cleanCacheByKey(Serializable key) {
@@ -21,4 +21,6 @@ public interface CorePersonnelHistoryMapper extends BaseMapper<CorePersonnelHist @@ -21,4 +21,6 @@ public interface CorePersonnelHistoryMapper extends BaseMapper<CorePersonnelHist
21 * @return 21 * @return
22 */ 22 */
23 List<CorePersonnelHistory> query(@Param("vo") QueryCorePersonnelHistoryVo vo); 23 List<CorePersonnelHistory> query(@Param("vo") QueryCorePersonnelHistoryVo vo);
  24 +
  25 + void updateAge();
24 } 26 }
@@ -25,4 +25,6 @@ public interface CorePersonnelMapper extends BaseMapper<CorePersonnel> { @@ -25,4 +25,6 @@ public interface CorePersonnelMapper extends BaseMapper<CorePersonnel> {
25 * @return 25 * @return
26 */ 26 */
27 List<CorePersonnel> query(@Param("vo") QueryCorePersonnelVo vo); 27 List<CorePersonnel> query(@Param("vo") QueryCorePersonnelVo vo);
  28 +
  29 + void updateAge();
28 } 30 }
@@ -57,4 +57,6 @@ public interface CorePersonnelHistoryService extends BaseMpService<CorePersonnel @@ -57,4 +57,6 @@ public interface CorePersonnelHistoryService extends BaseMpService<CorePersonnel
57 void updateWithChangeInfo(List<CorePersonnelHistory> beforeList, List<CorePersonnelHistory> afterList); 57 void updateWithChangeInfo(List<CorePersonnelHistory> beforeList, List<CorePersonnelHistory> afterList);
58 58
59 CorePersonnelHistory changeCorePersonnel(CorePersonnel vo); 59 CorePersonnelHistory changeCorePersonnel(CorePersonnel vo);
  60 +
  61 + void updateAge();
60 } 62 }
@@ -53,4 +53,6 @@ public interface CorePersonnelService extends BaseMpService<CorePersonnel> { @@ -53,4 +53,6 @@ public interface CorePersonnelService extends BaseMpService<CorePersonnel> {
53 */ 53 */
54 void deleteById(String id); 54 void deleteById(String id);
55 55
  56 + void updateAge();
  57 +
56 } 58 }
@@ -59,4 +59,10 @@ @@ -59,4 +59,10 @@
59 </if> 59 </if>
60 </where> 60 </where>
61 </select> 61 </select>
  62 +
  63 + <update id="updateAge">
  64 + UPDATE core_personnel
  65 + SET age = CAST(age AS UNSIGNED) + 1
  66 + WHERE age REGEXP '^[0-9]+$';
  67 + </update>
62 </mapper> 68 </mapper>
@@ -60,4 +60,9 @@ @@ -60,4 +60,9 @@
60 </if> 60 </if>
61 </where> 61 </where>
62 </select> 62 </select>
  63 + <update id="updateAge">
  64 + UPDATE core_personnel
  65 + SET age = CAST(age AS UNSIGNED) + 1
  66 + WHERE age REGEXP '^[0-9]+$';
  67 + </update>
63 </mapper> 68 </mapper>