|
@@ -1,6 +1,7 @@
|
|
|
package com.storlead.system.controller;
|
|
package com.storlead.system.controller;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -17,14 +18,20 @@ import com.storlead.user.service.ISubCompanyService;
|
|
|
import com.storlead.user.service.IUserService;
|
|
import com.storlead.user.service.IUserService;
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import io.swagger.annotations.ApiResponse;
|
|
|
|
|
+import io.swagger.annotations.ApiResponses;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+
|
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -92,7 +99,15 @@ public class SubCompanyApiController {
|
|
|
|
|
|
|
|
@ApiOperation("分页查询子公司")
|
|
@ApiOperation("分页查询子公司")
|
|
|
@PostMapping("pagelist")
|
|
@PostMapping("pagelist")
|
|
|
- public Result save(CompanyDTO param) {
|
|
|
|
|
|
|
+ public Result pagelist(CompanyDTO param) {
|
|
|
|
|
+ IPage<SubCompanyEntity> page = new Page<>(param.getPageIndex(),param.getPageSize());
|
|
|
|
|
+ IPage<SubCompanyEntity> companys = subCompanyService.page(page);
|
|
|
|
|
+ return Result.result(companys);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("查询所有的子公司")
|
|
|
|
|
+ @PostMapping("list")
|
|
|
|
|
+ public Result list(CompanyDTO param) {
|
|
|
IPage<SubCompanyEntity> page = new Page<>(param.getPageIndex(),param.getPageSize());
|
|
IPage<SubCompanyEntity> page = new Page<>(param.getPageIndex(),param.getPageSize());
|
|
|
IPage<SubCompanyEntity> companys = subCompanyService.page(page);
|
|
IPage<SubCompanyEntity> companys = subCompanyService.page(page);
|
|
|
return Result.result(companys);
|
|
return Result.result(companys);
|
|
@@ -157,5 +172,41 @@ public class SubCompanyApiController {
|
|
|
return Result.ok();
|
|
return Result.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @GetMapping(value = "/subCompany/listHasAllCompany")
|
|
|
|
|
+ @ApiOperation(value = "公共接口-分公司-包含所有公司列表", notes = "公共接口-分公司-包含所有公司列表")
|
|
|
|
|
+ @ApiResponses({
|
|
|
|
|
+ @ApiResponse(code = 200, message = "", response = SubCompanyEntity.class)
|
|
|
|
|
+ })
|
|
|
|
|
+ public Result<?> listHasAllCompany() {
|
|
|
|
|
+ List<SubCompanyEntity> list = new ArrayList<>();
|
|
|
|
|
+ SubCompanyEntity subCompany = new SubCompanyEntity();
|
|
|
|
|
+ subCompany.setId(0L);
|
|
|
|
|
+ subCompany.setName("所有公司");
|
|
|
|
|
+ subCompany.setDesc("所有公司");
|
|
|
|
|
+ list.add(subCompany);
|
|
|
|
|
+ // Step.1 组装查询条件
|
|
|
|
|
+ QueryWrapper<SubCompanyEntity> queryWrapper = new QueryWrapper<SubCompanyEntity>();
|
|
|
|
|
+ queryWrapper.select("id,company_id,`desc`,name,sort,enabled");
|
|
|
|
|
+ queryWrapper.eq("enabled", 1);
|
|
|
|
|
+ queryWrapper.orderByAsc("sort");
|
|
|
|
|
+ List<SubCompanyEntity> subCompanyEntityList = subCompanyService.list(queryWrapper);
|
|
|
|
|
+ list.addAll(subCompanyEntityList);
|
|
|
|
|
+ return Result.result(list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation("启用禁用子公司")
|
|
|
|
|
+ @PostMapping("/enable")
|
|
|
|
|
+ public Result setEnable(Long id,Boolean enable) {
|
|
|
|
|
+ LambdaUpdateWrapper<SubCompanyEntity> update = new LambdaUpdateWrapper();
|
|
|
|
|
+ update.in(SubCompanyEntity::getId, Arrays.asList(id));
|
|
|
|
|
+ update.set(SubCompanyEntity::getEnabled,enable);
|
|
|
|
|
+ Boolean re = subCompanyService.update(update);
|
|
|
|
|
+ if (re) {
|
|
|
|
|
+ return Result.ok();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return Result.error("操作失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|