| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.account.api.model.AppUser; |
| | | import com.ruoyi.account.api.model.AppUserShop; |
| | | import com.ruoyi.account.service.AppUserService; |
| | | import com.ruoyi.account.service.AppUserShopService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | |
| | | @RestController |
| | | @RequestMapping("/appUserShop") |
| | | public class AppUserShopController { |
| | | |
| | | @Resource |
| | | private AppUserShopService appUserShopService; |
| | | @Resource |
| | | private AppUserService appUserService; |
| | | |
| | | |
| | | |
| | | |
| | | @PostMapping("/addAppUserShop") |
| | | public R<Void> add(@RequestBody AppUserShop appUserShop) { |
| | | long count = appUserShopService.count(new LambdaQueryWrapper<AppUserShop>() |
| | | .eq(AppUserShop::getAppUserId, appUserShop.getAppUserId()).eq(AppUserShop::getShopId, appUserShop.getShopId())); |
| | | if(0 == count){ |
| | | appUserShopService.save(appUserShop); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/shop/{userId}") |
| | | public R<List<AppUserShop>> getAppUserShop(@PathVariable("userId") Long userId) { |
| | | return R.ok(appUserShopService.list(new LambdaQueryWrapper<AppUserShop>() |
| | | .eq(AppUserShop::getAppUserId,userId))); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除门店用户关系数据 |
| | | * @param appUserShop |
| | | * @return |
| | | */ |
| | | @PostMapping("/delAppUserShop") |
| | | public R delAppUserShop(@RequestBody AppUserShop appUserShop){ |
| | | LambdaUpdateWrapper<AppUserShop> wrapper = new LambdaUpdateWrapper<>(); |
| | | if(null != appUserShop.getAppUserId()){ |
| | | wrapper.eq(AppUserShop::getAppUserId, appUserShop.getAppUserId()); |
| | | } |
| | | if(null != appUserShop.getShopId()){ |
| | | wrapper.eq(AppUserShop::getShopId, appUserShop.getShopId()); |
| | | } |
| | | if(null != appUserShop.getRoleType()){ |
| | | wrapper.eq(AppUserShop::getRoleType, appUserShop.getRoleType()); |
| | | } |
| | | appUserShopService.remove(wrapper); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存关系数据 |
| | | * @param appUserShop |
| | | */ |
| | | @PostMapping("/saveAppUserShop") |
| | | public void saveAppUserShop(@RequestBody AppUserShop appUserShop){ |
| | | appUserShopService.save(appUserShop); |
| | | } |
| | | } |