package com.ruixuan.isc.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; import com.alibaba.fastjson.JSONObject; import com.ruixuan.common.annotation.Log; import com.ruixuan.common.core.controller.BaseController; import com.ruixuan.common.core.domain.AjaxResult; import com.ruixuan.common.core.page.TableDataInfo; import com.ruixuan.common.enums.BusinessType; import com.ruixuan.common.utils.Check; import com.ruixuan.common.utils.DateUtils; import com.ruixuan.common.utils.poi.ExcelUtil; import com.ruixuan.isc.entity.KuaishouRewardBaseInfo; import com.ruixuan.isc.service.IKuaishouRewardBaseInfoService; 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; /** * 【请填写功能名称】Controller * * @author ruoyi * @date 2024-10-31 */ @RestController @RequestMapping("/finance/reward") public class KuaishouRewardBaseInfoController extends BaseController { @Autowired private IKuaishouRewardBaseInfoService kuaishouRewardBaseInfoService; /** * 查询【请填写功能名称】列表 */ @GetMapping("/list") public TableDataInfo list(KuaishouRewardBaseInfo kuaishouRewardBaseInfo) { startPage(); List list = kuaishouRewardBaseInfoService.selectKuaishouRewardBaseInfoList(kuaishouRewardBaseInfo); return getDataTable(list); } @GetMapping("/getTotal") public JSONObject getTotal(KuaishouRewardBaseInfo kuaishouRewardBaseInfo) { JSONObject json = kuaishouRewardBaseInfoService.getTotal(kuaishouRewardBaseInfo); return json; } /** * 导出【请填写功能名称】列表 */ @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, KuaishouRewardBaseInfo kuaishouRewardBaseInfo) { List list = kuaishouRewardBaseInfoService.selectKuaishouRewardBaseInfoList(kuaishouRewardBaseInfo); ExcelUtil util = new ExcelUtil(KuaishouRewardBaseInfo.class); util.exportExcel(response, list, "【请填写功能名称】数据"); } /** * 获取【请填写功能名称】详细信息 */ @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") Long id) { return AjaxResult.success(kuaishouRewardBaseInfoService.selectKuaishouRewardBaseInfoById(id)); } /** * 新增【请填写功能名称】 */ @PostMapping("/add") public AjaxResult add(@RequestBody KuaishouRewardBaseInfo kuaishouRewardBaseInfo) { AjaxResult result = new AjaxResult(); try { Long itemId = kuaishouRewardBaseInfo.getItemId(); if (Check.isNull(itemId)) { throw new Exception("请输入商品ID"); } String promoterId = kuaishouRewardBaseInfo.getPromoterId(); if (Check.isNull(promoterId)) { throw new Exception("请输入达人ID"); } String statDate = kuaishouRewardBaseInfo.getStatDate(); if (Check.isNull(statDate)) { throw new Exception("请输入结算日期"); } kuaishouRewardBaseInfo.setStatDate(statDate); Integer dataCount = kuaishouRewardBaseInfoService.checkData(itemId, promoterId, statDate); if (dataCount >= 1) { throw new Exception("此达人下此商品所选日期已结算"); } JSONObject getInfo = kuaishouRewardBaseInfoService.getInfo(itemId, promoterId); if (!Check.isNull(getInfo)) { String itemName = getInfo.getString("itemName"); if (!Check.isNull(itemName)) { kuaishouRewardBaseInfo.setItemTitle(itemName); } String promoterName = getInfo.getString("promoterName"); if (!Check.isNull(promoterName)) { kuaishouRewardBaseInfo.setPromoterName(promoterName); } } return toAjax(kuaishouRewardBaseInfoService.insertKuaishouRewardBaseInfo(kuaishouRewardBaseInfo)); } catch (Exception e) { result.put("code", 500); result.put("msg", e.getMessage()); return result; } } /** * 修改【请填写功能名称】 */ @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody KuaishouRewardBaseInfo kuaishouRewardBaseInfo) { return toAjax(kuaishouRewardBaseInfoService.updateKuaishouRewardBaseInfo(kuaishouRewardBaseInfo)); } /** * 删除【请填写功能名称】 */ @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(kuaishouRewardBaseInfoService.deleteKuaishouRewardBaseInfoByIds(ids)); } }