小程序店铺相关
This commit is contained in:
parent
766351e0f6
commit
d5b9107c6e
Binary file not shown.
|
Before Width: | Height: | Size: 3.7 KiB |
|
|
@ -0,0 +1,9 @@
|
|||
package cn.pluss.platform.mapper;
|
||||
|
||||
import cn.pluss.platform.entity.AppletStore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface AppletStoreMapper extends BaseMapper<AppletStore> {
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package cn.pluss.platform.mapper;
|
||||
|
||||
import cn.pluss.platform.entity.Account;
|
||||
import cn.pluss.platform.entity.AppletInfo;
|
||||
import cn.pluss.platform.entity.AppletStoreUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Mapper
|
||||
public interface AppletStoreUserMapper extends BaseMapper<AppletStoreUser> {
|
||||
|
||||
@Select("SELECT * FROM tb_pluss_applet_store_user WHERE userId = #{userId}")
|
||||
List<AppletStoreUser> getAppletStoreByUser(@Param("userId") Integer userId);
|
||||
@Select("SELECT * FROM tb_pluss_applet_store_user WHERE userId = #{userId} AND appleStoreId = #{appleStoreId}")
|
||||
AppletStoreUser getAppletByUserStore(@Param("userId") Integer userId, @Param("appleStoreId") Integer appleStoreId);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package cn.pluss.platform.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Data
|
||||
@TableName("tb_pluss_applet_store")
|
||||
public class AppletStore {
|
||||
private Integer id;
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
private String storeName;
|
||||
/**
|
||||
* 图标
|
||||
*/
|
||||
private String icon;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 0.不显示1.显示
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 小程序跳转地址
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "createTime", fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
/**
|
||||
*小程序appId
|
||||
*/
|
||||
private String appId;
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package cn.pluss.platform.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
|
||||
@Data
|
||||
@TableName("tb_pluss_applet_store_user")
|
||||
public class AppletStoreUser {
|
||||
private Integer id;
|
||||
private Integer appleStoreId;
|
||||
private Integer userId;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "createTime", fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package cn.pluss.platform.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Data
|
||||
public class AppletStoreVO {
|
||||
private Integer id;
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
private String storeName;
|
||||
/**
|
||||
* 图标
|
||||
*/
|
||||
private String icon;
|
||||
|
||||
/**
|
||||
* 小程序跳转地址
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 用户是否开通 0未开通 1已开通
|
||||
*/
|
||||
private Integer isOpen = 0;
|
||||
/**
|
||||
*小程序appId
|
||||
*/
|
||||
private String appId;
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package cn.pluss.platform.AppletStoreUser;
|
||||
|
||||
import cn.pluss.platform.entity.AppletInfo;
|
||||
import cn.pluss.platform.entity.AppletStoreUser;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
public interface AppletStoreUserService extends IService<AppletStoreUser> {
|
||||
Integer addAppletStoreUser(AppletStoreUser appletStoreUser);
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package cn.pluss.platform.AppletStoreUser.impl;
|
||||
|
||||
import cn.pluss.platform.AppletStoreUser.AppletStoreUserService;
|
||||
import cn.pluss.platform.appletInfo.AppletInfoService;
|
||||
import cn.pluss.platform.entity.AppletInfo;
|
||||
import cn.pluss.platform.entity.AppletStore;
|
||||
import cn.pluss.platform.entity.AppletStoreUser;
|
||||
import cn.pluss.platform.exception.MsgException;
|
||||
import cn.pluss.platform.mapper.AppletInfoMapper;
|
||||
import cn.pluss.platform.mapper.AppletStoreMapper;
|
||||
import cn.pluss.platform.mapper.AppletStoreUserMapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Service
|
||||
public class AppletStoreUserServiceImpl extends ServiceImpl<AppletStoreUserMapper, AppletStoreUser> implements AppletStoreUserService {
|
||||
@Resource
|
||||
private AppletStoreUserMapper appletStoreUserMapper;
|
||||
@Resource
|
||||
private AppletStoreMapper appletStoreMapper;
|
||||
@Override
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public Integer addAppletStoreUser(AppletStoreUser appletStoreUser) {
|
||||
AppletStoreUser appletByUserStore = appletStoreUserMapper.getAppletByUserStore(appletStoreUser.getUserId(), appletStoreUser.getAppleStoreId());
|
||||
if (appletByUserStore != null){
|
||||
throw new MsgException("请勿重复绑定");
|
||||
}
|
||||
QueryWrapper<AppletStore> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("id", appletStoreUser.getAppleStoreId());
|
||||
AppletStore appletStore = appletStoreMapper.selectOne(queryWrapper);
|
||||
if (appletStore == null || appletStore.getType() == 0){
|
||||
throw new MsgException("未找到店铺号");
|
||||
}
|
||||
appletStoreUser.setCreateTime(new Date());
|
||||
return baseMapper.insert(appletStoreUser);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package cn.pluss.platform.access.exception;
|
||||
|
||||
import cn.pluss.platform.bsj.conn.domain.CodeEnum;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* bsj错误类
|
||||
* @author lyf
|
||||
*/
|
||||
public class AccessException extends RuntimeException{
|
||||
public AccessException(CodeEnum codeEnum, String message) {
|
||||
super(StringUtils.isNotBlank(message) ? message : codeEnum.getDesc());
|
||||
}
|
||||
|
||||
public AccessException(CodeEnum codeEnum) {
|
||||
super(codeEnum.getDesc());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package cn.pluss.platform.appletStore;
|
||||
|
||||
import cn.pluss.platform.entity.AppletStore;
|
||||
import cn.pluss.platform.vo.AppletStoreVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
public interface AppletStoreService extends IService<AppletStore> {
|
||||
List<AppletStoreVO> getList(Integer userId);
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package cn.pluss.platform.appletStore.impl;
|
||||
|
||||
import cn.pluss.platform.appletStore.AppletStoreService;
|
||||
import cn.pluss.platform.entity.AppletStore;
|
||||
import cn.pluss.platform.entity.AppletStoreUser;
|
||||
import cn.pluss.platform.mapper.AppletStoreMapper;
|
||||
import cn.pluss.platform.mapper.AppletStoreUserMapper;
|
||||
import cn.pluss.platform.util.BeanUtils;
|
||||
import cn.pluss.platform.vo.AppletStoreVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Service
|
||||
public class AppletStoreServiceImpl extends ServiceImpl<AppletStoreMapper, AppletStore> implements AppletStoreService {
|
||||
|
||||
@Resource
|
||||
private AppletStoreUserMapper appletStoreUserMapper;
|
||||
|
||||
@Override
|
||||
public List<AppletStoreVO> getList(Integer userId) {
|
||||
QueryWrapper<AppletStore> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("type", 1);
|
||||
queryWrapper.orderByAsc("sort");
|
||||
List<AppletStore> appletStores = getBaseMapper().selectList(queryWrapper);
|
||||
List<AppletStoreUser> appletStoreByUser = appletStoreUserMapper.getAppletStoreByUser(userId);
|
||||
//Map<Integer, AppletStoreUser> maps = appletStoreByUser.stream().collect(Collectors.toMap(AppletStoreUser::getId, Function.identity()));
|
||||
ArrayList<AppletStoreVO> appletStoreVOList = new ArrayList<>();
|
||||
for (AppletStore appletStore : appletStores) {
|
||||
AppletStoreVO appletStoreVO = new AppletStoreVO();
|
||||
for (AppletStoreUser value : appletStoreByUser) {
|
||||
if (value.getAppleStoreId().equals(appletStore.getId())){
|
||||
appletStoreVO.setIsOpen(1);
|
||||
}
|
||||
}
|
||||
if ("餐饮商超".equals(appletStore.getStoreName())){
|
||||
appletStoreVO.setIsOpen(1);
|
||||
}
|
||||
appletStoreVO.setId(appletStore.getId());
|
||||
appletStoreVO.setStoreName(appletStore.getStoreName());
|
||||
appletStoreVO.setIcon(appletStore.getIcon());
|
||||
appletStoreVO.setUrl(appletStore.getUrl());
|
||||
appletStoreVO.setAppId(appletStore.getAppId());
|
||||
appletStoreVOList.add(appletStoreVO);
|
||||
}
|
||||
return appletStoreVOList;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue