package com.stylefeng.guns.modular.code.controller;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageInfo;
|
import com.stylefeng.guns.core.common.annotion.BussinessLog;
|
import com.stylefeng.guns.core.common.constant.dictmap.DeptDict;
|
import com.stylefeng.guns.core.common.exception.BizExceptionEnum;
|
import com.stylefeng.guns.core.exception.GunsException;
|
import com.stylefeng.guns.core.mutidatasource.annotion.DataSource;
|
import com.stylefeng.guns.core.node.ZTreeNode;
|
import com.stylefeng.guns.core.shiro.ShiroKit;
|
import com.stylefeng.guns.core.util.ToolUtil;
|
import com.stylefeng.guns.modular.system.dto.AggrementDTO;
|
import com.stylefeng.guns.modular.system.dto.OrderQuery;
|
import com.stylefeng.guns.modular.system.dto.UseGuidDTO;
|
import com.stylefeng.guns.modular.system.model.*;
|
import com.stylefeng.guns.modular.system.service.*;
|
import com.stylefeng.guns.modular.system.util.ResultUtil;
|
import com.stylefeng.guns.modular.system.vo.OrderListVO;
|
import com.stylefeng.guns.modular.system.vo.RedPackageVO;
|
import com.stylefeng.guns.modular.system.vo.SystemSetVO;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.apache.commons.lang3.StringEscapeUtils;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.Model;
|
import org.springframework.util.StringUtils;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.math.BigDecimal;
|
import java.util.*;
|
|
@Controller
|
@RequestMapping("/base/system")
|
public class SystemController {
|
|
@Autowired
|
private IDeptService deptService;
|
@Autowired
|
private IPageService pageService;
|
@Autowired
|
private IProtocolService protocolService;
|
@Autowired
|
private IUseGuideService useGuideService;
|
@Autowired
|
private ISysSetService sysSetService;
|
@Autowired
|
private IRedPackageService redPackageService;
|
@Autowired
|
private IAppUserService appUserService;
|
@ResponseBody
|
@PostMapping("/page")
|
@ApiOperation(value = "启动页引导页", tags = {"启动页引导页管理"})
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "类型1=启动页 2=引导页", name = "type", required = true),
|
@ApiImplicitParam(value = "图片,多张逗号隔开(该字段不传的时候为查看,传了为修改)", name = "img")
|
})
|
public ResultUtil page(Integer type,String img) {
|
Page type1 = pageService.selectOne(new EntityWrapper<Page>()
|
.eq("type", type));
|
if(StringUtils.hasLength(img)){
|
if (type1!=null){
|
type1.setImg(img);
|
pageService.updateById(type1);
|
}else{
|
Page page = new Page();
|
page.setImg(img);
|
page.setType(type);
|
pageService.insert(page);
|
}
|
return ResultUtil.success("修改成功");
|
}else{
|
if (type1!=null){
|
return ResultUtil.success(type1.getImg());
|
}else{
|
Page page = new Page();
|
page.setImg(img);
|
page.setType(type);
|
pageService.insert(page);
|
return ResultUtil.success();
|
}
|
}
|
}
|
@ResponseBody
|
@PostMapping("/riskInfo")
|
@ApiOperation(value = "运动风险告知", tags = {"运动风险告知"})
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "内容", name = "content"),
|
})
|
public ResultUtil page(String content) {
|
SysSet sysSet = sysSetService.selectById(1);
|
String riskInfo = sysSet.getRiskInfo();
|
|
if(StringUtils.hasLength(content)){
|
sysSet.setRiskInfo(content);
|
sysSetService.updateById(sysSet);
|
return ResultUtil.success("修改成功");
|
}else{
|
return ResultUtil.success(riskInfo);
|
}
|
}
|
|
@ResponseBody
|
@PostMapping("/agreement")
|
@ApiOperation(value = " ", tags = {"协议管理"})
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "类型1=用户协议 2=隐私协议 3=注销协议 4=关于我们", name = "type", required = true),
|
@ApiImplicitParam(value = "内容(该字段不传的时候为查看,传了为修改)", name = "content"),
|
})
|
public ResultUtil agreement(@RequestBody AggrementDTO dto) {
|
Protocol protocol = protocolService.selectById(dto.getType());
|
if(StringUtils.hasLength(dto.getContent())){
|
protocol.setContent(dto.getContent());
|
protocolService.updateById(protocol);
|
return ResultUtil.success("修改成功");
|
}else{
|
return ResultUtil.success(protocol.getContent());
|
}
|
}
|
@ResponseBody
|
@PostMapping("/useGuide")
|
@ApiOperation(value = "使用指南-列表查询", tags = {"使用指南"})
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "问题标题", name = "title"),
|
})
|
public ResultUtil<PageInfo<UseGuide>> agreement(String title,Integer pageNum,Integer pageSize) {
|
EntityWrapper<UseGuide> wrapper = new EntityWrapper<>();
|
if (StringUtils.hasLength(title)){
|
wrapper.like("title",title);
|
}
|
List<String> strings = new ArrayList<>();
|
strings.add("insertTime");
|
wrapper.orderDesc(strings);
|
wrapper.ne("isDelete",1);
|
List<UseGuide> useGuides = useGuideService.selectList(wrapper);
|
// PageHelper.startPage(pageNum,pageSize);
|
PageInfo<UseGuide> info=new PageInfo<>(useGuides);
|
return ResultUtil.success(info);
|
}
|
|
@ResponseBody
|
@PostMapping("/updateUseGuide")
|
@ApiOperation(value = "使用指南-添加/编辑/查看详情", tags = {"使用指南"})
|
public ResultUtil<UseGuide> updateUseGuide(@RequestBody UseGuidDTO dto) {
|
switch (dto.getType()){
|
case 1:
|
UseGuide useGuide = new UseGuide();
|
useGuide.setTitle(dto.getTitle());
|
useGuide.setSort(dto.getSort());
|
useGuide.setIsDelete(0);
|
useGuide.setAnswer(dto.getAnswer());
|
useGuide.setInsertTime(new Date());
|
useGuideService.insert(useGuide);
|
return ResultUtil.success(useGuide);
|
case 2:
|
UseGuide useGuide1 = useGuideService.selectById(dto.getId());
|
useGuide1.setId(dto.getId());
|
useGuide1.setTitle(dto.getTitle());
|
useGuide1.setSort(dto.getSort());
|
useGuide1.setAnswer(dto.getAnswer());
|
useGuideService.updateById(useGuide1);
|
return ResultUtil.success(useGuide1);
|
case 3:
|
UseGuide useGuide2 = useGuideService.selectById(dto.getId());
|
return ResultUtil.success(useGuide2);
|
}
|
return ResultUtil.success(new UseGuide());
|
}
|
@ResponseBody
|
@PostMapping("/deleteUseGuide")
|
@ApiOperation(value = "使用指南删除", tags = {"使用指南"})
|
public ResultUtil deleteUseGuide(Integer id) {
|
UseGuide useGuide = useGuideService.selectById(id);
|
useGuide.setIsDelete(1);
|
useGuideService.updateById(useGuide);
|
return ResultUtil.success("删除成功");
|
}
|
@Autowired
|
private IUpdateSetService updateSetService;
|
@ResponseBody
|
@PostMapping("/systemSet")
|
@ApiOperation(value = "系统设置", tags = {"系统设置"})
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "联系方式", name = "phone"),
|
@ApiImplicitParam(value = "邀请人可获得被邀请人消费金额比例", name = "people"),
|
@ApiImplicitParam(value = "团队长可获得团员消费金额比例", name = "header"),
|
@ApiImplicitParam(value = "推广赚钱说明", name = "introduce"),
|
@ApiImplicitParam(value = "是否首次下单赠送物品0否1是", name = "isGive"),
|
@ApiImplicitParam(value = "运动风险告知", name = "riskInfo"),
|
@ApiImplicitParam(value = "类型1=编辑 2=查看详情", name = "type",required = true),
|
})
|
public ResultUtil<SystemSetVO> systemSet(String phone, String people, String header, String introduce, Integer isGive, String riskInfo, Integer type) {
|
SysSet sysSet2 = sysSetService.selectById(1);
|
SystemSetVO systemSetVO = new SystemSetVO();
|
switch (type){
|
case 1:
|
// 编辑
|
SysSet sysSet = new SysSet();
|
sysSet.setId(1);
|
sysSet.setPhone(phone);
|
sysSet.setPeople(people);
|
sysSet.setHeader(header);
|
sysSet.setIntroduce(introduce);
|
sysSet.setIsGive(isGive);
|
sysSet.setRiskInfo(riskInfo);
|
sysSetService.updateById(sysSet);
|
if (!people.equals(sysSet2.getPeople())){
|
// 修改了
|
UpdateSet updateSet = new UpdateSet();
|
updateSet.setBeforePeople(sysSet2.getPeople());
|
updateSet.setPeople(people);
|
updateSet.setBeforeHeader(sysSet2.getHeader());
|
updateSet.setHeader(header);
|
updateSet.setUpdateTime(new Date());
|
updateSetService.insert(updateSet);
|
}else if (!header.equals(sysSet2.getHeader())){
|
// 修改了
|
UpdateSet updateSet = new UpdateSet();
|
updateSet.setBeforePeople(sysSet2.getPeople());
|
updateSet.setPeople(people);
|
updateSet.setBeforeHeader(sysSet2.getHeader());
|
updateSet.setHeader(header);
|
updateSet.setUpdateTime(new Date());
|
updateSetService.insert(updateSet);
|
}
|
systemSetVO.setId(1);
|
systemSetVO.setPhone(phone);
|
systemSetVO.setPeople(people);
|
systemSetVO.setHeader(header);
|
systemSetVO.setIntroduce(introduce);
|
systemSetVO.setIsGive(isGive);
|
systemSetVO.setRiskInfo(riskInfo);
|
break;
|
case 2:
|
// 查看详情
|
SysSet sysSet1 = sysSetService.selectById(1);
|
BeanUtils.copyProperties(sysSet1,systemSetVO);
|
break;
|
}
|
List<RedPackageVO> vo = redPackageService.selectAll();
|
systemSetVO.setRedPackageList(vo);
|
// 查询红包记录
|
return ResultUtil.success(systemSetVO);
|
}
|
@ResponseBody
|
@PostMapping("/reaPackageList")
|
@ApiOperation(value = "红包领取记录列表查询", tags = {"系统设置"})
|
public ResultUtil<PageInfo<RedPackageVO>> courseList(OrderQuery query) {
|
List<RedPackageVO> vo = redPackageService.selectAll();
|
// PageHelper.startPage(query.getPageNum(),query.getPageSize());
|
PageInfo<RedPackageVO> info=new PageInfo<>(vo);
|
return ResultUtil.success(info);
|
}
|
@Autowired
|
private IMessageService messageService;
|
@ResponseBody
|
@PostMapping("/addRedPackage")
|
@ApiOperation(value = "发放红包", tags = {"系统设置"})
|
@ApiImplicitParams({
|
@ApiImplicitParam(value = "发放金额", name = "amount"),
|
})
|
public ResultUtil addRedPackage(BigDecimal amount) {
|
// 添加发放红包记录
|
// RedPackage redPackage = new RedPackage();
|
// redPackage.setAmount(amount);
|
// redPackage.setInsertUserId(Objects.requireNonNull(ShiroKit.getUser()).id);
|
// redPackage.setInsertTime(new Date());
|
// redPackageService.insert(redPackage);
|
// // 给每个用户的余额增加响应的金额
|
// List<AppUser> users = appUserService.selectList(new EntityWrapper<AppUser>()
|
// .eq("state", 1));
|
// for (AppUser user : users) {
|
// BigDecimal balance = user.getBalance();
|
// BigDecimal add = balance.add(amount);
|
// user.setBalance(add);
|
// appUserService.updateById(user);
|
// // 给用户发消息
|
// Message message = new Message();
|
// message.setUserId(user.getId());
|
// message.setType(1);
|
// message.setContent("系统发送红包¥"+amount+"到账至您的余额");
|
// message.setInsertTime(new Date());
|
// message.setIsRead(0);
|
// messageService.insert(message);
|
// }
|
return ResultUtil.success("发放成功");
|
}
|
}
|