|  |  |  | 
|---|
|  |  |  | import com.doumee.api.BaseController; | 
|---|
|  |  |  | import com.doumee.core.annotation.excel.ExcelExporter; | 
|---|
|  |  |  | import com.doumee.core.annotation.pr.PreventRepeat; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | import com.doumee.core.model.ApiResponse; | 
|---|
|  |  |  | import com.doumee.core.model.PageWrap; | 
|---|
|  |  |  | import com.doumee.core.model.PageData; | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.dao.business.model.Company; | 
|---|
|  |  |  | import com.doumee.service.business.CompanyService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiOperation; | 
|---|
|  |  |  | import org.apache.shiro.authz.annotation.RequiresPermissions; | 
|---|
|  |  |  | import org.apache.shiro.authz.annotation.Logical; | 
|---|
|  |  |  | import org.apache.shiro.authz.annotation.RequiresPermissions; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | import javax.servlet.http.HttpServletResponse; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @author 江蹄蹄 | 
|---|
|  |  |  | * @date 2024/01/15 15:07 | 
|---|
|  |  |  | * @date 2024/01/16 10:03 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Api(tags = "企业信息表") | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | 
|---|
|  |  |  | @PostMapping("/create") | 
|---|
|  |  |  | @RequiresPermissions("business:company:create") | 
|---|
|  |  |  | public ApiResponse create(@RequestBody Company company) { | 
|---|
|  |  |  | return ApiResponse.success(companyService.create(company)); | 
|---|
|  |  |  | companyService.create(company); | 
|---|
|  |  |  | companyService.startSignAuth(company.getId()); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @PreventRepeat | 
|---|
|  |  |  | @ApiOperation("新建商户") | 
|---|
|  |  |  | @PostMapping("/createShop") | 
|---|
|  |  |  | @RequiresPermissions("business:company:createShop") | 
|---|
|  |  |  | public ApiResponse createShop(@RequestBody Company company) { | 
|---|
|  |  |  | companyService.createShop(company); | 
|---|
|  |  |  | companyService.startSignAuth(company.getId()); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID删除") | 
|---|
|  |  |  | @GetMapping("/delete/{id}") | 
|---|
|  |  |  | @RequiresPermissions("business:company:delete") | 
|---|
|  |  |  | @RequiresPermissions(value = {"business:company:delete", "business:company:deleteShop"}, logical = Logical.OR) | 
|---|
|  |  |  | public ApiResponse deleteById(@PathVariable Integer id) { | 
|---|
|  |  |  | companyService.deleteById(id); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("批量删除") | 
|---|
|  |  |  | @GetMapping("/delete/batch") | 
|---|
|  |  |  | @RequiresPermissions("business:company:delete") | 
|---|
|  |  |  | @RequiresPermissions(value = {"business:company:delete", "business:company:deleteShop"}, logical = Logical.OR) | 
|---|
|  |  |  | public ApiResponse deleteByIdInBatch(@RequestParam String ids) { | 
|---|
|  |  |  | String [] idArray = ids.split(","); | 
|---|
|  |  |  | List<Integer> idList = new ArrayList<>(); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID修改") | 
|---|
|  |  |  | @PostMapping("/updateById") | 
|---|
|  |  |  | @RequiresPermissions("business:company:update") | 
|---|
|  |  |  | @RequiresPermissions(value = {"business:company:update", "business:company:updateShop"}, logical = Logical.OR) | 
|---|
|  |  |  | public ApiResponse updateById(@RequestBody Company company) { | 
|---|
|  |  |  | companyService.updateById(company); | 
|---|
|  |  |  | companyService.startSignAuth(company.getId()); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID禁用启用") | 
|---|
|  |  |  | @PostMapping("/updateStatus") | 
|---|
|  |  |  | @RequiresPermissions(value = {"business:company:update", "business:company:updateShop"}, logical = Logical.OR) | 
|---|
|  |  |  | public ApiResponse updateStatus(@RequestBody Company company) { | 
|---|
|  |  |  | companyService.updateStatus(company); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @ApiOperation("修改保险方案") | 
|---|
|  |  |  | @PostMapping("/updateSolutions") | 
|---|
|  |  |  | @RequiresPermissions(value = {"business:company:update", "business:company:updateShop"}, logical = Logical.OR) | 
|---|
|  |  |  | public ApiResponse updateSolutions(@RequestBody Company company) { | 
|---|
|  |  |  | companyService.updateSolutions(company); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @ApiOperation("企业更换手机号") | 
|---|
|  |  |  | @PostMapping("/updatePhone") | 
|---|
|  |  |  | @RequiresPermissions(value = {"business:company:update", "business:company:updateShop"}, logical = Logical.OR) | 
|---|
|  |  |  | public ApiResponse updatePhone(@RequestBody Company company) { | 
|---|
|  |  |  | companyService.updatePhone(company); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @ApiOperation("根据ID电子签认证企业信息") | 
|---|
|  |  |  | @PostMapping("/startSignAuth/{id}") | 
|---|
|  |  |  | @RequiresPermissions("business:company:update") | 
|---|
|  |  |  | public ApiResponse startSignAuth(@PathVariable Integer id) { | 
|---|
|  |  |  | companyService.startSignAuth(id); | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("分页查询") | 
|---|
|  |  |  | @PostMapping("/page") | 
|---|
|  |  |  | @RequiresPermissions("business:company:query") | 
|---|
|  |  |  | @RequiresPermissions(value = {"business:company:query", "business:company:queryShop"}, logical = Logical.OR) | 
|---|
|  |  |  | public ApiResponse<PageData<Company>> findPage (@RequestBody PageWrap<Company> pageWrap) { | 
|---|
|  |  |  | //权限范围内 | 
|---|
|  |  |  | return ApiResponse.success(companyService.findPage(pageWrap)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("查询全部数据(账号分配企业使用)") | 
|---|
|  |  |  | @PostMapping("/pageAll") | 
|---|
|  |  |  | @RequiresPermissions("business:companypermission:create") | 
|---|
|  |  |  | public ApiResponse<List<Company>> findPageAll (@RequestBody  Company pageWrap) { | 
|---|
|  |  |  | pageWrap.setQueryFlag(Constants.ONE);//查询全部 | 
|---|
|  |  |  | return ApiResponse.success(companyService.findList(pageWrap)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @ApiOperation("查询全部数据") | 
|---|
|  |  |  | @PostMapping("/list") | 
|---|
|  |  |  | @RequiresPermissions(value = {"business:company:query", "business:company:queryShop"}, logical = Logical.OR) | 
|---|
|  |  |  | public ApiResponse<List<Company>> findList (@RequestBody  Company pageWrap) { | 
|---|
|  |  |  | pageWrap.setQueryFlag(Constants.ZERO);//查询全部权限范围内 | 
|---|
|  |  |  | return ApiResponse.success(companyService.findList(pageWrap)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @ApiOperation("导出Excel") | 
|---|
|  |  |  | @PostMapping("/exportExcel") | 
|---|
|  |  |  | @RequiresPermissions("business:company:exportExcel") | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("根据ID查询") | 
|---|
|  |  |  | @GetMapping("/{id}") | 
|---|
|  |  |  | @RequiresPermissions("business:company:query") | 
|---|
|  |  |  | public ApiResponse findById(@PathVariable Integer id) { | 
|---|
|  |  |  | @RequiresPermissions(value = {"business:company:query", "business:company:queryShop"}, logical = Logical.OR) | 
|---|
|  |  |  | public ApiResponse<Company> findById(@PathVariable Integer id) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ApiResponse.success(companyService.findById(id)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("企业证件下载") | 
|---|
|  |  |  | @PostMapping("/exportFiles") | 
|---|
|  |  |  | @RequiresPermissions("business:company:exportExcel") | 
|---|
|  |  |  | public void exportFiles(@RequestBody Company company,HttpServletResponse response) { | 
|---|
|  |  |  | if(company.getId() == null){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | companyService.exportFiles(company.getId(),response); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|