|
@@ -0,0 +1,80 @@
|
|
|
+package com.miaxis.system.controller.system;
|
|
|
+
|
|
|
+import com.miaxis.common.annotation.Log;
|
|
|
+import com.miaxis.common.constant.UserConstants;
|
|
|
+import com.miaxis.common.core.controller.BaseController;
|
|
|
+import com.miaxis.common.core.domain.Response;
|
|
|
+import com.miaxis.common.core.domain.entity.SysAutoCodeRule;
|
|
|
+import com.miaxis.common.core.page.ResponsePageInfo;
|
|
|
+import com.miaxis.common.enums.BusinessTypeEnum;
|
|
|
+import com.miaxis.common.exception.CustomException;
|
|
|
+import com.miaxis.system.service.IAutoCodeRuleService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/system/autocode/rule")
|
|
|
+public class SysAutoCodeRuleController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IAutoCodeRuleService iAutoCodeRuleService;
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:autocode:rule:list')")
|
|
|
+ @GetMapping("/list")
|
|
|
+ public ResponsePageInfo list(SysAutoCodeRule sysAutoCodeRule){
|
|
|
+ startPage();
|
|
|
+ List<SysAutoCodeRule> rules = iAutoCodeRuleService.selectAutoCodeList(sysAutoCodeRule);
|
|
|
+ return toResponsePageInfo(rules);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:autocode:rule:query')")
|
|
|
+ @GetMapping("/{ruleId}")
|
|
|
+ public Response getInfo(@PathVariable Long ruleId){
|
|
|
+ return Response.success(iAutoCodeRuleService.findById(ruleId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:autocode:rule:add')")
|
|
|
+ @Log(title = "新增自动编码规则",businessType = BusinessTypeEnum.INSERT)
|
|
|
+ @PostMapping
|
|
|
+ public Response add(@Validated @RequestBody SysAutoCodeRule sysAutoCodeRule){
|
|
|
+ if(UserConstants.NOT_UNIQUE.equals(iAutoCodeRuleService.checkRuleCodeUnique(sysAutoCodeRule))){
|
|
|
+ throw new CustomException("自动编码规则的编号重复");
|
|
|
+ }
|
|
|
+ if(UserConstants.NOT_UNIQUE.equals(iAutoCodeRuleService.checkRuleNameUnique(sysAutoCodeRule))){
|
|
|
+ throw new CustomException("自动编码规则的名称重复");
|
|
|
+ }
|
|
|
+ if("N".equals(sysAutoCodeRule.getIsPadded())){
|
|
|
+ sysAutoCodeRule.setPaddedChar(null);
|
|
|
+ sysAutoCodeRule.setPaddedMethod(null);
|
|
|
+ }
|
|
|
+ sysAutoCodeRule.setCreateBy(getUsername());
|
|
|
+ return toResponse(iAutoCodeRuleService.insertInfo(sysAutoCodeRule));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:autocode:rule:edit')")
|
|
|
+ @Log(title = "更新自动编码规则",businessType = BusinessTypeEnum.UPDATE)
|
|
|
+ @PutMapping
|
|
|
+ public Response updateInfo(@Validated @RequestBody SysAutoCodeRule sysAutoCodeRule){
|
|
|
+ if(UserConstants.NOT_UNIQUE.equals(iAutoCodeRuleService.checkRuleCodeUnique(sysAutoCodeRule))){
|
|
|
+ throw new CustomException("自动编码规则的编号重复");
|
|
|
+ }
|
|
|
+ if(UserConstants.NOT_UNIQUE.equals(iAutoCodeRuleService.checkRuleNameUnique(sysAutoCodeRule))){
|
|
|
+ throw new CustomException("自动编码规则的名称重复");
|
|
|
+ }
|
|
|
+ sysAutoCodeRule.setUpdateBy(getUsername());
|
|
|
+ return toResponse(iAutoCodeRuleService.updateInfo(sysAutoCodeRule));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('system:autocode:rule:remove')")
|
|
|
+ @Log(title = "删除自动编码规则",businessType = BusinessTypeEnum.DELETE)
|
|
|
+ @DeleteMapping("/{ruleIds}")
|
|
|
+ public Response remove(@PathVariable Long[] ruleIds){
|
|
|
+
|
|
|
+ return toResponse(iAutoCodeRuleService.deleteByIds(ruleIds));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|