123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- package com.yijia.integral.controller;
- import java.util.List;
- import com.yijia.common.core.domain.entity.SysDept;
- import com.yijia.common.core.domain.model.LoginUser;
- import com.yijia.common.utils.SecurityUtils;
- import com.yijia.system.service.ISysDeptService;
- 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.yijia.common.annotation.Log;
- import com.yijia.common.core.controller.BaseController;
- import com.yijia.common.core.domain.AjaxResult;
- import com.yijia.common.enums.BusinessType;
- import com.yijia.integral.domain.IntegralRule;
- import com.yijia.integral.service.IIntegralRuleService;
- import com.yijia.common.utils.poi.ExcelUtil;
- import com.yijia.common.core.page.TableDataInfo;
- /**
- * 积分规则Controller
- *
- * @author yijia
- * @date 2021-02-24
- */
- @RestController
- @RequestMapping("/integral/rule")
- public class IntegralRuleController extends BaseController
- {
- @Autowired
- private IIntegralRuleService integralRuleService;
- @Autowired
- private ISysDeptService sysDeptService;
- /**
- * 查询积分规则列表
- */
- @GetMapping("/list")
- public TableDataInfo list(IntegralRule integralRule)
- {
- LoginUser currentUser = SecurityUtils.getLoginUser();
- SysDept dept =new SysDept();
- dept.setDeptId(currentUser.getUser().getDeptId());
- List<String> list = sysDeptService.selectDeptId(dept);
- if(list!=null && list.size()>0){
- integralRule.setStationIdList(list);
- integralRule.setStationId(null);
- }
- startPage();
- List<IntegralRule> integralRuleList = integralRuleService.selectIntegralRuleList(integralRule);
- return getDataTable(integralRuleList);
- }
- /**
- * 查询积分规则明细
- * @param integralRule
- * @return
- */
- @GetMapping("/listRuleInfo")
- public TableDataInfo listRuleInfo(IntegralRule integralRule)
- {
- LoginUser currentUser = SecurityUtils.getLoginUser();
- SysDept dept =new SysDept();
- dept.setDeptId(currentUser.getUser().getDeptId());
- List<String> list = sysDeptService.selectDeptId(dept);
- if(list!=null && list.size()>0){
- integralRule.setStationIdList(list);
- integralRule.setStationId(null);
- }
- startPage();
- List<IntegralRule> integralRuleList = integralRuleService.listRuleInfo(integralRule);
- return getDataTable(integralRuleList);
- }
- @GetMapping("/listRuleOne")
- public AjaxResult listRuleOne(IntegralRule integralRule)
- {
- LoginUser currentUser = SecurityUtils.getLoginUser();
- SysDept dept =new SysDept();
- dept.setDeptId(currentUser.getUser().getDeptId());
- List<String> list = sysDeptService.selectDeptId(dept);
- if(list!=null && list.size()>0){
- integralRule.setStationIdList(list);
- integralRule.setStationId(null);
- }
- IntegralRule rule = integralRuleService.selectIntegralRule(integralRule);
- return AjaxResult.success(rule);
- }
- /**
- * 导出积分规则列表
- */
- @Log(title = "积分规则", businessType = BusinessType.EXPORT)
- @GetMapping("/export")
- public AjaxResult export(IntegralRule integralRule)
- {
- LoginUser currentUser = SecurityUtils.getLoginUser();
- SysDept dept =new SysDept();
- dept.setDeptId(currentUser.getUser().getDeptId());
- List<String> list = sysDeptService.selectDeptId(dept);
- if(list!=null && list.size()>0){
- integralRule.setStationIdList(list);
- integralRule.setStationId(null);
- }
- List<IntegralRule> integralRuleList = integralRuleService.selectIntegralRuleList(integralRule);
- ExcelUtil<IntegralRule> util = new ExcelUtil<IntegralRule>(IntegralRule.class);
- return util.exportExcel(integralRuleList, "rule");
- }
- /**
- * 获取积分规则详细信息
- */
- @GetMapping(value = "/{id}")
- public AjaxResult getInfo(@PathVariable("id") Long id)
- {
- return AjaxResult.success(integralRuleService.selectIntegralRuleById(id));
- }
- /**
- * 新增积分规则
- */
- @Log(title = "积分规则", businessType = BusinessType.INSERT)
- @PostMapping
- public AjaxResult add(@RequestBody IntegralRule integralRule)
- {
- LoginUser currentUser = SecurityUtils.getLoginUser();
- integralRule.setStationId(currentUser.getUser().getDeptId());
- integralRule.setStationName(currentUser.getUser().getDept().getDeptName());
- if(integralRule!=null && integralRule.getIntegralActivity()==null){
- integralRule.setIntegralActivity("0");
- }
- return toAjax(integralRuleService.insertIntegralRule(integralRule));
- }
- /**
- * 修改积分规则
- */
- @Log(title = "积分规则", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody IntegralRule integralRule)
- {
- LoginUser currentUser = SecurityUtils.getLoginUser();
- integralRule.setStationId(currentUser.getUser().getDeptId());
- integralRule.setStationName(currentUser.getUser().getDept().getDeptName());
- if(integralRule!=null && integralRule.getIntegralActivity()==null){
- integralRule.setIntegralActivity("0");
- }
- return toAjax(integralRuleService.updateIntegralRule(integralRule));
- }
- /**
- * 删除积分规则
- */
- @Log(title = "积分规则", businessType = BusinessType.DELETE)
- @DeleteMapping("/{ids}")
- public AjaxResult remove(@PathVariable Long[] ids)
- {
- return toAjax(integralRuleService.deleteIntegralRuleByIds(ids));
- }
- }
|