Commit 3ab6e756 authored by shengnan hu's avatar shengnan hu
Browse files

init

parents
Pipeline #294 passed with stage
in 2 minutes and 13 seconds
package com.mall4j.cloud.multishop;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* @author FrozenWatermelon
* @date 2020/09/03
*/
@SpringBootApplication(scanBasePackages = { "com.mall4j.cloud" })
@EnableFeignClients(basePackages = {"com.mall4j.cloud.api.**.feign"})
public class MultishopApplication {
public static void main(String[] args) {
SpringApplication.run(MultishopApplication.class, args);
}
}
package com.mall4j.cloud.multishop.constant;
/**
* 店铺状态
*
* @author YXF
*/
public enum ShopStatus {
/**
* 未开通
*/
DELETE(-1),
/**
* 停业中
*/
STOP(0),
/**
* 营业中
*/
OPEN(1)
;
private Integer num;
public Integer value() {
return num;
}
ShopStatus(Integer num) {
this.num = num;
}
public static ShopStatus instance(Integer value) {
ShopStatus[] enums = values();
for (ShopStatus statusEnum : enums) {
if (statusEnum.value().equals(value)) {
return statusEnum;
}
}
return null;
}
}
package com.mall4j.cloud.multishop.constant;
/**
* 店铺状态
*
* @author YXF
*/
public enum ShopType {
/**
* 自营店
*/
SELF_SHOP(-1),
/**
* 其他店铺
*/
STOP(0)
;
private Integer num;
public Integer value() {
return num;
}
ShopType(Integer num) {
this.num = num;
}
public static ShopType instance(Integer value) {
ShopType[] enums = values();
for (ShopType statusEnum : enums) {
if (statusEnum.value().equals(value)) {
return statusEnum;
}
}
return null;
}
}
package com.mall4j.cloud.multishop.controller;
import com.mall4j.cloud.api.auth.vo.AuthAccountVO;
import com.mall4j.cloud.common.response.ResponseEnum;
import com.mall4j.cloud.common.response.ServerResponseEntity;
import com.mall4j.cloud.common.security.AuthUserContext;
import com.mall4j.cloud.multishop.dto.ChangeAccountDTO;
import com.mall4j.cloud.multishop.service.ShopUserAccountService;
import com.mall4j.cloud.multishop.service.ShopUserService;
import com.mall4j.cloud.multishop.vo.ShopUserVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import java.util.Objects;
/**
* @author FrozenWatermelon
* @date 2020/09/02
*/
@RequestMapping(value = "/shop_user/account")
@RestController
@Tag(name = "店铺用户账号信息")
public class ShopUserAccountController {
private final ShopUserAccountService shopUserAccountService;
private final ShopUserService shopUserService;
public ShopUserAccountController(ShopUserAccountService shopUserAccountService, ShopUserService shopUserService) {
this.shopUserAccountService = shopUserAccountService;
this.shopUserService = shopUserService;
}
@GetMapping
@Operation(summary = "获取账号信息" , description = "获取账号信息")
public ServerResponseEntity<AuthAccountVO> getAccount(Long shopUserId) {
return shopUserAccountService.getByUserIdAndSysType(shopUserId, AuthUserContext.get().getSysType());
}
@PostMapping
@Operation(summary = "添加账号" , description = "添加账号")
public ServerResponseEntity<Void> addAccount(@Valid @RequestBody ChangeAccountDTO changeAccountDTO) {
ShopUserVO shopUserVO = shopUserService.getByUserId(changeAccountDTO.getUserId());
if (shopUserVO == null) {
return ServerResponseEntity.showFailMsg("无法获取账户信息");
}
if (Objects.equals(shopUserVO.getHasAccount(), 1)) {
return ServerResponseEntity.showFailMsg("已有账号,无需重复添加");
}
if (!Objects.equals(shopUserVO.getShopId(), AuthUserContext.get().getTenantId())) {
return ServerResponseEntity.fail(ResponseEnum.UNAUTHORIZED);
}
return shopUserAccountService.save(changeAccountDTO);
}
@PutMapping
@Operation(summary = "修改账号" , description = "修改账号")
public ServerResponseEntity<Void> updateAccount(@Valid @RequestBody ChangeAccountDTO changeAccountDTO) {
ShopUserVO shopUserVO = shopUserService.getByUserId(changeAccountDTO.getUserId());
if (shopUserVO == null || Objects.equals(shopUserVO.getHasAccount(), 0)) {
return ServerResponseEntity.showFailMsg("无法获取账户信息");
}
if (!Objects.equals(shopUserVO.getShopId(), AuthUserContext.get().getTenantId())) {
return ServerResponseEntity.fail(ResponseEnum.UNAUTHORIZED);
}
return shopUserAccountService.update(changeAccountDTO);
}
}
package com.mall4j.cloud.multishop.controller.admin;
import com.mall4j.cloud.multishop.model.HotSearch;
import com.mall4j.cloud.multishop.service.HotSearchService;
import com.mall4j.cloud.multishop.vo.HotSearchVO;
import com.mall4j.cloud.multishop.dto.HotSearchDTO;
import com.mall4j.cloud.common.database.dto.PageDTO;
import com.mall4j.cloud.common.database.vo.PageVO;
import com.mall4j.cloud.common.response.ServerResponseEntity;
import com.mall4j.cloud.common.security.AuthUserContext;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import com.mall4j.cloud.common.util.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
/**
* 热搜
*
* @author YXF
* @date 2021-01-27 09:10:00
*/
@RestController("adminHotSearchController")
@RequestMapping("/admin/hot_search")
@Tag(name = "admin-热搜")
public class HotSearchController {
@Autowired
private HotSearchService hotSearchService;
@GetMapping("/page")
@Operation(summary = "分页获取热搜列表" , description = "分页获取热搜列表")
public ServerResponseEntity<PageVO<HotSearchVO>> page(@Valid PageDTO pageDTO, HotSearchDTO hotSearchDTO) {
hotSearchDTO.setShopId(AuthUserContext.get().getTenantId());
PageVO<HotSearchVO> hotSearchPage = hotSearchService.page(pageDTO, hotSearchDTO);
return ServerResponseEntity.success(hotSearchPage);
}
@GetMapping
@Operation(summary = "获取热搜" , description = "根据hotSearchId获取热搜")
public ServerResponseEntity<HotSearchVO> getByHotSearchId(@RequestParam Long hotSearchId) {
return ServerResponseEntity.success(hotSearchService.getByHotSearchId(hotSearchId));
}
@PostMapping
@Operation(summary = "保存热搜" , description = "保存热搜")
public ServerResponseEntity<Void> save(@Valid @RequestBody HotSearchDTO hotSearchDTO) {
HotSearch hotSearch = BeanUtil.map(hotSearchDTO, HotSearch.class);
hotSearch.setShopId(AuthUserContext.get().getTenantId());
hotSearchService.save(hotSearch);
hotSearchService.removeHotSearchListCache(hotSearch.getShopId());
return ServerResponseEntity.success();
}
@PutMapping
@Operation(summary = "更新热搜" , description = "更新热搜")
public ServerResponseEntity<Void> update(@Valid @RequestBody HotSearchDTO hotSearchDTO) {
HotSearch hotSearch = BeanUtil.map(hotSearchDTO, HotSearch.class);
hotSearch.setShopId(AuthUserContext.get().getTenantId());
hotSearchService.update(hotSearch);
hotSearchService.removeHotSearchListCache(hotSearch.getShopId());
return ServerResponseEntity.success();
}
@DeleteMapping
@Operation(summary = "删除热搜" , description = "根据热搜id删除热搜")
public ServerResponseEntity<Void> delete(@RequestParam Long hotSearchId) {
Long shopId = AuthUserContext.get().getTenantId();
hotSearchService.deleteById(hotSearchId, shopId);
hotSearchService.removeHotSearchListCache(shopId);
return ServerResponseEntity.success();
}
}
package com.mall4j.cloud.multishop.controller.admin;
import com.mall4j.cloud.api.product.feign.SpuFeignClient;
import com.mall4j.cloud.api.product.vo.SpuVO;
import com.mall4j.cloud.common.constant.StatusEnum;
import com.mall4j.cloud.common.database.dto.PageDTO;
import com.mall4j.cloud.common.database.vo.PageVO;
import com.mall4j.cloud.common.response.ServerResponseEntity;
import com.mall4j.cloud.common.security.AuthUserContext;
import com.mall4j.cloud.multishop.dto.IndexImgDTO;
import com.mall4j.cloud.multishop.model.IndexImg;
import com.mall4j.cloud.multishop.service.IndexImgService;
import com.mall4j.cloud.multishop.vo.IndexImgVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import com.mall4j.cloud.common.util.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import java.util.Objects;
/**
* 轮播图
*
* @author YXF
* @date 2020-11-24 16:38:32
*/
@RestController("adminIndexImgController")
@RequestMapping("/admin/index_img")
@Tag(name = "admin-轮播图")
public class IndexImgController {
@Autowired
private IndexImgService indexImgService;
@Autowired
private SpuFeignClient spuFeignClient;
@GetMapping("/page")
@Operation(summary = "获取轮播图列表" , description = "分页获取轮播图列表")
public ServerResponseEntity<PageVO<IndexImgVO>> page(@Valid PageDTO pageDTO, IndexImgDTO indexImgDTO) {
indexImgDTO.setShopId(AuthUserContext.get().getTenantId());
PageVO<IndexImgVO> indexImgPage = indexImgService.page(pageDTO, indexImgDTO);
return ServerResponseEntity.success(indexImgPage);
}
@GetMapping
@Operation(summary = "获取轮播图" , description = "根据imgId获取轮播图")
public ServerResponseEntity<IndexImgVO> getByImgId(@RequestParam Long imgId) {
IndexImgVO indexImg = indexImgService.getByImgId(imgId);
if (Objects.nonNull(indexImg.getSpuId())) {
ServerResponseEntity<SpuVO> spuResponse = spuFeignClient.getById(indexImg.getSpuId());
indexImg.setSpu(spuResponse.getData());
}
return ServerResponseEntity.success(indexImg);
}
@PostMapping
@Operation(summary = "保存轮播图" , description = "保存轮播图")
public ServerResponseEntity<Void> save(@Valid @RequestBody IndexImgDTO indexImgDTO) {
IndexImg indexImg = BeanUtil.map(indexImgDTO, IndexImg.class);
indexImg.setImgId(null);
indexImg.setShopId(AuthUserContext.get().getTenantId());
indexImg.setStatus(StatusEnum.ENABLE.value());
indexImgService.save(indexImg);
return ServerResponseEntity.success();
}
@PutMapping
@Operation(summary = "更新轮播图" , description = "更新轮播图")
public ServerResponseEntity<Void> update(@Valid @RequestBody IndexImgDTO indexImgDTO) {
IndexImg indexImg = BeanUtil.map(indexImgDTO, IndexImg.class);
indexImg.setShopId(AuthUserContext.get().getTenantId());
indexImgService.update(indexImg);
return ServerResponseEntity.success();
}
@DeleteMapping
@Operation(summary = "删除轮播图" , description = "根据轮播图id删除轮播图")
public ServerResponseEntity<Void> delete(@RequestParam Long imgId) {
indexImgService.deleteById(imgId, AuthUserContext.get().getTenantId());
return ServerResponseEntity.success();
}
}
package com.mall4j.cloud.multishop.controller.app;
import com.mall4j.cloud.common.response.ServerResponseEntity;
import com.mall4j.cloud.multishop.service.HotSearchService;
import com.mall4j.cloud.multishop.vo.HotSearchVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 热搜
*
* @author YXF
* @date 2021-01-27 09:10:00
*/
@RestController("appHotSearchController")
@RequestMapping("/ua/app/hot_search")
@Tag(name = "app-热搜")
public class HotSearchController {
@Autowired
private HotSearchService hotSearchService;
@GetMapping("/list")
@Operation(summary = "获取热搜列表" , description = "获取热搜列表")
@Parameter(name = "shopId", description = "店铺id")
public ServerResponseEntity<List<HotSearchVO>> listByShopId(@RequestParam("shopId") Long shopId) {
List<HotSearchVO> hotSearches = hotSearchService.listByShopId(shopId);
return ServerResponseEntity.success(hotSearches);
}
}
package com.mall4j.cloud.multishop.controller.app;
import com.mall4j.cloud.multishop.service.IndexImgService;
import com.mall4j.cloud.multishop.vo.IndexImgVO;
import com.mall4j.cloud.common.response.ServerResponseEntity;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 轮播图
*
* @author YXF
* @date 2020-11-24 16:38:32
*/
@RestController("appIndexImgController")
@RequestMapping("/ua/index_img")
@Tag(name = "app-轮播图")
public class IndexImgController {
@Autowired
private IndexImgService indexImgService;
@GetMapping("/list")
@Operation(summary = "获取轮播图列表" , description = "分页获取轮播图列表")
@Parameter(name = "shopId", description = "店铺id(平台:0)")
public ServerResponseEntity<List<IndexImgVO>> getList(@RequestParam("shopId") Long shopId) {
List<IndexImgVO> indexImgPage = indexImgService.getListByShopId(shopId);
return ServerResponseEntity.success(indexImgPage);
}
}
package com.mall4j.cloud.multishop.controller.app;
import com.mall4j.cloud.api.multishop.vo.ShopDetailVO;
import com.mall4j.cloud.common.response.ServerResponseEntity;
import com.mall4j.cloud.common.security.AuthUserContext;
import com.mall4j.cloud.multishop.dto.ShopDetailDTO;
import com.mall4j.cloud.multishop.service.ShopDetailService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import java.util.Objects;
/**
* @Author lth
* @Date 2021/6/30 9:37
*/
@RequestMapping(value = "/my_shop_detail")
@RestController("appMyShopDetailController")
@Tag(name = "app-我的店铺详情信息")
public class MyShopDetailController {
@Autowired
private ShopDetailService shopDetailService;
@PostMapping("/create")
@Operation(summary = "创建店铺" , description = "创建店铺")
public ServerResponseEntity<Void> create(@Valid @RequestBody ShopDetailDTO shopDetailDTO) {
shopDetailService.createShop(shopDetailDTO);
return ServerResponseEntity.success();
}
@GetMapping
@Operation(summary = "获取我的店铺" , description = "获取我的店铺")
public ServerResponseEntity<ShopDetailVO> get() {
Long shopId = AuthUserContext.get().getTenantId();
if (Objects.isNull(shopId)) {
return ServerResponseEntity.success(null);
}
return ServerResponseEntity.success(shopDetailService.getByShopId(shopId));
}
}
package com.mall4j.cloud.multishop.controller.app;
import com.mall4j.cloud.api.multishop.vo.ShopDetailVO;
import com.mall4j.cloud.common.exception.Mall4cloudException;
import com.mall4j.cloud.common.response.ServerResponseEntity;
import com.mall4j.cloud.multishop.service.ShopDetailService;
import com.mall4j.cloud.multishop.vo.ShopHeadInfoVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Objects;
/**
* @Author lth
* @Date 2021/6/29 18:39
*/
@RequestMapping(value = "/ua/shop_detail")
@RestController("appShopDetailController")
@Tag(name = "app-店铺详情信息")
public class ShopDetailController {
@Autowired
private ShopDetailService shopDetailService;
@GetMapping("/check_shop_name")
@Operation(summary = "验证店铺名称是否重名" , description = "验证店铺名称是否重名")
public ServerResponseEntity<Boolean> checkShopName(@RequestParam("shopName") String shopName) {
Boolean res = shopDetailService.checkShopName(shopName);
return ServerResponseEntity.success(res);
}
@GetMapping("/head_info")
@Operation(summary = "店铺头部信息" , description = "店铺头部信息")
public ServerResponseEntity<ShopHeadInfoVO> getShopHeadInfo(Long shopId) {
ShopHeadInfoVO shopHeadInfoVO = new ShopHeadInfoVO();
ShopDetailVO shopDetailVO = shopDetailService.getByShopId(shopId);
if (Objects.isNull(shopDetailVO)) {
throw new Mall4cloudException("店铺不存在");
}
shopHeadInfoVO.setShopStatus(shopDetailVO.getShopStatus());
if (!Objects.equals(shopDetailVO.getShopStatus(), 1)) {
return ServerResponseEntity.success(shopHeadInfoVO);
}
shopHeadInfoVO.setShopId(shopId);
shopHeadInfoVO.setType(shopDetailVO.getType());
shopHeadInfoVO.setIntro(shopDetailVO.getIntro());
shopHeadInfoVO.setShopLogo(shopDetailVO.getShopLogo());
shopHeadInfoVO.setShopName(shopDetailVO.getShopName());
shopHeadInfoVO.setMobileBackgroundPic(shopDetailVO.getMobileBackgroundPic());
return ServerResponseEntity.success(shopHeadInfoVO);
}
}
package com.mall4j.cloud.multishop.controller.multishop;
import com.mall4j.cloud.api.multishop.vo.ShopDetailVO;
import com.mall4j.cloud.common.response.ServerResponseEntity;
import com.mall4j.cloud.common.security.AuthUserContext;
import com.mall4j.cloud.multishop.service.ShopDetailService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author lth
* @Date 2021/6/24 14:46
*/
@RequestMapping(value = "/m/shop_detail")
@RestController("multishopShopDetailController")
@Tag(name = "multishop-店铺详情信息")
public class ShopDetailController {
@Autowired
private ShopDetailService shopDetailService;
@GetMapping("/info")
@Operation(summary = "获取店铺详情信息" , description = "获取店铺详情信息")
public ServerResponseEntity<ShopDetailVO> info() {
Long shopId = AuthUserContext.get().getTenantId();
ShopDetailVO shopDetailVO = shopDetailService.getByShopId(shopId);
return ServerResponseEntity.success(shopDetailVO);
}
}
package com.mall4j.cloud.multishop.controller.multishop;
import com.mall4j.cloud.api.auth.bo.UserInfoInTokenBO;
import com.mall4j.cloud.api.multishop.vo.ShopDetailVO;
import com.mall4j.cloud.common.database.dto.PageDTO;
import com.mall4j.cloud.common.database.vo.PageVO;
import com.mall4j.cloud.common.response.ResponseEnum;
import com.mall4j.cloud.common.response.ServerResponseEntity;
import com.mall4j.cloud.common.security.AuthUserContext;
import com.mall4j.cloud.multishop.dto.ShopUserDTO;
import com.mall4j.cloud.multishop.model.ShopUser;
import com.mall4j.cloud.multishop.service.ShopDetailService;
import com.mall4j.cloud.multishop.service.ShopUserService;
import com.mall4j.cloud.multishop.vo.ShopUserVO;
import com.mall4j.cloud.multishop.vo.ShopUserSimpleVO;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import com.mall4j.cloud.common.util.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import java.util.Objects;
/**
* @author FrozenWatermelon
* @date 2020/09/02
*/
@RequestMapping(value = "/m/shop_user")
@RestController("multishopShopUserController")
@Tag(name = "店铺用户信息")
public class ShopUserController {
@Autowired
private ShopUserService shopUserService;
@Autowired
private ShopDetailService shopDetailService;
@GetMapping("/info")
@Operation(summary = "登陆店铺用户信息" , description = "获取当前登陆店铺用户的用户信息")
public ServerResponseEntity<ShopUserSimpleVO> info() {
UserInfoInTokenBO userInfoInTokenBO = AuthUserContext.get();
ShopUserSimpleVO shopUserSimple = new ShopUserSimpleVO();
shopUserSimple.setIsAdmin(userInfoInTokenBO.getIsAdmin());
ShopDetailVO shopDetail = shopDetailService.getByShopId(userInfoInTokenBO.getTenantId());
shopUserSimple.setAvatar(shopDetail.getShopLogo());
shopUserSimple.setNickName(shopDetail.getShopName());
return ServerResponseEntity.success(shopUserSimple);
}
@GetMapping("/page")
@Operation(summary = "店铺用户列表" , description = "获取店铺用户列表")
public ServerResponseEntity<PageVO<ShopUserVO>> page(@Valid PageDTO pageDTO, String nickName) {
UserInfoInTokenBO userInfoInTokenBO = AuthUserContext.get();
PageVO<ShopUserVO> shopUserPage = shopUserService.pageByShopId(pageDTO, userInfoInTokenBO.getTenantId(), nickName);
return ServerResponseEntity.success(shopUserPage);
}
@GetMapping
@Operation(summary = "获取店铺用户信息" , description = "根据用户id获取店铺用户信息")
public ServerResponseEntity<ShopUserVO> detail(@RequestParam Long shopUserId) {
return ServerResponseEntity.success(shopUserService.getByUserId(shopUserId));
}
@PostMapping
@Operation(summary = "保存店铺用户信息" , description = "保存店铺用户信息")
public ServerResponseEntity<Void> save(@Valid @RequestBody ShopUserDTO shopUserDTO) {
ShopUser shopUser = BeanUtil.map(shopUserDTO, ShopUser.class);
shopUser.setShopUserId(null);
shopUser.setShopId(AuthUserContext.get().getTenantId());
shopUser.setHasAccount(0);
shopUserService.save(shopUser,shopUserDTO.getRoleIds());
return ServerResponseEntity.success();
}
@PutMapping
@Operation(summary = "更新店铺用户信息" , description = "更新店铺用户信息")
public ServerResponseEntity<Void> update(@Valid @RequestBody ShopUserDTO shopUserDTO) {
ShopUser shopUser = BeanUtil.map(shopUserDTO, ShopUser.class);
ShopUserVO dbShopUser = shopUserService.getByUserId(shopUserDTO.getShopUserId());
if (!Objects.equals(dbShopUser.getShopId(), AuthUserContext.get().getTenantId())) {
return ServerResponseEntity.fail(ResponseEnum.UNAUTHORIZED);
}
shopUser.setShopId(dbShopUser.getShopId());
shopUserService.update(shopUser,shopUserDTO.getRoleIds());
return ServerResponseEntity.success();
}
@DeleteMapping
@Operation(summary = "删除店铺用户信息" , description = "根据店铺用户id删除店铺用户信息")
public ServerResponseEntity<Void> delete(@RequestParam Long shopUserId) {
ShopUserVO dbShopUser = shopUserService.getByUserId(shopUserId);
if (!Objects.equals(dbShopUser.getShopId(), AuthUserContext.get().getTenantId())) {
return ServerResponseEntity.fail(ResponseEnum.UNAUTHORIZED);
}
shopUserService.deleteById(shopUserId);
return ServerResponseEntity.success();
}
}
package com.mall4j.cloud.multishop.controller.platform;
import com.mall4j.cloud.api.multishop.vo.ShopDetailVO;
import com.mall4j.cloud.common.constant.Constant;
import com.mall4j.cloud.common.database.dto.PageDTO;
import com.mall4j.cloud.common.database.vo.PageVO;
import com.mall4j.cloud.common.exception.Mall4cloudException;
import com.mall4j.cloud.common.response.ResponseEnum;
import com.mall4j.cloud.common.response.ServerResponseEntity;
import com.mall4j.cloud.common.security.AuthUserContext;
import com.mall4j.cloud.multishop.dto.ShopDetailDTO;
import com.mall4j.cloud.multishop.model.ShopDetail;
import com.mall4j.cloud.multishop.service.ShopDetailService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import com.mall4j.cloud.common.util.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Objects;
/**
* 店铺详情
*
* @author FrozenWatermelon
* @date 2020-12-05 15:50:25
*/
@RestController("platformShopDetailController")
@RequestMapping("/platform/shop_detail")
@Tag(name = "platform-店铺信息")
public class ShopDetailController {
@Autowired
private ShopDetailService shopDetailService;
@GetMapping("/page")
@Operation(summary = "分页查询" , description = "分页查询")
public ServerResponseEntity<PageVO<ShopDetailVO>> getShopAuditingPage(PageDTO pageDTO, ShopDetailDTO shopDetailDTO) {
if (!Objects.equals(Constant.PLATFORM_SHOP_ID, AuthUserContext.get().getTenantId())) {
throw new Mall4cloudException(ResponseEnum.UNAUTHORIZED);
}
return ServerResponseEntity.success(shopDetailService.page(pageDTO, shopDetailDTO));
}
@GetMapping("/info")
@Operation(summary = "店铺详情" , description = "店铺详情")
public ServerResponseEntity<ShopDetailVO> getInfo(@RequestParam Long shopId) {
ShopDetailVO shopDetailVO = shopDetailService.getByShopId(shopId);
return ServerResponseEntity.success(shopDetailVO);
}
/**
* 新建店铺
*/
@PostMapping("/create_shop")
@Operation(summary = "新建店铺" , description = "新建店铺")
public ServerResponseEntity<Void> createShop(@RequestBody ShopDetailDTO shopDetailDTO) {
shopDetailService.createShop(shopDetailDTO);
return ServerResponseEntity.success();
}
@PutMapping("/update_shop")
@Operation(summary = "更新店铺" , description = "更新店铺")
public ServerResponseEntity<Void> updateShop(@RequestBody ShopDetailDTO shopDetailDTO) {
shopDetailService.update(BeanUtil.map(shopDetailDTO, ShopDetail.class));
return ServerResponseEntity.success();
}
}
package com.mall4j.cloud.multishop.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
/**
* @author FrozenWatermelon
* @date 2020/9/22
*/
public class ChangeAccountDTO {
@NotNull(message = "userId not null")
@Schema(description = "用户id" )
private Long userId;
@NotBlank(message = "username not blank")
@Schema(description = "用户名" )
private String username;
@NotBlank(message = "password not blank")
@Schema(description = "密码" )
private String password;
@NotNull(message = "status not null")
@Schema(description = "状态 1启用 0禁用" )
private Integer status;
@Schema(description = "邮箱" )
private String email;
@Schema(description = "手机号" )
private String phone;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
@Override
public String toString() {
return "ChangeAccountDTO{" +
"userId=" + userId +
", username='" + username + '\'' +
", password='" + password + '\'' +
", status=" + status +
", email='" + email + '\'' +
", phone='" + phone + '\'' +
'}';
}
}
package com.mall4j.cloud.multishop.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Date;
/**
* 热搜DTO
*
* @author YXF
* @date 2021-01-27 09:10:00
*/
public class HotSearchDTO{
private static final long serialVersionUID = 1L;
@Schema(description = "主键" )
private Long hotSearchId;
@Schema(description = "店铺ID 0为全局热搜" )
private Long shopId;
@Schema(description = "内容" )
private String content;
@Schema(description = "顺序" )
private Integer seq;
@Schema(description = "状态 0下线 1上线" )
private Integer status;
@Schema(description = "热搜标题" )
private String title;
public Long getHotSearchId() {
return hotSearchId;
}
public void setHotSearchId(Long hotSearchId) {
this.hotSearchId = hotSearchId;
}
public Long getShopId() {
return shopId;
}
public void setShopId(Long shopId) {
this.shopId = shopId;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Integer getSeq() {
return seq;
}
public void setSeq(Integer seq) {
this.seq = seq;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Override
public String toString() {
return "HotSearchDTO{" +
"hotSearchId=" + hotSearchId +
",shopId=" + shopId +
",content=" + content +
",seq=" + seq +
",status=" + status +
",title=" + title +
'}';
}
}
package com.mall4j.cloud.multishop.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
/**
* 轮播图DTO
*
* @author YXF
* @date 2020-11-24 16:38:32
*/
public class IndexImgDTO{
private static final long serialVersionUID = 1L;
@Schema(description = "主键" )
private Long imgId;
@Schema(description = "店铺ID" )
private Long shopId;
@NotNull(message = "图片不能为空")
@Schema(description = "图片" )
private String imgUrl;
@Schema(description = "状态" )
private Integer status;
@NotNull(message = "序号不能为空")
@Schema(description = "顺序" )
private Integer seq;
@Schema(description = "关联商品id" )
private Long spuId;
@NotNull(message = "图片类型不能为空")
@Schema(description = "图片类型 0:小程序 1:pc" )
private Integer imgType;
public Long getImgId() {
return imgId;
}
public void setImgId(Long imgId) {
this.imgId = imgId;
}
public Long getShopId() {
return shopId;
}
public void setShopId(Long shopId) {
this.shopId = shopId;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getSeq() {
return seq;
}
public void setSeq(Integer seq) {
this.seq = seq;
}
public Long getSpuId() {
return spuId;
}
public void setSpuId(Long spuId) {
this.spuId = spuId;
}
public Integer getImgType() {
return imgType;
}
public void setImgType(Integer imgType) {
this.imgType = imgType;
}
@Override
public String toString() {
return "IndexImgDTO{" +
"imgId=" + imgId +
",shopId=" + shopId +
",imgUrl=" + imgUrl +
",status=" + status +
",seq=" + seq +
",spuId=" + spuId +
",imgType=" + imgType +
'}';
}
}
package com.mall4j.cloud.multishop.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
/**
* 店铺详情DTO
*
* @author FrozenWatermelon
* @date 2020-12-05 15:50:25
*/
public class ShopDetailDTO{
private static final long serialVersionUID = 1L;
@Schema(description = "店铺id" )
private Long shopId;
@Schema(description = "店铺类型1自营店 2普通店" )
private Integer type;
@Schema(description = "店铺名称" )
private String shopName;
@Schema(description = "店铺简介" )
private String intro;
@Schema(description = "店铺logo(可修改)" )
private String shopLogo;
@Schema(description = "店铺状态(-1:已删除 0: 停业中 1:营业中)" )
private Integer shopStatus;
@Schema(description = "营业执照" )
private String businessLicense;
@Schema(description = "身份证正面" )
private String identityCardFront;
@Schema(description = "身份证反面" )
private String identityCardLater;
@Size(max = 30)
@Schema(description = "用户名" ,requiredMode = Schema.RequiredMode.REQUIRED)
private String username;
@Size(max = 30)
@Size(max = 64)
@Schema(description = "密码" ,requiredMode = Schema.RequiredMode.REQUIRED)
private String password;
@Schema(description = "移动端背景图" )
@NotBlank(message="移动端背景图不能为空")
private String mobileBackgroundPic;
public String getMobileBackgroundPic() {
return mobileBackgroundPic;
}
public void setMobileBackgroundPic(String mobileBackgroundPic) {
this.mobileBackgroundPic = mobileBackgroundPic;
}
public Long getShopId() {
return shopId;
}
public void setShopId(Long shopId) {
this.shopId = shopId;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getShopName() {
return shopName;
}
public void setShopName(String shopName) {
this.shopName = shopName;
}
public String getIntro() {
return intro;
}
public void setIntro(String intro) {
this.intro = intro;
}
public String getShopLogo() {
return shopLogo;
}
public void setShopLogo(String shopLogo) {
this.shopLogo = shopLogo;
}
public Integer getShopStatus() {
return shopStatus;
}
public void setShopStatus(Integer shopStatus) {
this.shopStatus = shopStatus;
}
public String getBusinessLicense() {
return businessLicense;
}
public void setBusinessLicense(String businessLicense) {
this.businessLicense = businessLicense;
}
public String getIdentityCardFront() {
return identityCardFront;
}
public void setIdentityCardFront(String identityCardFront) {
this.identityCardFront = identityCardFront;
}
public String getIdentityCardLater() {
return identityCardLater;
}
public void setIdentityCardLater(String identityCardLater) {
this.identityCardLater = identityCardLater;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "ShopDetailDTO{" +
"shopId=" + shopId +
", type=" + type +
", shopName='" + shopName + '\'' +
", intro='" + intro + '\'' +
", shopLogo='" + shopLogo + '\'' +
", shopStatus=" + shopStatus +
", businessLicense='" + businessLicense + '\'' +
", identityCardFront='" + identityCardFront + '\'' +
", identityCardLater='" + identityCardLater + '\'' +
", username='" + username + '\'' +
", password='" + password + '\'' +
", mobileBackgroundPic='" + mobileBackgroundPic + '\'' +
'}';
}
}
package com.mall4j.cloud.multishop.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import java.util.List;
/**
* @author FrozenWatermelon
* @date 2020/9/8
*/
public class ShopUserDTO {
@Schema(description = "店铺用户id" )
private Long shopUserId;
@NotBlank(message = "昵称不能为空")
@Schema(description = "昵称" )
private String nickName;
@Schema(description = "员工编号" )
private String code;
@Schema(description = "联系方式" )
private String phoneNum;
@Schema(description = "角色id列表" )
private List<Long> roleIds;
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getPhoneNum() {
return phoneNum;
}
public void setPhoneNum(String phoneNum) {
this.phoneNum = phoneNum;
}
public Long getShopUserId() {
return shopUserId;
}
public void setShopUserId(Long shopUserId) {
this.shopUserId = shopUserId;
}
public List<Long> getRoleIds() {
return roleIds;
}
public void setRoleIds(List<Long> roleIds) {
this.roleIds = roleIds;
}
@Override
public String toString() {
return "ShopUserDTO{" +
"shopUserId=" + shopUserId +
", nickName='" + nickName + '\'' +
", code='" + code + '\'' +
", phoneNum='" + phoneNum + '\'' +
", roleIds=" + roleIds +
'}';
}
}
package com.mall4j.cloud.multishop.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
/**
* @author lhd
* @date 2020/12/30
*/
@Schema(description = "用户名和密码参数")
public class UsernameAndPasswordDTO {
@NotBlank(message="用户名不能为空")
@Size(max = 30)
@Schema(description = "用户名" ,requiredMode = Schema.RequiredMode.REQUIRED)
private String username;
@NotBlank(message="密码不能为空")
@Size(max = 64)
@Schema(description = "密码" ,requiredMode = Schema.RequiredMode.REQUIRED)
private String password;
@Schema(description = "店铺id" )
private Long shopId;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Long getShopId() {
return shopId;
}
public void setShopId(Long shopId) {
this.shopId = shopId;
}
@Override
public String toString() {
return "UsernameAndPasswordDTO{" +
"username='" + username + '\'' +
", password='" + password + '\'' +
", shopId='" + shopId +
'}';
}
}
package com.mall4j.cloud.multishop.feign;
import com.mall4j.cloud.api.multishop.feign.IndexImgFeignClient;
import com.mall4j.cloud.common.response.ServerResponseEntity;
import com.mall4j.cloud.multishop.service.IndexImgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author lth
* @Date 2021/7/8 11:12
*/
@RestController
public class IndexImgFeignController implements IndexImgFeignClient {
@Autowired
private IndexImgService indexImgService;
@Override
public ServerResponseEntity<Void> deleteBySpuId(Long spuId, Long shopId) {
indexImgService.deleteBySpuId(spuId, shopId);
return ServerResponseEntity.success();
}
}
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