|
@@ -1,10 +1,24 @@
|
|
|
package com.szwl.controller;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.szwl.constant.ResponseCodesEnum;
|
|
|
+import com.szwl.model.bo.R;
|
|
|
+import com.szwl.model.bo.ResponseModel;
|
|
|
+import com.szwl.model.entity.TAdmin;
|
|
|
+import com.szwl.model.entity.TProportion;
|
|
|
+import com.szwl.service.TAdminService;
|
|
|
+import com.szwl.service.TProportionService;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* 前端控制器
|
|
@@ -17,5 +31,38 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
@RequestMapping("/tProportion")
|
|
|
public class TProportionController {
|
|
|
|
|
|
+ public TProportionController(TAdminService adminService, TProportionService proportionService) {
|
|
|
+ this.adminService = adminService;
|
|
|
+ this.proportionService = proportionService;
|
|
|
+ }
|
|
|
+
|
|
|
+ TAdminService adminService;
|
|
|
+
|
|
|
+ TProportionService proportionService;
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "通过用户username获取分销信息")
|
|
|
+ @GetMapping("/getProportionByUsername")
|
|
|
+ public ResponseModel<?> getProportionByUsername(String username) {
|
|
|
+ if (StringUtils.isEmpty(username)) {
|
|
|
+ return R.fail(ResponseCodesEnum.A0001);
|
|
|
+ }
|
|
|
+
|
|
|
+ LambdaQueryWrapper<TAdmin> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(TAdmin::getUsername, username);
|
|
|
+ TAdmin admin = adminService.getOne(wrapper);
|
|
|
+ if (Objects.isNull(admin)) {
|
|
|
+ return R.fail(ResponseCodesEnum.A0206);
|
|
|
+ }
|
|
|
+ Long adminId = admin.getId();
|
|
|
+ Long parentId = admin.getParentId();
|
|
|
+
|
|
|
+ LambdaQueryWrapper<TProportion> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(TProportion::getAdminId, adminId);
|
|
|
+ TProportion proportion = proportionService.getOne(lqw);
|
|
|
+
|
|
|
+ return R.ok(proportion);
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|