package com.ruoyi.mall.controller; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import com.ruoyi.mall.service.IMallLinkIndustryCareerService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.mall.domain.MallIndustry; import com.ruoyi.mall.service.IMallIndustryService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; /** * 行业Controller * * @author LCL * @date 2023-10-20 */ @RestController @RequestMapping("/mall/mallIndustry") public class MallIndustryController extends BaseController { @Resource private IMallIndustryService mallIndustryService; @Resource private IMallLinkIndustryCareerService mallLinkIndustryCareerService; /** * 查询行业列表 */ @PreAuthorize("@ss.hasPermi('mall:mallIndustry:list')") @GetMapping("/list") public TableDataInfo list(MallIndustry mallIndustry) { startPage(); List list = mallIndustryService.selectMallIndustryList(mallIndustry); return getDataTable(list); } /** * 导出行业列表 */ @PreAuthorize("@ss.hasPermi('mall:mallIndustry:export')") @Log(title = "行业", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, MallIndustry mallIndustry) { List list = mallIndustryService.selectMallIndustryList(mallIndustry); ExcelUtil util = new ExcelUtil(MallIndustry.class); util.exportExcel(response, list, "行业数据"); } /** * 获取行业详细信息 */ @PreAuthorize("@ss.hasPermi('mall:mallIndustry:query')") @GetMapping(value = "/{industryId}") public AjaxResult getInfo(@PathVariable("industryId") Long industryId) { return AjaxResult.success(mallIndustryService.selectMallIndustryByIndustryId(industryId)); } /** * 新增行业 */ @PreAuthorize("@ss.hasPermi('mall:mallIndustry:add')") @Log(title = "行业", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody MallIndustry mallIndustry) { return toAjax(mallIndustryService.insertMallIndustry(mallIndustry)); } /** * 修改行业 */ @PreAuthorize("@ss.hasPermi('mall:mallIndustry:edit')") @Log(title = "行业", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody MallIndustry mallIndustry) { return toAjax(mallIndustryService.updateMallIndustry(mallIndustry)); } /** * 删除行业 */ @PreAuthorize("@ss.hasPermi('mall:mallIndustry:remove')") @Log(title = "行业", businessType = BusinessType.DELETE) @DeleteMapping("/{industryIds}") public AjaxResult remove(@PathVariable Long[] industryIds) { return toAjax(mallIndustryService.deleteMallIndustryByIndustryIds(industryIds)); } /** * 修改行业关联职业 */ @Log(title = "修改行业关联职业", businessType = BusinessType.UPDATE) @PutMapping("/updateIndustryCareer") public AjaxResult updateIndustryCareer(@RequestBody MallIndustry mallIndustry) { mallLinkIndustryCareerService.deleteMallLinkIndustryCareerByIndustryId(mallIndustry.getIndustryId()); mallLinkIndustryCareerService.batchInsertMallLinkIndustryCareer(mallIndustry.getIndustryId(), mallIndustry.getCareerList()); return AjaxResult.success(); } }