Commit f2314057 by 邹磊浩

修改代码

parent a7f3a84a
//package com.pz.accompany;
//
//import com.pz.system.domain.ChatMessage;
//import lombok.RequiredArgsConstructor;
//import org.springframework.messaging.handler.annotation.DestinationVariable;
//import org.springframework.messaging.handler.annotation.MessageMapping;
//import org.springframework.messaging.simp.SimpMessagingTemplate;
//import org.springframework.validation.annotation.Validated;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.socket.WebSocketSession;
//
//import java.util.List;
//import java.util.Map;
//import java.util.concurrent.ConcurrentHashMap;
//
//@Validated
//@RequiredArgsConstructor
//@RestController
//@RequestMapping("/accompany/chat")
//public class ChatController {
//
//
//
// private final Map<String, WebSocketSession> sessions = new ConcurrentHashMap<>();
//
// private final SimpMessagingTemplate messagingTemplate;
//
// @GetMapping("/history/{userId}")
// public List<ChatMessage> getChatHistory(@PathVariable String userId) {
// return chatMessageRepository.findByUserId(userId);
// }
//
// @GetMapping("/offline/{userId}")
// public void sendOfflineMessages(@PathVariable String userId) {
// List<ChatMessage> offlineMessages = chatMessageRepository.findOfflineMessages(userId);
// for (ChatMessage message : offlineMessages) {
// WebSocketSession session = sessions.get(userId);
// if (session != null && session.isOpen()) {
// messagingTemplate.convertAndSendToUser(userId, "/queue/messages", message);
// message.setSent(true);
// chatMessageRepository.save(message);
// }
// }
// }
//
// @MessageMapping("/connect/{userId}")
// public void connect(@DestinationVariable String userId, WebSocketSession session) {
// sessions.put(userId, session);
//
// // 发送离线消息
// sendOfflineMessages(userId);
// }
//
// @MessageMapping("/send/{userId}")
// public void sendMessage(@DestinationVariable String userId, ChatMessage message) {
// WebSocketSession session = sessions.get(userId);
// if (session != null && session.isOpen()) {
// messagingTemplate.convertAndSendToUser(userId, "/queue/messages", message);
// message.setSent(true);
// chatMessageRepository.save(message);
// } else {
// message.setSent(false);
// chatMessageRepository.save(message);
// }
// }
//}
package com.pz.accompany;
import com.pz.system.domain.ChatMessage;
import lombok.RequiredArgsConstructor;
import org.springframework.messaging.handler.annotation.DestinationVariable;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.socket.WebSocketSession;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/accompany/chat")
public class ChatController {
}
package com.pz.web.controller.system;
import java.util.List;
import java.util.Arrays;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.pz.common.annotation.RepeatSubmit;
import com.pz.common.annotation.Log;
import com.pz.common.core.controller.BaseController;
import com.pz.common.core.domain.PageQuery;
import com.pz.common.core.domain.R;
import com.pz.common.core.validate.AddGroup;
import com.pz.common.core.validate.EditGroup;
import com.pz.common.enums.BusinessType;
import com.pz.common.utils.poi.ExcelUtil;
import com.pz.system.domain.vo.StoreInfoVo;
import com.pz.system.domain.bo.StoreInfoBo;
import com.pz.system.service.IStoreInfoService;
import com.pz.common.core.page.TableDataInfo;
/**
* 商户
*
* @author ruoyi
* @date 2023-09-08
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/info")
public class StoreInfoController extends BaseController {
private final IStoreInfoService iStoreInfoService;
/**
* 查询商户列表
*/
@SaCheckPermission("system:info:list")
@GetMapping("/list")
public TableDataInfo<StoreInfoVo> list(StoreInfoBo bo, PageQuery pageQuery) {
return iStoreInfoService.queryPageList(bo, pageQuery);
}
/**
* 导出商户列表
*/
@SaCheckPermission("system:info:export")
@Log(title = "商户", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(StoreInfoBo bo, HttpServletResponse response) {
List<StoreInfoVo> list = iStoreInfoService.queryList(bo);
ExcelUtil.exportExcel(list, "商户", StoreInfoVo.class, response);
}
/**
* 获取商户详细信息
*
* @param id 主键
*/
@SaCheckPermission("system:info:query")
@GetMapping("/{id}")
public R<StoreInfoVo> getInfo(@NotNull(message = "主键不能为空")
@PathVariable Integer id) {
return R.ok(iStoreInfoService.queryById(id));
}
/**
* 新增商户
*/
@SaCheckPermission("system:info:add")
@Log(title = "商户", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping()
public R<Void> add(@Validated(AddGroup.class) @RequestBody StoreInfoBo bo) {
return toAjax(iStoreInfoService.insertByBo(bo));
}
/**
* 修改商户
*/
@SaCheckPermission("system:info:edit")
@Log(title = "商户", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody StoreInfoBo bo) {
return toAjax(iStoreInfoService.updateByBo(bo));
}
/**
* 删除商户
*
* @param ids 主键串
*/
@SaCheckPermission("system:info:remove")
@Log(title = "商户", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Integer[] ids) {
return toAjax(iStoreInfoService.deleteWithValidByIds(Arrays.asList(ids), true));
}
}
package com.pz.system.domain;
import com.baomidou.mybatisplus.annotation.*;
import com.pz.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 商户对象 store_info
*
* @author ruoyi
* @date 2023-09-08
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("store_info")
public class StoreInfo extends BaseEntity {
private static final long serialVersionUID=1L;
/**
*
*/
private Integer id;
/**
*
*/
private Integer storeId;
/**
*
*/
private String name;
/**
* 城市
*/
private Integer cityId;
/**
*
*/
private String tel;
/**
*
*/
private String email;
/**
*
*/
private String address;
/**
*
*/
private String businessLicense;
/**
*
*/
private String foodBusinessLicense;
/**
*
*/
private String drugBusinessLicense;
/**
*
*/
private String medicalBusinessLicense;
/**
*
*/
private String twoMedicalBusinessLicense;
/**
*
*/
private Integer isCashDeposit;
/**
*
*/
private Long cashDeposit;
/**
*
*/
private Long totalRevenue;
/**
*
*/
private Long balance;
/**
*
*/
private Long freezeBalance;
/**
* 删除标志(0代表存在 2代表删除)
*/
@TableLogic
private String delFlag;
}
package com.pz.system.domain.bo;
import com.pz.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.*;
/**
* 商户业务对象 store_info
*
* @author ruoyi
* @date 2023-09-08
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class StoreInfoBo extends BaseEntity {
/**
*
*/
private Integer id;
/**
*
*/
private Integer storeId;
/**
*
*/
private String name;
/**
* 城市
*/
private Integer cityId;
/**
*
*/
private String tel;
/**
*
*/
private String email;
/**
*
*/
private String address;
/**
*
*/
private String businessLicense;
/**
*
*/
private String foodBusinessLicense;
/**
*
*/
private String drugBusinessLicense;
/**
*
*/
private String medicalBusinessLicense;
/**
*
*/
private String twoMedicalBusinessLicense;
/**
*
*/
private Integer isCashDeposit;
/**
*
*/
private Long cashDeposit;
/**
*
*/
private Long totalRevenue;
/**
*
*/
private Long balance;
/**
*
*/
private Long freezeBalance;
}
package com.pz.system.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.pz.common.annotation.ExcelDictFormat;
import com.pz.common.convert.ExcelDictConvert;
import lombok.Data;
/**
* 商户视图对象 store_info
*
* @author ruoyi
* @date 2023-09-08
*/
@Data
@ExcelIgnoreUnannotated
public class StoreInfoVo {
private static final long serialVersionUID = 1L;
/**
*
*/
@ExcelProperty(value = "")
private Integer id;
/**
*
*/
@ExcelProperty(value = "")
private Integer storeId;
/**
*
*/
@ExcelProperty(value = "")
private String name;
/**
* 城市
*/
@ExcelProperty(value = "城市")
private Integer cityId;
/**
*
*/
@ExcelProperty(value = "")
private String tel;
/**
*
*/
@ExcelProperty(value = "")
private String email;
/**
*
*/
@ExcelProperty(value = "")
private String address;
/**
*
*/
@ExcelProperty(value = "")
private String businessLicense;
/**
*
*/
@ExcelProperty(value = "")
private String foodBusinessLicense;
/**
*
*/
@ExcelProperty(value = "")
private String drugBusinessLicense;
/**
*
*/
@ExcelProperty(value = "")
private String medicalBusinessLicense;
/**
*
*/
@ExcelProperty(value = "")
private String twoMedicalBusinessLicense;
/**
*
*/
@ExcelProperty(value = "")
private Integer isCashDeposit;
/**
*
*/
@ExcelProperty(value = "")
private Long cashDeposit;
/**
*
*/
@ExcelProperty(value = "")
private Long totalRevenue;
/**
*
*/
@ExcelProperty(value = "")
private Long balance;
/**
*
*/
@ExcelProperty(value = "")
private Long freezeBalance;
}
package com.pz.system.mapper;
import com.pz.system.domain.StoreInfo;
import com.pz.system.domain.vo.StoreInfoVo;
import com.pz.common.core.mapper.BaseMapperPlus;
/**
* 商户Mapper接口
*
* @author ruoyi
* @date 2023-09-08
*/
public interface StoreInfoMapper extends BaseMapperPlus<StoreInfoMapper, StoreInfo, StoreInfoVo> {
}
package com.pz.system.service;
import com.pz.system.domain.StoreInfo;
import com.pz.system.domain.vo.StoreInfoVo;
import com.pz.system.domain.bo.StoreInfoBo;
import com.pz.common.core.page.TableDataInfo;
import com.pz.common.core.domain.PageQuery;
import java.util.Collection;
import java.util.List;
/**
* 商户Service接口
*
* @author ruoyi
* @date 2023-09-08
*/
public interface IStoreInfoService {
/**
* 查询商户
*/
StoreInfoVo queryById(Integer id);
/**
* 查询商户列表
*/
TableDataInfo<StoreInfoVo> queryPageList(StoreInfoBo bo, PageQuery pageQuery);
/**
* 查询商户列表
*/
List<StoreInfoVo> queryList(StoreInfoBo bo);
/**
* 新增商户
*/
Boolean insertByBo(StoreInfoBo bo);
/**
* 修改商户
*/
Boolean updateByBo(StoreInfoBo bo);
/**
* 校验并批量删除商户信息
*/
Boolean deleteWithValidByIds(Collection<Integer> ids, Boolean isValid);
}
package com.pz.system.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.pz.common.core.page.TableDataInfo;
import com.pz.common.core.domain.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import com.pz.system.domain.bo.StoreInfoBo;
import com.pz.system.domain.vo.StoreInfoVo;
import com.pz.system.domain.StoreInfo;
import com.pz.system.mapper.StoreInfoMapper;
import com.pz.system.service.IStoreInfoService;
import java.util.List;
import java.util.Map;
import java.util.Collection;
/**
* 商户Service业务层处理
*
* @author ruoyi
* @date 2023-09-08
*/
@RequiredArgsConstructor
@Service
public class StoreInfoServiceImpl implements IStoreInfoService {
private final StoreInfoMapper baseMapper;
/**
* 查询商户
*/
@Override
public StoreInfoVo queryById(Integer id){
return baseMapper.selectVoById(id);
}
/**
* 查询商户列表
*/
@Override
public TableDataInfo<StoreInfoVo> queryPageList(StoreInfoBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<StoreInfo> lqw = buildQueryWrapper(bo);
Page<StoreInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询商户列表
*/
@Override
public List<StoreInfoVo> queryList(StoreInfoBo bo) {
LambdaQueryWrapper<StoreInfo> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<StoreInfo> buildQueryWrapper(StoreInfoBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<StoreInfo> lqw = Wrappers.lambdaQuery();
lqw.eq(bo.getStoreId() != null, StoreInfo::getStoreId, bo.getStoreId());
lqw.like(StringUtils.isNotBlank(bo.getName()), StoreInfo::getName, bo.getName());
lqw.eq(bo.getCityId() != null, StoreInfo::getCityId, bo.getCityId());
lqw.eq(StringUtils.isNotBlank(bo.getTel()), StoreInfo::getTel, bo.getTel());
lqw.eq(StringUtils.isNotBlank(bo.getEmail()), StoreInfo::getEmail, bo.getEmail());
lqw.eq(StringUtils.isNotBlank(bo.getAddress()), StoreInfo::getAddress, bo.getAddress());
lqw.eq(StringUtils.isNotBlank(bo.getBusinessLicense()), StoreInfo::getBusinessLicense, bo.getBusinessLicense());
lqw.eq(StringUtils.isNotBlank(bo.getFoodBusinessLicense()), StoreInfo::getFoodBusinessLicense, bo.getFoodBusinessLicense());
lqw.eq(StringUtils.isNotBlank(bo.getDrugBusinessLicense()), StoreInfo::getDrugBusinessLicense, bo.getDrugBusinessLicense());
lqw.eq(StringUtils.isNotBlank(bo.getMedicalBusinessLicense()), StoreInfo::getMedicalBusinessLicense, bo.getMedicalBusinessLicense());
lqw.eq(StringUtils.isNotBlank(bo.getTwoMedicalBusinessLicense()), StoreInfo::getTwoMedicalBusinessLicense, bo.getTwoMedicalBusinessLicense());
lqw.eq(bo.getIsCashDeposit() != null, StoreInfo::getIsCashDeposit, bo.getIsCashDeposit());
lqw.eq(bo.getCashDeposit() != null, StoreInfo::getCashDeposit, bo.getCashDeposit());
lqw.eq(bo.getTotalRevenue() != null, StoreInfo::getTotalRevenue, bo.getTotalRevenue());
lqw.eq(bo.getBalance() != null, StoreInfo::getBalance, bo.getBalance());
lqw.eq(bo.getFreezeBalance() != null, StoreInfo::getFreezeBalance, bo.getFreezeBalance());
return lqw;
}
/**
* 新增商户
*/
@Override
public Boolean insertByBo(StoreInfoBo bo) {
StoreInfo add = BeanUtil.toBean(bo, StoreInfo.class);
validEntityBeforeSave(add);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
return flag;
}
/**
* 修改商户
*/
@Override
public Boolean updateByBo(StoreInfoBo bo) {
StoreInfo update = BeanUtil.toBean(bo, StoreInfo.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(StoreInfo entity){
//TODO 做一些数据校验,如唯一约束
}
/**
* 批量删除商户
*/
@Override
public Boolean deleteWithValidByIds(Collection<Integer> ids, Boolean isValid) {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment