Commit 485d61a4 by wuwenlong

Room manage dev;

Store mange opt;
code generator opt;
parent 8ec830ad
......@@ -2,19 +2,17 @@ package share.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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 org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import share.common.annotation.Log;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.domain.R;
import share.common.enums.BusinessType;
import share.system.domain.SConsumer;
import share.system.service.SConsumerService;
......@@ -28,77 +26,32 @@ import share.common.core.page.TableDataInfo;
* @date 2023-09-27
*/
@RestController
@RequestMapping("/system/consumer")
@RequestMapping("/front/consumer")
@Api(tags = "微信 -- 用户信息")
public class SConsumerController extends BaseController
{
@Autowired
private SConsumerService sConsumerService;
/**
* 查询会员用户列表
*/
@PreAuthorize("@ss.hasPermi('system:consumer:list')")
@GetMapping("/list")
public TableDataInfo list(SConsumer sConsumer)
{
startPage();
List<SConsumer> list = sConsumerService.selectSConsumerList(sConsumer);
return getDataTable(list);
}
/**
* 导出会员用户列表
* 个人中心-用户信息
*/
@PreAuthorize("@ss.hasPermi('system:consumer:export')")
@Log(title = "会员用户", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SConsumer sConsumer)
{
List<SConsumer> list = sConsumerService.selectSConsumerList(sConsumer);
ExcelUtil<SConsumer> util = new ExcelUtil<SConsumer>(SConsumer.class);
util.exportExcel(response, list, "会员用户数据");
@ApiOperation(value = "个人中心-用户信息")
@RequestMapping(value = "/info", method = RequestMethod.GET)
public R<SConsumer> getSConsumerCenter() {
return R.ok(sConsumerService.getSConsumer());
}
/**
* 获取会员用户详细信息
* 修改个人资料
*/
@PreAuthorize("@ss.hasPermi('system:consumer:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(sConsumerService.selectSConsumerById(id));
@ApiOperation(value = "修改个人资料")
@RequestMapping(value = "/edit", method = RequestMethod.POST)
public R<Object> personInfo(@RequestBody SConsumer request) {
if (sConsumerService.editSConsumer(request)) {
return R.ok();
}
/**
* 新增会员用户
*/
@PreAuthorize("@ss.hasPermi('system:consumer:add')")
@Log(title = "会员用户", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SConsumer sConsumer)
{
return toAjax(sConsumerService.insertSConsumer(sConsumer));
return R.fail();
}
/**
* 修改会员用户
*/
@PreAuthorize("@ss.hasPermi('system:consumer:edit')")
@Log(title = "会员用户", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SConsumer sConsumer)
{
return toAjax(sConsumerService.updateSConsumer(sConsumer));
}
/**
* 删除会员用户
*/
@PreAuthorize("@ss.hasPermi('system:consumer:remove')")
@Log(title = "会员用户", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sConsumerService.deleteSConsumerByIds(ids));
}
}
package share.web.controller.system;
import java.util.List;
import java.util.Objects;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
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 org.springframework.web.bind.annotation.*;
import share.common.annotation.Log;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.domain.R;
import share.common.enums.BusinessType;
import share.system.domain.SRoom;
import share.system.domain.vo.SRoomVo;
......@@ -29,7 +28,8 @@ import share.common.core.page.TableDataInfo;
* @date 2023-09-27
*/
@RestController
@RequestMapping("/system/room")
@RequestMapping("/front/room")
@Api(tags = "房间信息")
public class SRoomController extends BaseController
{
@Autowired
......@@ -38,7 +38,6 @@ public class SRoomController extends BaseController
/**
* 查询房间列表
*/
@PreAuthorize("@ss.hasPermi('system:room:list')")
@GetMapping("/list")
public TableDataInfo list(SRoom sRoom)
{
......@@ -47,59 +46,23 @@ public class SRoomController extends BaseController
return getDataTable(list);
}
/**
* 导出房间列表
*/
@PreAuthorize("@ss.hasPermi('system:room:export')")
@Log(title = "房间", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SRoom sRoom)
{
List<SRoomVo> list = sRoomService.selectSRoomList(sRoom);
ExcelUtil<SRoomVo> util = new ExcelUtil<SRoomVo>(SRoomVo.class);
util.exportExcel(response, list, "房间数据");
}
/**
* 获取房间详细信息
*/
@PreAuthorize("@ss.hasPermi('system:room:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(sRoomService.selectSRoomById(id));
@ApiOperation(value = "房间详情")
@RequestMapping(value = "/info", method = RequestMethod.GET)
public R<SRoomVo> getInfo(@RequestParam("id") Long id) {
SRoom room = sRoomService.getById(id);
SRoomVo vo = null;
if(Objects.nonNull(room)){
vo = new SRoomVo();
BeanUtils.copyProperties(room,vo);
}
/**
* 新增房间
*/
@PreAuthorize("@ss.hasPermi('system:room:add')")
@Log(title = "房间", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SRoom sRoom)
{
return toAjax(sRoomService.insertSRoom(sRoom));
return R.ok(vo);
}
/**
* 修改房间
*/
@PreAuthorize("@ss.hasPermi('system:room:edit')")
@Log(title = "房间", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SRoom sRoom)
{
return toAjax(sRoomService.updateSRoom(sRoom));
}
/**
* 删除房间
*/
@PreAuthorize("@ss.hasPermi('system:room:remove')")
@Log(title = "房间", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sRoomService.deleteSRoomByIds(ids));
}
}
......@@ -2,20 +2,21 @@ package share.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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 org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import share.common.annotation.Log;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.domain.R;
import share.common.enums.BusinessType;
import share.system.domain.SConsumer;
import share.system.domain.vo.SStoreVo;
import share.system.request.SStoreRequest;
import share.system.service.ISStoreService;
import share.common.utils.poi.ExcelUtil;
import share.common.core.page.TableDataInfo;
......@@ -28,7 +29,8 @@ import share.system.domain.SStore;
* @date 2023-09-27
*/
@RestController
@RequestMapping("/system/store")
@RequestMapping("/front/store")
@Api(tags = "门店信息")
public class SStoreController extends BaseController
{
@Autowired
......@@ -37,7 +39,6 @@ public class SStoreController extends BaseController
/**
* 查询门店列表
*/
@PreAuthorize("@ss.hasPermi('system:store:list')")
@GetMapping("/list")
public TableDataInfo list(SStore sStore)
{
......@@ -46,23 +47,10 @@ public class SStoreController extends BaseController
return getDataTable(list);
}
/**
* 导出门店列表
*/
@PreAuthorize("@ss.hasPermi('system:store:export')")
@Log(title = "门店", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SStore sStore)
{
List<SStore> list = sStoreService.selectSStoreList(sStore);
ExcelUtil<SStore> util = new ExcelUtil<SStore>(SStore.class);
util.exportExcel(response, list, "门店数据");
}
/**
* 获取门店详细信息
*/
@PreAuthorize("@ss.hasPermi('system:store:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
......@@ -70,35 +58,14 @@ public class SStoreController extends BaseController
}
/**
* 新增门店
*/
@PreAuthorize("@ss.hasPermi('system:store:add')")
@Log(title = "门店", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SStore sStore)
{
return toAjax(sStoreService.insertSStore(sStore));
}
/**
* 修改门店
* 查询门店列表
*/
@PreAuthorize("@ss.hasPermi('system:store:edit')")
@Log(title = "门店", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SStore sStore)
@ApiOperation(value = "按距离排序查询门店列表")
@RequestMapping(value = "/listVo", method = RequestMethod.POST)
public R<List<SStoreVo>> listByDistance(@RequestBody SStoreRequest request)
{
return toAjax(sStoreService.updateSStore(sStore));
startPage();
return R.ok(sStoreService.listVo(request));
}
/**
* 删除门店
*/
@PreAuthorize("@ss.hasPermi('system:store:remove')")
@Log(title = "门店", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(sStoreService.deleteSStoreByIds(ids));
}
}
......@@ -62,6 +62,8 @@ public class WebConfig implements WebMvcConfigurer {
"/webjars/**",
"/favicon.ico",
"/front/wechat/**",
"/front/login/**",
"/front/store/**",
"**"
).addPathPatterns("/**");
}
......
......@@ -5,6 +5,6 @@ gen:
# 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool
packageName: share.system
# 自动去除表前缀,默认是false
autoRemovePre: false
autoRemovePre: true
# 表前缀(生成类名不会包含表前缀,多个用逗号分隔)
tablePrefix: s_
\ No newline at end of file
......@@ -52,6 +52,12 @@
<artifactId>hutool-all</artifactId>
<version>4.5.7</version>
</dependency>
<dependency>
<groupId>org.locationtech.spatial4j</groupId>
<artifactId>spatial4j</artifactId>
<version>0.7</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -25,9 +25,9 @@ public class SConsumer
@ApiModelProperty(value = "用户账号")
private String account;
/** 微信用户openId */
@ApiModelProperty(value = "微信用户openId")
private String openId;
// /** 微信用户openId */
// @ApiModelProperty(value = "微信用户openId")
// private String openId;
/** 用户昵称 */
@ApiModelProperty(value = "用户昵称")
......
......@@ -192,7 +192,7 @@ public class FrontTokenComponent {
*/
public void logout(HttpServletRequest request) {
String token = getToken(request);
Integer userId = getSConsumerId();
Long userId = getSConsumerId();
delLoginSConsumer(token);
}
......@@ -200,7 +200,7 @@ public class FrontTokenComponent {
/**
* 获取当前登录用户id
*/
public Integer getSConsumerId() {
public Long getSConsumerId() {
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
String token = getToken(request);
if (StrUtil.isEmpty(token)) {
......
package share.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity;
/**
......@@ -23,59 +23,59 @@ public class SRoomVo extends BaseEntity
private Long id;
/** 门店ID */
@Excel(name = "门店ID")
@ApiModelProperty(value = "门店ID")
private Long storeId;
/** 门店名称 */
@Excel(name = "门店名称")
@ApiModelProperty(value = "门店名称")
private String storeName;
/** 房间名称 */
@Excel(name = "房间名称")
@ApiModelProperty(value = "房间名称")
private String name;
/** 房间类型(中、大、豪华包) */
@Excel(name = "房间类型(中、大、豪华包)")
@ApiModelProperty(value = "房间类型(中、大、豪华包)")
private String roomType;
/** 房间主图 */
@Excel(name = "房间主图")
@ApiModelProperty(value = "房间主图")
private String images;
/** 房间设施(空调、外窗、沙发、茶几、、、) */
@Excel(name = "房间设施(空调、外窗、沙发、茶几、、、)")
@ApiModelProperty(value = "房间设施(空调、外窗、沙发、茶几、、、)")
private String facilities;
/** 房间详情介绍 */
@Excel(name = "房间详情介绍")
@ApiModelProperty(value = "房间详情介绍")
private String info;
/** 房间状态(空闲、保洁中、使用中、维护中) */
@Excel(name = "房间状态(空闲、保洁中、使用中、维护中)")
@ApiModelProperty(value = "房间状态(空闲、保洁中、使用中、维护中)")
private String status;
/** 房间单价(默认单位:元/小时) */
@Excel(name = "房间单价(默认单位:元/小时)")
@ApiModelProperty(value = "房间单价(默认单位:元/小时)")
private Integer price;
/** 门锁编码(接入第三方使用) */
@Excel(name = "门锁编码(接入第三方使用)")
@ApiModelProperty(value = "门锁编码(接入第三方使用)")
private String doorLockCode;
/** 电控控制(接入第三方使用) */
@Excel(name = "电控控制(接入第三方使用)")
@ApiModelProperty(value = "电控控制(接入第三方使用)")
private String electricControlCode;
/** 门禁密码(多人可设置多个) */
@Excel(name = "门禁密码(多人可设置多个)")
@ApiModelProperty(value = "门禁密码(多人可设置多个)")
private String password;
/** 其他可能硬件接入参数(备用1) */
@Excel(name = "其他可能硬件接入参数(备用1)")
@ApiModelProperty(value = "其他可能硬件接入参数(备用1)")
private String params1;
/** 其他可能硬件接入参数(备用2) */
@Excel(name = "其他可能硬件接入参数(备用2)")
@ApiModelProperty(value = "其他可能硬件接入参数(备用2)")
private String params2;
@Override
......
package share.system.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import share.common.core.domain.BaseEntity;
import java.util.List;
/**
* 门店对象 s_store
*
* @author ruoyi
* @date 2023-10-11
*/
@Data
public class SStoreVo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 门店ID */
@ApiModelProperty(value = "门店ID")
private Long id;
/** 门店名称 */
@ApiModelProperty(value = "门店名称")
private String name;
/** 门店主图 */
@ApiModelProperty(value = "门店主图")
private String images;
/** 门店地址 */
@ApiModelProperty(value = "门店地址")
private String address;
/** 经度 */
@ApiModelProperty(value = "经度")
private String longitude;
/** 纬度 */
@ApiModelProperty(value = "纬度")
private String latitude;
/** 联系人 */
@ApiModelProperty(value = "联系人")
private String manager;
/** 联系人电话 */
@ApiModelProperty(value = "联系人电话")
private String phone;
/** 门店详情 */
@ApiModelProperty(value = "门店详情")
private String info;
/** 营业状态 0:停业 1:正常营业 */
@ApiModelProperty(value = "营业状态 0:停业 1:正常营业")
private String status;
/** 开始营业时间 */
@ApiModelProperty(value = "开始营业时间")
private String openStartTime;
/** 结束营业时间 */
@ApiModelProperty(value = "结束营业时间")
private String openEndTime;
/** 门店类型 1:标准店 2: 形象店 3:旗舰店 */
@ApiModelProperty(value = "门店类型 1:标准店 2: 形象店 3:旗舰店")
private String storeType;
@ApiModelProperty(value = "距离(KM)")
private String distance;
@ApiModelProperty(value = "房间列表")
private List<SRoomVo> roomVoList;
}
package share.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.SRoom;
/**
......@@ -9,7 +11,7 @@ import share.system.domain.SRoom;
* @author ruoyi
* @date 2023-09-27
*/
public interface SRoomMapper
public interface SRoomMapper extends BaseMapper<SRoom>
{
/**
* 查询房间
......
package share.system.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 门店对象 s_store
*
* @author ruoyi
* @date 2023-10-11
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="SStoreRequest对象", description="门店查询请求对象")
public class SStoreRequest implements Serializable {
private static final long serialVersionUID=1L;
/** 门店ID */
@ApiModelProperty(value = "门店ID")
private Long id;
/** 门店名称 */
@ApiModelProperty(value = "门店名称")
private String name;
/** 门店地址 */
@ApiModelProperty(value = "门店地址")
private String address;
/** 经度 */
@ApiModelProperty(value = "经度")
private String nowLongitude;
/** 纬度 */
@ApiModelProperty(value = "纬度")
private String nowLatitude;
/** 营业状态 0:停业 1:正常营业 */
@ApiModelProperty(value = "营业状态 0:停业 1:正常营业")
private String status;
/** 门店类型 1:标准店 2: 形象店 3:旗舰店 */
@ApiModelProperty(value = "门店类型 1:标准店 2: 形象店 3:旗舰店")
private String storeType;
}
package share.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.SRoom;
import share.system.domain.vo.SRoomVo;
......@@ -10,7 +12,7 @@ import share.system.domain.vo.SRoomVo;
* @author ruoyi
* @date 2023-09-27
*/
public interface ISRoomService
public interface ISRoomService extends IService<SRoom>
{
/**
* 查询房间
......@@ -59,4 +61,11 @@ public interface ISRoomService
* @return 结果
*/
public int deleteSRoomById(Long id);
/**
* 通过门店ID列表查询所有房间
* @param storeIds
* @return
*/
List<SRoomVo> listByStoreIds(List<Long> storeIds);
}
......@@ -5,6 +5,8 @@ import java.util.Map;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.SStore;
import share.system.domain.vo.SStoreVo;
import share.system.request.SStoreRequest;
/**
* 门店Service接口
......@@ -77,4 +79,11 @@ public interface ISStoreService extends IService<SStore>
* @return 门店集合
*/
public List<Map> optionList(List<Long> ids);
/**
* 查询门店列表
* @param request
* @return
*/
List<SStoreVo> listVo(SStoreRequest request);
}
......@@ -84,4 +84,28 @@ public interface SConsumerService extends IService<SConsumer>
SConsumer registerByThird(RegisterThirdSConsumerRequest thirdUserRequest);
/**
* 获取当前登陆用户个人信息(空则返回异常)
* @return
*/
SConsumer getSConsumer();
/**
* 获取当前登陆用户个人信息
* @return
*/
SConsumer getInfo();
/**
* 获取当前登陆用户ID
* @return
*/
Long getUserId();
/**
* 修改个人资料
* @param request
* @return
*/
boolean editSConsumer(SConsumer request);
}
......@@ -110,11 +110,11 @@ public class SConsumerCenterServiceImpl extends ServiceImpl<SConsumerMapper, SCo
return loginResponse;
}
if (StrUtil.isBlank(request.getNickName()) && StrUtil.isBlank(request.getAvatar())) {
/*if (StrUtil.isBlank(request.getNickName()) && StrUtil.isBlank(request.getAvatar())) {
// 返回后,前端去走注册起始页
loginResponse.setType("start");
return loginResponse;
}
}*/
request.setOpenId(response.getOpenId());
String key = SecureUtil.md5(response.getOpenId());
redisUtil.set(key, JSONObject.toJSONString(request), (long) (60 * 2), TimeUnit.MINUTES);
......@@ -133,7 +133,7 @@ public class SConsumerCenterServiceImpl extends ServiceImpl<SConsumerMapper, SCo
@DSTransactional
@Override
public LoginResponse registerBindingPhone(WxBindingPhoneRequest request) {
checkBindingPhone(request);
checkLoginPhone(request);
// 进入创建用户绑定手机号流程
Object o = redisUtil.get(request.getKey());
if (ObjectUtil.isNull(o)) {
......
......@@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.codec.digest.DigestUtils;
......@@ -11,8 +12,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.constant.Constants;
import share.common.constant.SmsConstants;
import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil;
import share.common.utils.DateUtil;
import share.system.domain.vo.FrontTokenComponent;
import share.system.mapper.SConsumerMapper;
import share.system.domain.SConsumer;
import share.system.request.RegisterThirdSConsumerRequest;
......@@ -30,6 +33,9 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
@Autowired
private SConsumerMapper sConsumerMapper;
@Autowired
private FrontTokenComponent tokenComponet;
/**
* 查询会员用户
*
......@@ -134,12 +140,46 @@ public class SConsumerServiceImpl extends ServiceImpl<SConsumerMapper, SConsumer
public SConsumer registerByThird(RegisterThirdSConsumerRequest thirdSConsumerRequest) {
SConsumer user = new SConsumer();
user.setAccount(DigestUtils.md5Hex(BaseUtil.getUuid() + DateUtil.getNowTime()));
user.setNickName(thirdSConsumerRequest.getNickName());
String avatar = thirdSConsumerRequest.getAvatar();
user.setAvatar(avatar);
user.setSex(Integer.parseInt(thirdSConsumerRequest.getSex()));
user.setAddres(thirdSConsumerRequest.getCountry() + "," + thirdSConsumerRequest.getProvince() + "," + thirdSConsumerRequest.getCity());
// user.setNickName(thirdSConsumerRequest.getNickName());
// String avatar = thirdSConsumerRequest.getAvatar();
//
// user.setAvatar(avatar);
// user.setSex(Integer.parseInt(thirdSConsumerRequest.getSex()));
// user.setAddres(thirdSConsumerRequest.getCountry() + "," + thirdSConsumerRequest.getProvince() + "," + thirdSConsumerRequest.getCity());
return user;
}
@Override
public SConsumer getSConsumer() {
SConsumer currentUser = getInfo();
if (ObjectUtil.isNull(currentUser)) {
throw new BaseException("您的登录已过期,请先登录");
}
return currentUser;
}
/**
* 获取个人资料
*/
@Override
public SConsumer getInfo() {
if (getUserId() == 0) {
return null;
}
return this.selectSConsumerById(getUserId());
}
@Override
public Long getUserId() {
Long id = tokenComponet.getSConsumerId();
if (null == id) {
return 0L;
}
return id;
}
@Override
public boolean editSConsumer(SConsumer request) {
return updateById(request);
}
}
......@@ -6,6 +6,9 @@ import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.BeanUtils;
import share.common.utils.DateUtils;
......@@ -25,7 +28,7 @@ import share.system.service.ISStoreService;
* @date 2023-09-27
*/
@Service
public class SRoomServiceImpl implements ISRoomService
public class SRoomServiceImpl extends ServiceImpl<SRoomMapper,SRoom> implements ISRoomService
{
@Autowired
private SRoomMapper sRoomMapper;
......@@ -130,4 +133,25 @@ public class SRoomServiceImpl implements ISRoomService
{
return sRoomMapper.deleteSRoomById(id);
}
@Override
public List<SRoomVo> listByStoreIds(List<Long> storeIds) {
LambdaQueryWrapper<SRoom> queryWrapper = new LambdaQueryWrapper();
queryWrapper.in(SRoom::getStoreId,storeIds);
List<SRoom> roomList = sRoomMapper.selectList(queryWrapper);
return convertDoListToVoList(roomList);
}
private List<SRoomVo> convertDoListToVoList(List<SRoom> roomList){
List<SRoomVo> voList = new ArrayList<>();
if(CollectionUtils.isNotEmpty(roomList)){
roomList.stream().forEach( o -> {
SRoomVo vo = new SRoomVo();
BeanUtils.copyProperties(o,vo);
voList.add(vo);
});
}
return voList;
}
}
package share.system.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.util.Store;
import org.locationtech.spatial4j.context.SpatialContext;
import org.locationtech.spatial4j.distance.DistanceUtils;
import org.springframework.beans.BeanUtils;
import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.system.domain.vo.SRoomVo;
import share.system.domain.vo.SStoreVo;
import share.system.mapper.SStoreMapper;
import share.system.domain.SStore;
import share.system.request.SStoreRequest;
import share.system.service.ISRoomService;
import share.system.service.ISStoreService;
/**
......@@ -27,6 +35,9 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
@Autowired
private SStoreMapper sStoreMapper;
@Autowired
private ISRoomService sRoomService;
/**
* 查询门店
*
......@@ -113,6 +124,75 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
return convertOptionList(storeList);
}
@Override
public List<SStoreVo> listVo(SStoreRequest request) {
if(StringUtils.isBlank(request.getStatus())){
//默认营业状态
request.setStatus(YesNoEnum.yes.getIndex().toString());
}
listVoCheck(request);
Double nowLng = Double.parseDouble(request.getNowLongitude());
Double nowLat = Double.parseDouble(request.getNowLatitude());
SStore store = new SStore();
store.setStatus(request.getStatus());
List<SStore> storeList = sStoreMapper.selectSStoreList(store);
List<SStoreVo> voList = new ArrayList<>();
if(CollectionUtils.isNotEmpty(storeList)){
SpatialContext geo = SpatialContext.GEO;
storeList.stream().forEach( o -> {
double distance = geo.calcDistance(geo.makePoint(nowLng,nowLat)
, geo.makePoint(Double.parseDouble(o.getLongitude()), Double.parseDouble(o.getLatitude())))
* DistanceUtils.DEG_TO_KM;
SStoreVo vo = new SStoreVo();
BeanUtils.copyProperties(o,vo);
vo.setDistance(distance+"");
voList.add(vo);
});
voList.stream().sorted(Comparator.comparing(storeVo -> Double.parseDouble(storeVo.getDistance())));
}
handleSStoreVoList(voList);
return voList;
}
private void listVoCheck(SStoreRequest request) throws BaseException{
if(StringUtils.isNotBlank(request.getNowLongitude())||StringUtils.isNotBlank(request.getNowLatitude())) {
try {
Double.parseDouble(request.getNowLongitude());
} catch (Exception e) {
throw new BaseException("请求参数当前经度异常!");
}
try {
Double.parseDouble(request.getNowLatitude());
} catch (Exception e) {
throw new BaseException("请求参数当前纬度异常!");
}
}
try {
if (StringUtils.isNotBlank(request.getStatus()) &&
Integer.compare(Integer.parseInt(request.getStatus()), 0) != 0 &&
Integer.compare(Integer.parseInt(request.getStatus()), 1) != 0) {
throw new BaseException("请求参数门店状态异常!");
}
}catch (Exception e){
throw new BaseException("请求参数门店状态异常!");
}
}
public void handleSStoreVoList(List<SStoreVo> voList){
if(CollectionUtils.isNotEmpty(voList)) {
List<Long> storeIds = voList.stream().map(SStoreVo::getId).collect(Collectors.toList());
List<SRoomVo> roomVoList = sRoomService.listByStoreIds(storeIds);
voList.stream().forEach( storeVo -> {
storeVo.setRoomVoList(roomVoList.stream().filter( roomVo -> {
if(Long.compare(roomVo.getStoreId(),storeVo.getId())==0){
return true;
}
return false;
}).collect(Collectors.toList()));
});
}
}
private List<Map> convertOptionList(List<SStore> storeList){
List<Map> result = new ArrayList<>();
if(CollectionUtils.isNotEmpty(storeList)) {
......
......@@ -80,7 +80,7 @@ public class SmsServiceImpl implements SmsService {
@Override
public boolean sendSmsCode(String phone) {
redisUtil.set(sConsumerService.getValidateCodeRedisKey(phone), "1234", Long.valueOf(Constants.CONFIG_KEY_SMS_CODE_EXPIRE), TimeUnit.MINUTES);
redisUtil.set(sConsumerService.getValidateCodeRedisKey(phone), "123456", Long.valueOf(Constants.CONFIG_KEY_SMS_CODE_EXPIRE), TimeUnit.MINUTES);
return true;//TODO 手机验证吗待对接短信平台 sendSms(phone, SmsConstants.SMS_CONFIG_TYPE_VERIFICATION_CODE);
}
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="share.system.mapper.SConsumerMapper">
<resultMap type="SConsumer" id="SConsumerResult">
<result property="id" column="id" />
<result property="openId" column="open_id" />
<result property="account" column="account" />
<result property="nickName" column="nick_name" />
<result property="avatar" column="avatar" />
<result property="phone" column="phone" />
<result property="level" column="level" />
<result property="roleType" column="role_type" />
<result property="sex" column="sex" />
<result property="addres" column="addres" />
<result property="amount" column="amount" />
<result property="freeAmount" column="free_amount" />
<result property="totalTimes" column="total_times" />
<result property="duration" column="duration" />
<result property="status" column="status" />
<result property="pwd" column="pwd" />
<result property="createTime" column="create_time" />
<result property="lastLoginTime" column="last_login_time" />
</resultMap>
<sql id="selectSConsumerVo">
select id, open_id, nick_name, phone, level, role_type, sex, amount, free_amount, total_times, duration from s_consumer
select id, account, nick_name, avatar, phone, level, role_type, sex, addres, amount, free_amount, total_times, duration, status, pwd, create_time, last_login_time from s_consumer
</sql>
<select id="selectSConsumerList" parameterType="SConsumer" resultMap="SConsumerResult">
<include refid="selectSConsumerVo"/>
<where>
<if test="account != null and account != ''"> and account = #{account}</if>
<if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
<if test="avatar != null and avatar != ''"> and avatar = #{avatar}</if>
<if test="phone != null and phone != ''"> and phone = #{phone}</if>
<if test="level != null "> and level = #{level}</if>
<if test="roleType != null "> and role_type = #{roleType}</if>
<if test="sex != null "> and sex = #{sex}</if>
<if test="addres != null and addres != ''"> and addres = #{addres}</if>
<if test="amount != null "> and amount = #{amount}</if>
<if test="freeAmount != null "> and free_amount = #{freeAmount}</if>
<if test="totalTimes != null "> and total_times = #{totalTimes}</if>
<if test="duration != null "> and duration = #{duration}</if>
<if test="status != null "> and status = #{status}</if>
<if test="pwd != null and pwd != ''"> and pwd = #{pwd}</if>
<if test="lastLoginTime != null "> and last_login_time = #{lastLoginTime}</if>
</where>
</select>
......@@ -45,44 +57,62 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertSConsumer" parameterType="SConsumer" useGeneratedKeys="true" keyProperty="id">
insert into s_consumer
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="openId != null and openId != ''">open_id,</if>
<if test="account != null and account != ''">account,</if>
<if test="nickName != null and nickName != ''">nick_name,</if>
<if test="avatar != null">avatar,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="level != null">level,</if>
<if test="roleType != null">role_type,</if>
<if test="sex != null">sex,</if>
<if test="addres != null">addres,</if>
<if test="amount != null">amount,</if>
<if test="freeAmount != null">free_amount,</if>
<if test="totalTimes != null">total_times,</if>
<if test="duration != null">duration,</if>
<if test="status != null">status,</if>
<if test="pwd != null and pwd != ''">pwd,</if>
<if test="createTime != null">create_time,</if>
<if test="lastLoginTime != null">last_login_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="openId != null and openId != ''">#{openId},</if>
<if test="account != null and account != ''">#{account},</if>
<if test="nickName != null and nickName != ''">#{nickName},</if>
<if test="avatar != null">#{avatar},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="level != null">#{level},</if>
<if test="roleType != null">#{roleType},</if>
<if test="sex != null">#{sex},</if>
<if test="addres != null">#{addres},</if>
<if test="amount != null">#{amount},</if>
<if test="freeAmount != null">#{freeAmount},</if>
<if test="totalTimes != null">#{totalTimes},</if>
<if test="duration != null">#{duration},</if>
<if test="status != null">#{status},</if>
<if test="pwd != null and pwd != ''">#{pwd},</if>
<if test="createTime != null">#{createTime},</if>
<if test="lastLoginTime != null">#{lastLoginTime},</if>
</trim>
</insert>
<update id="updateSConsumer" parameterType="SConsumer">
update s_consumer
<trim prefix="SET" suffixOverrides=",">
<if test="openId != null and openId != ''">open_id = #{openId},</if>
<if test="account != null and account != ''">account = #{account},</if>
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
<if test="avatar != null">avatar = #{avatar},</if>
<if test="phone != null and phone != ''">phone = #{phone},</if>
<if test="level != null">level = #{level},</if>
<if test="roleType != null">role_type = #{roleType},</if>
<if test="sex != null">sex = #{sex},</if>
<if test="addres != null">addres = #{addres},</if>
<if test="amount != null">amount = #{amount},</if>
<if test="freeAmount != null">free_amount = #{freeAmount},</if>
<if test="totalTimes != null">total_times = #{totalTimes},</if>
<if test="duration != null">duration = #{duration},</if>
<if test="status != null">status = #{status},</if>
<if test="pwd != null and pwd != ''">pwd = #{pwd},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="lastLoginTime != null">last_login_time = #{lastLoginTime},</if>
</trim>
where id = #{id}
</update>
......
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