| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.qianwen.smartman.modules.system.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.qianwen.core.boot.ctrl.BladeController; |
| | | import com.qianwen.core.mp.support.Condition; |
| | | import com.qianwen.core.mp.support.Query; |
| | | import com.qianwen.core.scanner.modular.annotation.GetResource; |
| | | import com.qianwen.core.scanner.modular.stereotype.ApiResource; |
| | | import com.qianwen.core.tool.api.R; |
| | | import com.qianwen.core.tool.utils.Func; |
| | | import com.qianwen.smartman.common.constant.ExtCacheConstant; |
| | | import com.qianwen.smartman.common.utils.Lambda; |
| | | import com.qianwen.smartman.modules.system.convert.BasCoderuleConvert; |
| | | import com.qianwen.smartman.modules.system.dto.BasCoderuleDTO; |
| | | import com.qianwen.smartman.common.cache.CodeRuleCache; |
| | | import com.qianwen.smartman.modules.system.dto.BaseCodeRuleQueryDTO; |
| | | import com.qianwen.smartman.modules.system.entity.BasCodeRule; |
| | | import com.qianwen.smartman.modules.system.entity.MetaObjectType; |
| | | import com.qianwen.smartman.modules.system.service.IBasCoderuleService; |
| | | import com.qianwen.smartman.modules.system.service.ICodeGeneratorService; |
| | | import com.qianwen.smartman.modules.system.service.IMetaObjectTypeService; |
| | | import com.qianwen.smartman.modules.system.vo.UserVO; |
| | | import com.qianwen.core.log.exception.ServiceException; |
| | | import com.qianwen.core.secure.annotation.PreAuth; |
| | | import com.qianwen.core.tool.api.ResultCode; |
| | | import com.qianwen.core.scanner.modular.annotation.PostResource; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import java.lang.invoke.SerializedLambda; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import javax.validation.Valid; |
| | | import com.qianwen.core.cache.utils.CacheUtil; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | @ApiResource({"blade-system/bascoderule"}) |
| | | @Api(value = "ç¼ç è§å", tags = {"ç¼ç è§åæ¥å£"}) |
| | | @RestController |
| | | /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/system/controller/BasCoderuleController.class */ |
| | | public class BasCoderuleController extends BladeController { |
| | | private IBasCoderuleService basCoderuleService; |
| | | private IMetaObjectTypeService metaObjectTypeService; |
| | | private ICodeGeneratorService codeGeneratorService; |
| | | |
| | | public BasCoderuleController(final IBasCoderuleService basCoderuleService, final IMetaObjectTypeService metaObjectTypeService, final ICodeGeneratorService codeGeneratorService) { |
| | | this.basCoderuleService = basCoderuleService; |
| | | this.metaObjectTypeService = metaObjectTypeService; |
| | | this.codeGeneratorService = codeGeneratorService; |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 1) |
| | | @GetResource({"/detail"}) |
| | | @ApiOperation(value = "详æ
", notes = "æ ¹æ®ç¼ç idè·å详æ
") |
| | | public R<BasCoderuleDTO> detail(Long id) { |
| | | BasCoderuleDTO detail = this.basCoderuleService.getCoderuleDetails(id); |
| | | return R.data(detail); |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 2) |
| | | @GetResource({"/list"}) |
| | | @ApiOperation(value = "å页", notes = "ä¼ å
¥basCoderule") |
| | | @PreAuth |
| | | public R<IPage<BasCodeRule>> list(BaseCodeRuleQueryDTO baseCodeRuleQueryDTO, Query query) { |
| | | List<String> list = new ArrayList<>(); |
| | | if (Func.isNotEmpty(baseCodeRuleQueryDTO.getSubsysId())) { |
| | | List<MetaObjectType> metaObjectTypes = this.metaObjectTypeService.list(Wrappers.<MetaObjectType>lambdaQuery() |
| | | .eq(MetaObjectType::getSubsysId, baseCodeRuleQueryDTO.getSubsysId())); |
| | | /* |
| | | List<MetaObjectType> metaObjectTypes = this.metaObjectTypeService.list((Wrapper) Wrappers.lambdaQuery().eq((v0) -> { |
| | | return v0.getSubsysId(); |
| | | }, baseCodeRuleQueryDTO.getSubsysId()));*/ |
| | | if (metaObjectTypes.isEmpty()) { |
| | | return R.data(new Page<>()); |
| | | } |
| | | list = metaObjectTypes.stream().map((v0) -> { |
| | | return v0.getFId(); |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | IPage<BasCodeRule> pages = this.basCoderuleService.page(Condition.getPage(query), Wrappers.<BasCodeRule>lambdaQuery() |
| | | .eq(Func.isNotEmpty(baseCodeRuleQueryDTO.getDictKey()), BasCodeRule::getRuleFieldDictKey, baseCodeRuleQueryDTO.getDictKey()) |
| | | .eq(Func.isNotEmpty(baseCodeRuleQueryDTO.getObjectId()), BasCodeRule::getBillFormId, baseCodeRuleQueryDTO.getObjectId()) |
| | | .in(Func.isNotEmpty(list), BasCodeRule::getBillFormId, list) |
| | | .and(Func.isNotEmpty(baseCodeRuleQueryDTO.getCondition()), wrapper -> wrapper.like(BasCodeRule::getName, baseCodeRuleQueryDTO.getCondition()).or().like(BasCodeRule::getRemark, baseCodeRuleQueryDTO.getCondition()))); |
| | | /* |
| | | IPage<BasCodeRule> pages = this.basCoderuleService.page(Condition.getPage(query), Wrappers.lambdaQuery().eq(Func.isNotEmpty(baseCodeRuleQueryDTO.getDictKey()), (v0) -> { |
| | | return v0.getRuleFieldDictKey(); |
| | | }, baseCodeRuleQueryDTO.getDictKey()).eq(Func.isNotEmpty(baseCodeRuleQueryDTO.getObjectId()), (v0) -> { |
| | | return v0.getBillFormId(); |
| | | }, baseCodeRuleQueryDTO.getObjectId()).in(Func.isNotEmpty(list), (v0) -> { |
| | | return v0.getBillFormId(); |
| | | }, list).and(Func.isNotEmpty(baseCodeRuleQueryDTO.getCondition()), wrapper -> { |
| | | LambdaQueryWrapper lambdaQueryWrapper = (LambdaQueryWrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) wrapper.like((v0) -> { |
| | | return v0.getName(); |
| | | }, baseCodeRuleQueryDTO.getCondition())).or()).like((v0) -> { |
| | | return v0.getRemark(); |
| | | }, baseCodeRuleQueryDTO.getCondition()); |
| | | }));*/ |
| | | return R.data(pages); |
| | | } |
| | | |
| | | @PreAuth |
| | | @GetResource({"/count"}) |
| | | @ApiOperation(value = "count", notes = "ç¼ç è§åæ¥è¯¢æ°é") |
| | | public R<Long> count(@RequestParam("type") @ApiParam("ä¸å¡å¯¹è±¡åç§°") String type) { |
| | | return R.data(Long.valueOf(this.basCoderuleService.count(Lambda.eq((v0) -> { |
| | | return v0.getBillFormId(); |
| | | }, type)))); |
| | | } |
| | | |
| | | @GetResource({"/count-all"}) |
| | | @ApiOperation(value = "count-all", notes = "æ¥è¯¢ææä¸å¡å¯¹è±¡ç¼ç è§åæ°é") |
| | | public R countAll() { |
| | | Wrapper<BasCodeRule> w = (new QueryWrapper<BasCodeRule>()).select(new String[] { "count(1) as \"count\"", Lambda.getName(BasCodeRule::getBillFormId) }).lambda().groupBy(BasCodeRule::getBillFormId); |
| | | /* |
| | | Wrapper w = (Wrapper) new QueryWrapper().select(new String[]{"count(1) as \"count\"", Lambda.getName((v0) -> { |
| | | return v0.getBillFormId(); |
| | | })}).lambda().groupBy((v0) -> { |
| | | return v0.getBillFormId(); |
| | | });*/ |
| | | return R.data(BasCoderuleConvert.INSTANCE.convert(this.basCoderuleService.listMaps(w))); |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 6) |
| | | @PostResource({"/submit"}) |
| | | @ApiOperation(value = "æ°å¢æä¿®æ¹", notes = "ä¼ å
¥basCoderule") |
| | | @PreAuth |
| | | public R<BasCodeRule> submit(@Valid @RequestBody BasCoderuleDTO basCoderuleDTO) { |
| | | return R.data(this.basCoderuleService.submitCoderule(basCoderuleDTO)); |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 7) |
| | | @PostResource({"/remove"}) |
| | | @ApiOperation(value = "é»è¾å é¤", notes = "ä¼ å
¥ids") |
| | | @PreAuth |
| | | public R remove(@RequestParam @ApiParam(value = "主é®éå", required = true) String ids) { |
| | | CacheUtil.clear(ExtCacheConstant.CODE_RULE_CACHE, Boolean.FALSE); |
| | | return R.status(this.basCoderuleService.deleteCoderule(Func.toLongList(ids)).booleanValue()); |
| | | } |
| | | |
| | | @ApiOperationSupport(order = 8) |
| | | @GetResource({"/is-exist-code-rule"}) |
| | | @ApiOperation(value = "æ ¹æ®ä¸å¡å¯¹è±¡æ¥è¯¢æ¯å¦åå¨ç¼ç è§å", notes = "ä¼ å
¥ä¸å¡å¯¹è±¡") |
| | | public R<Boolean> getIsExistCodeRuleByBillFormId(@RequestParam @ApiParam(value = "ä¸å¡å¯¹è±¡", required = true) String billFormId) { |
| | | boolean existCodeRule = CodeRuleCache.existCodeRule(billFormId); |
| | | return R.data(Boolean.valueOf(existCodeRule)); |
| | | } |
| | | |
| | | @PreAuth |
| | | @GetResource({"change-default/{id}"}) |
| | | @ApiOperation(value = "å¯ç¨åç¨", notes = "å¯ç¨åç¨ç¼ç è§å") |
| | | public R<Boolean> changeDefault(@PathVariable String id) { |
| | | CacheUtil.clear(ExtCacheConstant.CODE_RULE_CACHE, Boolean.FALSE); |
| | | return R.status(this.basCoderuleService.changeDefault(id)); |
| | | } |
| | | |
| | | @PostMapping({"/patch-code"}) |
| | | @PreAuth |
| | | @ApiOperation(value = "è·åæå¨è¡¥å·æ°æ®", notes = "ä¼ å
¥ä¸å¡å¯¹è±¡çç¼ç åæ®µåä¸å¡å¯¹è±¡,æ¥è¯¢æå¨è¡¥å·æ°æ®") |
| | | public R<List<String>> patchCodeList(@RequestParam @ApiParam("ä¸å¡å¯¹è±¡") String billFormId, @RequestBody Map<String, Object> objectData) { |
| | | try { |
| | | return R.data(this.basCoderuleService.patchCodeList(billFormId, objectData)); |
| | | } catch (IllegalArgumentException e) { |
| | | R re = (R) JSONObject.parseObject(e.getMessage(), R.class); |
| | | re.setCode(ResultCode.FAILURE.getCode()); |
| | | return re; |
| | | } catch (ServiceException e2) { |
| | | return R.fail(e2.getMessage()); |
| | | } |
| | | } |
| | | |
| | | @PostMapping({"/generate"}) |
| | | public R<String> generateTest(@ApiParam("æ°å»ºç¨æ·å¯¹è±¡") UserVO user) { |
| | | String code = this.codeGeneratorService.getGeneratorCode(user, "User"); |
| | | return R.data(code); |
| | | } |
| | | } |