门店修改

This commit is contained in:
qjq
2024-04-23 14:03:41 +08:00
parent 99fc189db4
commit b05e2a2717
7 changed files with 176 additions and 11 deletions

View File

@ -6,10 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenRespVO;
import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenWeekSalesRespVo;
import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.*;
import cn.iocoder.yudao.module.system.dal.dataobject.carteen.CarteenDO;
import cn.iocoder.yudao.module.system.service.carteen.CarteenService;
import io.swagger.v3.oas.annotations.Operation;
@ -95,8 +92,22 @@ public class CarteenController {
@GetMapping("/week/sales")
@Operation(summary = "获得门店销量")
@PreAuthorize("@ss.hasPermission('t:carteen:query')")
// @PermitAll
public CommonResult<Map<String, List<CarteenWeekSalesRespVo>>> getCarteenSales(CarteenPageReqVO pageReqVO) {
return success(carteenService.getCarteenWeekSales(pageReqVO));
}
@GetMapping("/user/carteem")
@Operation(summary = "获取当前用户有那些门店")
@PreAuthorize("@ss.hasPermission('t:carteen:query')")
public CommonResult<List<CarteenRespVO>> getUserCarteem(@RequestParam("userId")Long userId) {
return success(BeanUtils.toBean(carteenService.getUserCarteem(userId), CarteenRespVO.class));
}
@PutMapping("/user/update/carteen")
@Operation(summary = "更新门店关联用户")
@PreAuthorize("@ss.hasPermission('t:carteen:update')")
public CommonResult<Boolean> updateUserCarteen(@Valid @RequestBody CarteenSerialSaveReqVO req) {
return success(carteenService.updateUserCarteen(req));
}
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.system.controller.admin.carteen.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @Author:qjq
* @Date:2024/4/23 上午10:41
*/
@Schema(description = "管理后台 - 门店管理/用户关联门店 Request VO")
@Data
public class CarteenSerialSaveReqVO {
@Schema(description = "角色id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3,4,5,6")
@NotBlank(message = "角色id不能 为空")
private String serialNumber;
@Schema(description = "门店id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "门店id不能 为空")
private Long id;
}

View File

@ -0,0 +1,36 @@
package cn.iocoder.yudao.module.system.controller.app.carteen;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.controller.app.carteen.vo.CarteenRespVO;
import cn.iocoder.yudao.module.system.service.carteen.CarteenService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/**
* @Author:qjq
* @Date:2024/4/23 下午1:44
*/
@Tag(name = "门店")
@RestController
@RequestMapping("/app/t/carteen")
@Validated
public class AppCarteenController {
@Resource
private CarteenService carteenService;
@GetMapping("/list")
@Operation(summary = "门店列表")
public CommonResult<List<CarteenRespVO>> listCarteen() {
return success(BeanUtils.toBean(carteenService.getCarteenList(), CarteenRespVO.class));
}
}

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.system.controller.app.carteen.vo;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @Author:qjq
* @Date:2024/4/23 下午1:41
*/
@Data
public class CarteenRespVO {
private Long id;
private String storesName;
private Boolean status;
private Boolean multipleManage;
private Boolean accountOrder;
private String storeAddress;
private String phone;
private LocalDateTime createTime;
}

View File

@ -21,7 +21,7 @@ import java.util.LinkedList;
@Mapper
public interface CarteenMapper extends BaseMapperX<CarteenDO> {
default PageResult<CarteenDO> selectPage(CarteenPageReqVO reqVO) {
default PageResult<CarteenDO> selectPage(CarteenPageReqVO reqVO,Long userId) {
return selectPage(reqVO, new LambdaQueryWrapperX<CarteenDO>()
.likeIfPresent(CarteenDO::getStoresName, reqVO.getStoresName())
.likeIfPresent(CarteenDO::getStoreAddress, reqVO.getStoreAddress())
@ -30,7 +30,8 @@ public interface CarteenMapper extends BaseMapperX<CarteenDO> {
.eqIfPresent(CarteenDO::getAccountOrder, reqVO.getAccountOrder())
.eqIfPresent(CarteenDO::getPhone, reqVO.getPhone())
.betweenIfPresent(CarteenDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(CarteenDO::getId));
.last(" and FIND_IN_SET("+userId+",serial_number) order by id desc")
);
}
@Select("<script>"+"SELECT\n" +
"\tA.weigh as sales,\n" +

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.service.carteen;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenSerialSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenWeekSalesRespVo;
import cn.iocoder.yudao.module.system.dal.dataobject.carteen.CarteenDO;
@ -62,4 +63,25 @@ public interface CarteenService {
* @return
*/
Map<String, List<CarteenWeekSalesRespVo>> getCarteenWeekSales(CarteenPageReqVO pageReqVO);
/**
* @Description: 根据用户编号获取门店
* @Author: qjq
* @Date: 2024/4/23 上午9:58
* @return
*/
List<CarteenDO> getUserCarteem(Long userId);
/**
* @Description: 修改门店那些用户可以看
* @Author: qjq
* @Date: 2024/4/23 上午10:37
* @return
*/
Boolean updateUserCarteen(CarteenSerialSaveReqVO req);
/**
* @Description: 获取所有门店
* @Author: qjq
* @Date: 2024/4/23 下午1:47
* @return
*/
List<CarteenDO> getCarteenList();
}

View File

@ -7,14 +7,17 @@ import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenSerialSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenWeekSalesRespVo;
import cn.iocoder.yudao.module.system.dal.dataobject.carteen.CarteenDO;
import cn.iocoder.yudao.module.system.dal.mysql.carteen.CarteenMapper;
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -53,8 +56,7 @@ public class CarteenServiceImpl implements CarteenService {
carteen.setMultipleManage(Boolean.FALSE);
carteen.setAccountOrder(Boolean.FALSE);
carteen.setDeleted(Boolean.FALSE);
Set<Long> set = permissionService.getUserRoleIdListByUserId(SecurityFrameworkUtils.getLoginUserId());
carteen.setSerialNumber(Arrays.toString(set.toArray()));
carteen.setSerialNumber(String.valueOf(SecurityFrameworkUtils.getLoginUserId()));
carteenMapper.insert(carteen);
// 返回
return carteen.getId();
@ -89,9 +91,9 @@ public class CarteenServiceImpl implements CarteenService {
@Override
public PageResult<CarteenDO> getCarteenPage(CarteenPageReqVO pageReqVO) {
return carteenMapper.selectPage(pageReqVO);
Long loginUserId = SecurityFrameworkUtils.getLoginUserId();
return carteenMapper.selectPage(pageReqVO,loginUserId);
}
/**
* @param req
* @return
@ -170,4 +172,46 @@ public class CarteenServiceImpl implements CarteenService {
return carteenMapper.getCarteenSales(req.getCarteenId(),startDate,endDate);
}
}
/**
* @param userId
* @return
* @Description: 根据用户编号获取门店
* @Author: qjq
* @Date: 2024/4/23 上午9:58
*/
@Override
public List<CarteenDO> getUserCarteem(Long userId) {
//获取门店
return carteenMapper.selectList(new LambdaQueryWrapperX<CarteenDO>()
.last("and FIND_IN_SET(" + userId + ",serial_number) order by id desc")
);
}
/**
* @param req
* @return
* @Description: 修改门店那些用户可以看
* @Author: qjq
* @Date: 2024/4/23 上午10:37
*/
@Override
public Boolean updateUserCarteen(CarteenSerialSaveReqVO req) {
int update = carteenMapper.update(new LambdaUpdateWrapper<CarteenDO>()
.set(CarteenDO::getSerialNumber, req.getSerialNumber())
.eq(CarteenDO::getId, req.getId())
);
return update>0?Boolean.TRUE:Boolean.FALSE;
}
/**
* @return
* @Description: 获取所有门店
* @Author: qjq
* @Date: 2024/4/23 下午1:47
*/
@Override
public List<CarteenDO> getCarteenList() {
return carteenMapper.selectList(new LambdaQueryWrapperX<CarteenDO>()
.eq(CarteenDO::getDeleted,Boolean.FALSE));
}
}