puzhibing
2023-12-07 aa0131b1efb96c9f52371160b3a1e6823db3656a
ruoyi-modules/ruoyi-shop/src/main/java/com/ruoyi/shop/controller/staff/StaffShopController.java
@@ -3,20 +3,16 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.shop.domain.dto.StaffShopCCEditDto;
import com.ruoyi.shop.domain.dto.StaffShopECEditDto;
import com.ruoyi.shop.domain.dto.StaffShopEstimateEditDto;
import com.ruoyi.shop.domain.dto.StaffShopPageDto;
import com.ruoyi.shop.domain.vo.StaffHomeShopTotalVo;
import com.ruoyi.shop.domain.vo.StaffShopInfoGetVo;
import com.ruoyi.shop.domain.vo.StaffShopPageVo;
import com.ruoyi.shop.domain.vo.StaffShopSimpleTotalVo;
import com.ruoyi.shop.domain.dto.*;
import com.ruoyi.shop.domain.vo.*;
import com.ruoyi.shop.service.shop.ShopService;
import com.ruoyi.system.api.domain.dto.StaffBaseGetDto;
import com.ruoyi.system.api.domain.poji.sys.SysUser;
import com.ruoyi.system.api.service.RemoteSysStaffService;
import com.ruoyi.system.api.service.RemoteUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -29,6 +25,7 @@
@Api(value = "员工端商户接口", tags = "员工端商户接口", description = "员工端商户接口")
@RestController
@RequestMapping("/staff/shop")
@Log4j2
public class StaffShopController {
    @Resource
@@ -54,13 +51,34 @@
    @ApiOperation(value = "分页获取员工端商户列表")
    public R<Page<StaffShopPageVo>> listStaffShop(@RequestBody StaffShopPageDto staffShopPageDto) {
        Long userId = SecurityUtils.getUserId();
        if (remoteSysStaffService.isLeader()) {
//        if (remoteSysStaffService.isLeader()) {
//            List<Long> userIds = sysUserService.getUserIdsByDept(userId).getData();
//            userIds.add(userId);
//            staffShopPageDto.setUserIdList(userIds);
//        } else {
//            staffShopPageDto.setBelongUserId(userId);
//        }
        // TODO: 2023/12/5 统一改成使用权限来控制数据
        R<SysUser> sysUser = sysUserService.getSysUser(userId);
        if(sysUser.getCode() != 200){
            return R.fail(sysUser.getMsg());
        }
        //员工端数据权限(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)
        //2/4暂未使用
        String dataScopeEmployee = sysUser.getData().getDataScopeEmployee();
        if(dataScopeEmployee.equals("1")){
            staffShopPageDto.setUserIdList(null);
        }
        if(dataScopeEmployee.equals("3")){
            List<Long> userIds = sysUserService.getUserIdsByDept(userId).getData();
            userIds.add(userId);
            staffShopPageDto.setUserIdList(userIds);
        } else {
        }
        if(dataScopeEmployee.equals("5")){
            staffShopPageDto.setBelongUserId(userId);
        }
        Page<StaffShopPageVo> page = new Page<>();
        page.setSize(staffShopPageDto.getPageSize());
        page.setCurrent(staffShopPageDto.getPageNum());
@@ -112,5 +130,21 @@
        return R.ok();
    }
    @RequestMapping(value = "/editShopDetail", method = RequestMethod.POST)
    @ApiOperation(value = "修改店铺详细资料")
    public R editShopDetail(@RequestBody StaffShopDetailDto staffShopDetailDto) {
        Long userId = SecurityUtils.getUserId();
        staffShopDetailDto.setUserId(userId);
        shopService.editShopDetail(staffShopDetailDto);
        return R.ok();
    }
    @RequestMapping(value = "/getShopDetail", method = RequestMethod.POST)
    @ApiOperation(value = "获取店铺详细资料")
    public R<StaffShopDetailVo> getShopDetail(@RequestBody StaffBaseGetDto staffBaseGetDto) {
        Long userId = SecurityUtils.getUserId();
        staffBaseGetDto.setUserId(userId);
        StaffShopDetailVo staffShopDetailVo = shopService.getShopDetail(Long.valueOf(staffBaseGetDto.getId()));
        return R.ok(staffShopDetailVo);
    }
}