diff --git a/src/main/java/cn/com/tenlion/usercenter/controller/api/business/BusinessController.java b/src/main/java/cn/com/tenlion/usercenter/controller/api/business/BusinessController.java index be4d919..4f20b6b 100644 --- a/src/main/java/cn/com/tenlion/usercenter/controller/api/business/BusinessController.java +++ b/src/main/java/cn/com/tenlion/usercenter/controller/api/business/BusinessController.java @@ -2,6 +2,7 @@ package cn.com.tenlion.usercenter.controller.api.business; import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.common.base.DefaultBaseController; +import ink.wgink.exceptions.ParamsException; import ink.wgink.interfaces.consts.ISystemConstant; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.result.ErrorResult; @@ -11,7 +12,9 @@ import ink.wgink.pojo.result.SuccessResultList; import cn.com.tenlion.usercenter.pojo.dtos.business.BusinessDTO; import cn.com.tenlion.usercenter.pojo.vos.business.BusinessVO; import cn.com.tenlion.usercenter.service.business.IBusinessService; +import ink.wgink.util.RegexUtil; import io.swagger.annotations.*; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -39,13 +42,19 @@ public class BusinessController extends DefaultBaseController { @PostMapping("save") @CheckRequestBodyAnnotation public SuccessResult save(@RequestBody BusinessVO businessVO) { + if (StringUtils.isBlank(businessVO.getBusinessCode())) { + throw new ParamsException("业务编码不能为空"); + } + if (!RegexUtil.isLetterOrNumber(businessVO.getBusinessCode())) { + throw new ParamsException("业务编码只能是字母和数字"); + } businessService.save(businessVO); return new SuccessResult(); } @ApiOperation(value = "删除业务", notes = "删除业务接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3") + @ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @DeleteMapping("remove/{ids}") @@ -56,7 +65,7 @@ public class BusinessController extends DefaultBaseController { @ApiOperation(value = "修改业务", notes = "修改业务接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "businessId", value = "业务ID", paramType = "path") + @ApiImplicitParam(name = "businessId", value = "业务ID", paramType = "path") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @PutMapping("update/{businessId}") @@ -68,11 +77,11 @@ public class BusinessController extends DefaultBaseController { @ApiOperation(value = "业务详情", notes = "业务详情接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "businessId", value = "业务ID", paramType = "path") + @ApiImplicitParam(name = "businessId", value = "业务ID", paramType = "path") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("get/{businessId}") - public BusinessDTO get(@PathVariable("businessId") String businessId) { + public BusinessDTO get(@PathVariable("businessId") String businessId) { return businessService.get(businessId); } @@ -86,11 +95,11 @@ public class BusinessController extends DefaultBaseController { @ApiOperation(value = "业务分页列表", notes = "业务分页列表接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"), - @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"), - @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String") + @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"), + @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"), + @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("listpage") diff --git a/src/main/java/cn/com/tenlion/usercenter/controller/api/businessuser/BusinessUserController.java b/src/main/java/cn/com/tenlion/usercenter/controller/api/businessuser/BusinessUserController.java index 3fb6d4e..4426be1 100644 --- a/src/main/java/cn/com/tenlion/usercenter/controller/api/businessuser/BusinessUserController.java +++ b/src/main/java/cn/com/tenlion/usercenter/controller/api/businessuser/BusinessUserController.java @@ -1,16 +1,19 @@ package cn.com.tenlion.usercenter.controller.api.businessuser; +import cn.com.tenlion.usercenter.pojo.dtos.business.BusinessDTO; +import cn.com.tenlion.usercenter.pojo.dtos.businessuser.BusinessUserDTO; +import cn.com.tenlion.usercenter.service.businessuser.IBusinessUserService; import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.common.base.DefaultBaseController; +import ink.wgink.exceptions.SearchException; import ink.wgink.interfaces.consts.ISystemConstant; import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.dtos.user.UserDTO; import ink.wgink.pojo.result.ErrorResult; import ink.wgink.pojo.result.SuccessResult; import ink.wgink.pojo.result.SuccessResultData; import ink.wgink.pojo.result.SuccessResultList; -import cn.com.tenlion.usercenter.pojo.dtos.businessuser.BusinessUserDTO; -import cn.com.tenlion.usercenter.pojo.vos.businessuser.BusinessUserVO; -import cn.com.tenlion.usercenter.service.businessuser.IBusinessUserService; +import ink.wgink.pojo.vos.IdsVO; import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -34,70 +37,87 @@ public class BusinessUserController extends DefaultBaseController { @Autowired private IBusinessUserService businessUserService; - @ApiOperation(value = "新增业务用户", notes = "新增业务用户接口") - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PostMapping("save") - @CheckRequestBodyAnnotation - public SuccessResult save(@RequestBody BusinessUserVO businessUserVO) { - businessUserService.save(businessUserVO); - return new SuccessResult(); - } - @ApiOperation(value = "删除业务用户", notes = "删除业务用户接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3") + @ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @DeleteMapping("remove/{ids}") - public SuccessResult remove(@PathVariable("ids") String ids) { - businessUserService.remove(Arrays.asList(ids.split("\\_"))); + @DeleteMapping("delete/{ids}") + public SuccessResult delete(@PathVariable("ids") String ids) { + businessUserService.delete(Arrays.asList(ids.split("\\_"))); return new SuccessResult(); } @ApiOperation(value = "修改业务用户", notes = "修改业务用户接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "businessUserId", value = "业务用户ID", paramType = "path") + @ApiImplicitParam(name = "businessUserId", value = "业务用户ID", paramType = "path") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PutMapping("update/{businessUserId}") + @PutMapping("update/{businessId}") @CheckRequestBodyAnnotation - public SuccessResult update(@PathVariable("businessUserId") String businessUserId, @RequestBody BusinessUserVO businessUserVO) { - businessUserService.update(businessUserId, businessUserVO); + public SuccessResult update(@PathVariable("businessId") String businessId, @RequestBody IdsVO idsVO) { + if (idsVO.getIds().isEmpty()) { + throw new SearchException("列表不能为空"); + } + businessUserService.update(businessId, idsVO); return new SuccessResult(); } @ApiOperation(value = "业务用户详情", notes = "业务用户详情接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "businessUserId", value = "业务用户ID", paramType = "path") + @ApiImplicitParam(name = "businessUserId", value = "业务用户ID", paramType = "path") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) @GetMapping("get/{businessUserId}") - public BusinessUserDTO get(@PathVariable("businessUserId") String businessUserId) { + public BusinessUserDTO get(@PathVariable("businessUserId") String businessUserId) { return businessUserService.get(businessUserId); } - @ApiOperation(value = "业务用户列表", notes = "业务用户列表接口") + @ApiOperation(value = "业务用户ID列表", notes = "业务用户ID列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "businessId", value = "业务用户ID", paramType = "path") + }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("list") - public List list() { + @GetMapping("list-user-id/{businessId}") + public List list(@PathVariable("businessId") String businessId) { Map params = requestParams(); - return businessUserService.list(params); + return businessUserService.listUserId(businessId, params); + } + + @ApiOperation(value = "业务用户列表", notes = "业务用户列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "businessId", value = "业务用户ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("list-user/{businessId}") + public List listUser(@PathVariable("businessId") String businessId) { + return businessUserService.listUser(businessId); + } + + @ApiOperation(value = "业务列表", notes = "业务列表接口") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path") + }) + @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) + @GetMapping("list-business/{userId}") + public List listBusiness(@PathVariable("userId") String userId) { + return businessUserService.listBusiness(userId); } @ApiOperation(value = "业务用户分页列表", notes = "业务用户分页列表接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"), - @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"), - @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String") + @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"), + @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"), + @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("listpage") - public SuccessResultList> listPage(ListPage page) { + @GetMapping("listpage/{businessId}") + public SuccessResultList> listPage(@PathVariable("businessId") String businessId, ListPage page) { Map params = requestParams(); page.setParams(params); - return businessUserService.listPage(page); + return businessUserService.listPage(businessId, page); } @ApiOperation(value = "业务用户统计", notes = "业务用户统计接口") diff --git a/src/main/java/cn/com/tenlion/usercenter/controller/app/api/businessuser/BusinessUserAppController.java b/src/main/java/cn/com/tenlion/usercenter/controller/app/api/businessuser/BusinessUserAppController.java index 3ba01c9..089de1b 100644 --- a/src/main/java/cn/com/tenlion/usercenter/controller/app/api/businessuser/BusinessUserAppController.java +++ b/src/main/java/cn/com/tenlion/usercenter/controller/app/api/businessuser/BusinessUserAppController.java @@ -1,21 +1,17 @@ package cn.com.tenlion.usercenter.controller.app.api.businessuser; -import ink.wgink.annotation.CheckRequestBodyAnnotation; +import cn.com.tenlion.usercenter.pojo.dtos.businessuser.BusinessUserDTO; +import cn.com.tenlion.usercenter.service.businessuser.IBusinessUserService; import ink.wgink.common.base.DefaultBaseController; import ink.wgink.interfaces.consts.ISystemConstant; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.result.ErrorResult; -import ink.wgink.pojo.result.SuccessResult; import ink.wgink.pojo.result.SuccessResultData; import ink.wgink.pojo.result.SuccessResultList; -import cn.com.tenlion.usercenter.pojo.dtos.businessuser.BusinessUserDTO; -import cn.com.tenlion.usercenter.pojo.vos.businessuser.BusinessUserVO; -import cn.com.tenlion.usercenter.service.businessuser.IBusinessUserService; import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -34,43 +30,6 @@ public class BusinessUserAppController extends DefaultBaseController { @Autowired private IBusinessUserService businessUserService; - @ApiOperation(value = "新增业务用户", notes = "新增业务用户接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "token", value = "token", paramType = "header") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PostMapping("save") - @CheckRequestBodyAnnotation - public SuccessResult save(@RequestHeader("token") String token, @RequestBody BusinessUserVO businessUserVO) { - businessUserService.save(token, businessUserVO); - return new SuccessResult(); - } - - @ApiOperation(value = "删除业务用户(id列表)", notes = "删除业务用户(id列表)接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "token", value = "token", paramType = "header"), - @ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @DeleteMapping("remove/{ids}") - public SuccessResult remove(@RequestHeader("token") String token, @PathVariable("ids") String ids) { - businessUserService.remove(token, Arrays.asList(ids.split("\\_"))); - return new SuccessResult(); - } - - @ApiOperation(value = "修改业务用户", notes = "修改业务用户接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "token", value = "token", paramType = "header"), - @ApiImplicitParam(name = "businessUserId", value = "业务用户ID", paramType = "path") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PutMapping("updatebusinessuser/{businessUserId}") - @CheckRequestBodyAnnotation - public SuccessResult updateBusinessUser(@RequestHeader("token") String token, @PathVariable("businessUserId") String businessUserId, @RequestBody BusinessUserVO businessUserVO) { - businessUserService.update(token, businessUserId, businessUserVO); - return new SuccessResult(); - } - @ApiOperation(value = "业务用户详情(通过ID)", notes = "业务用户详情(通过ID)接口") @ApiImplicitParams({ @ApiImplicitParam(name = "token", value = "token", paramType = "header"), diff --git a/src/main/java/cn/com/tenlion/usercenter/controller/resource/business/BusinessResourceController.java b/src/main/java/cn/com/tenlion/usercenter/controller/resource/business/BusinessResourceController.java index 9cbf5b1..79a3355 100644 --- a/src/main/java/cn/com/tenlion/usercenter/controller/resource/business/BusinessResourceController.java +++ b/src/main/java/cn/com/tenlion/usercenter/controller/resource/business/BusinessResourceController.java @@ -34,43 +34,6 @@ public class BusinessResourceController extends DefaultBaseController { @Autowired private IBusinessService businessService; - @ApiOperation(value = "新增业务", notes = "新增业务接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PostMapping("save") - @CheckRequestBodyAnnotation - public SuccessResult save(@RequestBody BusinessVO businessVO) { - businessService.save(businessVO); - return new SuccessResult(); - } - - @ApiOperation(value = "删除业务(id列表)", notes = "删除业务(id列表)接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), - @ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @DeleteMapping("remove/{ids}") - public SuccessResult remove(@PathVariable("ids") String ids) { - businessService.remove(Arrays.asList(ids.split("\\_"))); - return new SuccessResult(); - } - - @ApiOperation(value = "修改业务", notes = "修改业务接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), - @ApiImplicitParam(name = "businessId", value = "业务ID", paramType = "path") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PutMapping("update/{businessId}") - @CheckRequestBodyAnnotation - public SuccessResult update(@PathVariable("businessId") String businessId, @RequestBody BusinessVO businessVO) { - businessService.update(businessId, businessVO); - return new SuccessResult(); - } - @ApiOperation(value = "业务详情", notes = "业务详情接口") @ApiImplicitParams({ @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), diff --git a/src/main/java/cn/com/tenlion/usercenter/controller/resource/businessuser/BusinessUserResourceController.java b/src/main/java/cn/com/tenlion/usercenter/controller/resource/businessuser/BusinessUserResourceController.java index 1b5a303..ef9de65 100644 --- a/src/main/java/cn/com/tenlion/usercenter/controller/resource/businessuser/BusinessUserResourceController.java +++ b/src/main/java/cn/com/tenlion/usercenter/controller/resource/businessuser/BusinessUserResourceController.java @@ -1,21 +1,22 @@ package cn.com.tenlion.usercenter.controller.resource.businessuser; -import ink.wgink.annotation.CheckRequestBodyAnnotation; +import cn.com.tenlion.usercenter.pojo.dtos.business.BusinessDTO; +import cn.com.tenlion.usercenter.pojo.dtos.businessuser.BusinessUserDTO; +import cn.com.tenlion.usercenter.service.businessuser.IBusinessUserService; import ink.wgink.common.base.DefaultBaseController; import ink.wgink.interfaces.consts.ISystemConstant; import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.dtos.user.UserDTO; import ink.wgink.pojo.result.ErrorResult; -import ink.wgink.pojo.result.SuccessResult; import ink.wgink.pojo.result.SuccessResultData; import ink.wgink.pojo.result.SuccessResultList; -import cn.com.tenlion.usercenter.pojo.dtos.businessuser.BusinessUserDTO; -import cn.com.tenlion.usercenter.pojo.vos.businessuser.BusinessUserVO; -import cn.com.tenlion.usercenter.service.businessuser.IBusinessUserService; import io.swagger.annotations.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; -import java.util.Arrays; import java.util.List; import java.util.Map; @@ -34,88 +35,26 @@ public class BusinessUserResourceController extends DefaultBaseController { @Autowired private IBusinessUserService businessUserService; - @ApiOperation(value = "新增业务用户", notes = "新增业务用户接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PostMapping("save") - @CheckRequestBodyAnnotation - public SuccessResult save(@RequestBody BusinessUserVO businessUserVO) { - businessUserService.save(businessUserVO); - return new SuccessResult(); - } - - @ApiOperation(value = "删除业务用户(id列表)", notes = "删除业务用户(id列表)接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), - @ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @DeleteMapping("remove/{ids}") - public SuccessResult remove(@PathVariable("ids") String ids) { - businessUserService.remove(Arrays.asList(ids.split("\\_"))); - return new SuccessResult(); - } - - @ApiOperation(value = "修改业务用户", notes = "修改业务用户接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), - @ApiImplicitParam(name = "businessUserId", value = "业务用户ID", paramType = "path") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @PutMapping("update/{businessUserId}") - @CheckRequestBodyAnnotation - public SuccessResult update(@PathVariable("businessUserId") String businessUserId, @RequestBody BusinessUserVO businessUserVO) { - businessUserService.update(businessUserId, businessUserVO); - return new SuccessResult(); - } - - @ApiOperation(value = "业务用户详情", notes = "业务用户详情接口") - @ApiImplicitParams({ - @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), - @ApiImplicitParam(name = "businessUserId", value = "业务用户ID", paramType = "path") - }) - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("get/{businessUserId}") - public BusinessUserDTO get(@PathVariable("businessUserId") String businessUserId) { - return businessUserService.get(businessUserId); - } - @ApiOperation(value = "业务用户列表", notes = "业务用户列表接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query") + @ApiImplicitParam(name = "businessId", value = "业务用户ID", paramType = "path"), + @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("list") - public List list() { - Map params = requestParams(); - return businessUserService.list(params); + @GetMapping("list-user/{businessId}") + public List listUser(@PathVariable("businessId") String businessId) { + return businessUserService.listUser(businessId); } - @ApiOperation(value = "业务用户分页列表", notes = "业务用户分页列表接口") + @ApiOperation(value = "业务列表", notes = "业务列表接口") @ApiImplicitParams({ - @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query"), - @ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"), - @ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"), - @ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String") + @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "path"), + @ApiImplicitParam(name = "access_token", value = "access_token", paramType = "query") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("listpage") - public SuccessResultList> listPage(ListPage page) { - Map params = requestParams(); - page.setParams(params); - return businessUserService.listPage(page); - } - - @ApiOperation(value = "业务用户统计", notes = "业务用户统计接口") - @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("count") - SuccessResultData count() { - Map params = requestParams(); - return new SuccessResultData<>(businessUserService.count(params)); + @GetMapping("list-business/{userId}") + public List listBusiness(@PathVariable("userId") String userId) { + return businessUserService.listBusiness(userId); } } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/usercenter/dao/businessuser/IBusinessUserDao.java b/src/main/java/cn/com/tenlion/usercenter/dao/businessuser/IBusinessUserDao.java index af477f8..0e2628f 100644 --- a/src/main/java/cn/com/tenlion/usercenter/dao/businessuser/IBusinessUserDao.java +++ b/src/main/java/cn/com/tenlion/usercenter/dao/businessuser/IBusinessUserDao.java @@ -109,6 +109,24 @@ public interface IBusinessUserDao extends IInitBaseTable { */ List listPO(Map params) throws SearchException; + /** + * 用户ID列表 + * + * @param params + * @return + * @throws SearchException + */ + List listUserId(Map params) throws SearchException; + + /** + * 业务ID列表 + * + * @param params + * @return + * @throws SearchException + */ + List listBusinessId(Map params) throws SearchException; + /** * 业务用户统计 * diff --git a/src/main/java/cn/com/tenlion/usercenter/pojo/dtos/businessuser/BusinessUserDTO.java b/src/main/java/cn/com/tenlion/usercenter/pojo/dtos/businessuser/BusinessUserDTO.java index 20226f4..3d9e293 100644 --- a/src/main/java/cn/com/tenlion/usercenter/pojo/dtos/businessuser/BusinessUserDTO.java +++ b/src/main/java/cn/com/tenlion/usercenter/pojo/dtos/businessuser/BusinessUserDTO.java @@ -20,6 +20,10 @@ public class BusinessUserDTO { private String businessId; @ApiModelProperty(name = "userId", value = "用户ID") private String userId; + @ApiModelProperty(name = "userName", value = "昵称") + private String userName; + @ApiModelProperty(name = "username", value = "用户名") + private String userUsername; public String getBusinessUserId() { return businessUserId == null ? "" : businessUserId.trim(); @@ -45,5 +49,19 @@ public class BusinessUserDTO { this.userId = userId; } + public String getUserName() { + return userName == null ? "" : userName.trim(); + } + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserUsername() { + return userUsername == null ? "" : userUsername.trim(); + } + + public void setUserUsername(String userUsername) { + this.userUsername = userUsername; + } } diff --git a/src/main/java/cn/com/tenlion/usercenter/pojo/vos/business/BusinessVO.java b/src/main/java/cn/com/tenlion/usercenter/pojo/vos/business/BusinessVO.java index 88f4cef..5027955 100644 --- a/src/main/java/cn/com/tenlion/usercenter/pojo/vos/business/BusinessVO.java +++ b/src/main/java/cn/com/tenlion/usercenter/pojo/vos/business/BusinessVO.java @@ -1,7 +1,6 @@ package cn.com.tenlion.usercenter.pojo.vos.business; import ink.wgink.annotation.CheckEmptyAnnotation; -import ink.wgink.annotation.CheckNumberAnnotation; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -17,6 +16,7 @@ import io.swagger.annotations.ApiModelProperty; public class BusinessVO { @ApiModelProperty(name = "businessName", value = "业务名称") + @CheckEmptyAnnotation(name = "业务名称") private String businessName; @ApiModelProperty(name = "businessSummary", value = "业务描述") private String businessSummary; diff --git a/src/main/java/cn/com/tenlion/usercenter/service/business/IBusinessService.java b/src/main/java/cn/com/tenlion/usercenter/service/business/IBusinessService.java index d891fbe..27b9751 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/business/IBusinessService.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/business/IBusinessService.java @@ -66,7 +66,7 @@ public interface IBusinessService { * 删除业务 * * @param token - * @param ids id列表 + * @param ids id列表 * @return */ void remove(String token, List ids); @@ -145,6 +145,14 @@ public interface IBusinessService { */ BusinessPO getPO(String businessId); + /** + * 业务详情 + * + * @param businessCode 业务编码 + * @return + */ + BusinessPO getPOByBusinessCode(String businessCode); + /** * 业务列表 * @@ -153,6 +161,14 @@ public interface IBusinessService { */ List list(Map params); + /** + * 业务列表 + * + * @param businessIds 业务ID列表 + * @return + */ + List listByBusinessIds(List businessIds); + /** * 业务列表 * diff --git a/src/main/java/cn/com/tenlion/usercenter/service/business/impl/BusinessServiceImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/business/impl/BusinessServiceImpl.java index c46ddf1..b0f525a 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/business/impl/BusinessServiceImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/business/impl/BusinessServiceImpl.java @@ -1,24 +1,25 @@ package cn.com.tenlion.usercenter.service.business.impl; -import ink.wgink.common.base.DefaultBaseService; -import ink.wgink.pojo.ListPage; -import ink.wgink.pojo.result.SuccessResult; -import ink.wgink.pojo.result.SuccessResultList; -import ink.wgink.util.map.HashMapUtil; -import ink.wgink.util.UUIDUtil; import cn.com.tenlion.usercenter.dao.business.IBusinessDao; -import cn.com.tenlion.usercenter.pojo.dtos.business.BusinessDTO; -import cn.com.tenlion.usercenter.pojo.vos.business.BusinessVO; import cn.com.tenlion.usercenter.pojo.bos.business.BusinessBO; +import cn.com.tenlion.usercenter.pojo.dtos.business.BusinessDTO; import cn.com.tenlion.usercenter.pojo.pos.business.BusinessPO; +import cn.com.tenlion.usercenter.pojo.vos.business.BusinessVO; import cn.com.tenlion.usercenter.service.business.IBusinessService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import ink.wgink.common.base.DefaultBaseService; +import ink.wgink.exceptions.SearchException; +import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.result.SuccessResultList; +import ink.wgink.util.UUIDUtil; +import ink.wgink.util.map.HashMapUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.*; +import java.util.List; +import java.util.Map; /** * @ClassName: BusinessServiceImpl @@ -50,6 +51,10 @@ public class BusinessServiceImpl extends DefaultBaseService implements IBusiness @Override public String saveReturnId(String token, BusinessVO businessVO) { + BusinessPO businessPO = getPOByBusinessCode(businessVO.getBusinessCode()); + if (businessPO != null) { + throw new SearchException("编码已经存在"); + } String businessId = UUIDUtil.getUUID(); Map params = HashMapUtil.beanToMap(businessVO); params.put("businessId", businessId); @@ -139,11 +144,25 @@ public class BusinessServiceImpl extends DefaultBaseService implements IBusiness return getPO(params); } + @Override + public BusinessPO getPOByBusinessCode(String businessCode) { + Map params = getHashMap(2); + params.put("businessCode", businessCode); + return getPO(params); + } + @Override public List list(Map params) { return businessDao.list(params); } + @Override + public List listByBusinessIds(List businessIds) { + Map params = getHashMap(2); + params.put("businessIds", businessIds); + return list(params); + } + @Override public List listBO(Map params) { return businessDao.listBO(params); diff --git a/src/main/java/cn/com/tenlion/usercenter/service/businessuser/IBusinessUserService.java b/src/main/java/cn/com/tenlion/usercenter/service/businessuser/IBusinessUserService.java index 48af288..2fccd4a 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/businessuser/IBusinessUserService.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/businessuser/IBusinessUserService.java @@ -1,11 +1,13 @@ package cn.com.tenlion.usercenter.service.businessuser; -import ink.wgink.pojo.ListPage; -import ink.wgink.pojo.result.SuccessResultList; -import cn.com.tenlion.usercenter.pojo.dtos.businessuser.BusinessUserDTO; -import cn.com.tenlion.usercenter.pojo.vos.businessuser.BusinessUserVO; import cn.com.tenlion.usercenter.pojo.bos.businessuser.BusinessUserBO; +import cn.com.tenlion.usercenter.pojo.dtos.business.BusinessDTO; +import cn.com.tenlion.usercenter.pojo.dtos.businessuser.BusinessUserDTO; import cn.com.tenlion.usercenter.pojo.pos.businessuser.BusinessUserPO; +import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.dtos.user.UserDTO; +import ink.wgink.pojo.result.SuccessResultList; +import ink.wgink.pojo.vos.IdsVO; import java.util.List; import java.util.Map; @@ -19,58 +21,6 @@ import java.util.Map; **/ public interface IBusinessUserService { - /** - * 新增业务用户 - * - * @param businessUserVO - * @return - */ - void save(BusinessUserVO businessUserVO); - - /** - * 新增业务用户 - * - * @param token - * @param businessUserVO - * @return - */ - void save(String token, BusinessUserVO businessUserVO); - - /** - * 新增业务用户 - * - * @param businessUserVO - * @return businessUserId - */ - String saveReturnId(BusinessUserVO businessUserVO); - - /** - * 新增业务用户 - * - * @param token - * @param businessUserVO - * @return businessUserId - */ - String saveReturnId(String token, BusinessUserVO businessUserVO); - - /** - * 删除业务用户 - * - * @param ids id列表 - * @return - */ - void remove(List ids); - - - /** - * 删除业务用户 - * - * @param token - * @param ids id列表 - * @return - */ - void remove(String token, List ids); - /** * 删除业务用户(物理删除) * @@ -81,21 +31,11 @@ public interface IBusinessUserService { /** * 修改业务用户 * - * @param businessUserId - * @param businessUserVO + * @param businessId + * @param idsVO * @return */ - void update(String businessUserId, BusinessUserVO businessUserVO); - - /** - * 修改业务用户 - * - * @param token - * @param businessUserId - * @param businessUserVO - * @return - */ - void update(String token, String businessUserId, BusinessUserVO businessUserVO); + void update(String businessId, IdsVO idsVO); /** * 业务用户详情 @@ -153,6 +93,24 @@ public interface IBusinessUserService { */ List list(Map params); + /** + * 业务用户ID列表 + * + * @param businessId + * @param params + * @return + */ + List listUserId(String businessId, Map params); + + /** + * 业务ID列表 + * + * @param businessId + * @param params + * @return + */ + List listBusinessId(String businessId, Map params); + /** * 业务用户列表 * @@ -177,6 +135,15 @@ public interface IBusinessUserService { */ SuccessResultList> listPage(ListPage page); + /** + * 业务用户分页列表 + * + * @param businessId + * @param page + * @return + */ + SuccessResultList> listPage(String businessId, ListPage page); + /** * 业务用户统计 * @@ -185,4 +152,19 @@ public interface IBusinessUserService { */ Integer count(Map params); + /** + * 用户列表 + * + * @param businessId 业务ID + * @return + */ + List listUser(String businessId); + + /** + * 业务列表 + * + * @param userId 用户ID + * @return + */ + List listBusiness(String userId); } \ No newline at end of file diff --git a/src/main/java/cn/com/tenlion/usercenter/service/businessuser/impl/BusinessUserServiceImpl.java b/src/main/java/cn/com/tenlion/usercenter/service/businessuser/impl/BusinessUserServiceImpl.java index 6fcc63b..9fc555b 100644 --- a/src/main/java/cn/com/tenlion/usercenter/service/businessuser/impl/BusinessUserServiceImpl.java +++ b/src/main/java/cn/com/tenlion/usercenter/service/businessuser/impl/BusinessUserServiceImpl.java @@ -1,24 +1,29 @@ package cn.com.tenlion.usercenter.service.businessuser.impl; -import ink.wgink.common.base.DefaultBaseService; -import ink.wgink.pojo.ListPage; -import ink.wgink.pojo.result.SuccessResult; -import ink.wgink.pojo.result.SuccessResultList; -import ink.wgink.util.map.HashMapUtil; -import ink.wgink.util.UUIDUtil; import cn.com.tenlion.usercenter.dao.businessuser.IBusinessUserDao; -import cn.com.tenlion.usercenter.pojo.dtos.businessuser.BusinessUserDTO; -import cn.com.tenlion.usercenter.pojo.vos.businessuser.BusinessUserVO; import cn.com.tenlion.usercenter.pojo.bos.businessuser.BusinessUserBO; +import cn.com.tenlion.usercenter.pojo.dtos.business.BusinessDTO; +import cn.com.tenlion.usercenter.pojo.dtos.businessuser.BusinessUserDTO; import cn.com.tenlion.usercenter.pojo.pos.businessuser.BusinessUserPO; +import cn.com.tenlion.usercenter.service.business.IBusinessService; import cn.com.tenlion.usercenter.service.businessuser.IBusinessUserService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import ink.wgink.common.base.DefaultBaseService; +import ink.wgink.interfaces.user.IUserBaseService; +import ink.wgink.pojo.ListPage; +import ink.wgink.pojo.dtos.user.UserDTO; +import ink.wgink.pojo.result.SuccessResultList; +import ink.wgink.pojo.vos.IdsVO; +import ink.wgink.util.ArrayListUtil; +import ink.wgink.util.UUIDUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; /** * @ClassName: BusinessUserServiceImpl @@ -32,52 +37,10 @@ public class BusinessUserServiceImpl extends DefaultBaseService implements IBusi @Autowired private IBusinessUserDao businessUserDao; - - @Override - public void save(BusinessUserVO businessUserVO) { - saveReturnId(businessUserVO); - } - - @Override - public void save(String token, BusinessUserVO businessUserVO) { - saveReturnId(token, businessUserVO); - } - - @Override - public String saveReturnId(BusinessUserVO businessUserVO) { - return saveReturnId(null, businessUserVO); - } - - @Override - public String saveReturnId(String token, BusinessUserVO businessUserVO) { - String businessUserId = UUIDUtil.getUUID(); - Map params = HashMapUtil.beanToMap(businessUserVO); - params.put("businessUserId", businessUserId); - if (StringUtils.isBlank(token)) { - setSaveInfo(params); - } else { - setAppSaveInfo(token, params); - } - businessUserDao.save(params); - return businessUserId; - } - - @Override - public void remove(List ids) { - remove(null, ids); - } - - @Override - public void remove(String token, List ids) { - Map params = getHashMap(2); - params.put("businessUserIds", ids); - if (StringUtils.isBlank(token)) { - setUpdateInfo(params); - } else { - setAppUpdateInfo(token, params); - } - businessUserDao.remove(params); - } + @Autowired + private IUserBaseService userBaseService; + @Autowired + private IBusinessService businessService; @Override public void delete(List ids) { @@ -87,20 +50,30 @@ public class BusinessUserServiceImpl extends DefaultBaseService implements IBusi } @Override - public void update(String businessUserId, BusinessUserVO businessUserVO) { - update(null, businessUserId, businessUserVO); - } - - @Override - public void update(String token, String businessUserId, BusinessUserVO businessUserVO) { - Map params = HashMapUtil.beanToMap(businessUserVO); - params.put("businessUserId", businessUserId); - if (StringUtils.isBlank(token)) { - setUpdateInfo(params); - } else { - setAppUpdateInfo(token, params); + public void update(String businessId, IdsVO idsVO) { + List userIds = idsVO.getIds(); + if (userIds.isEmpty()) { + return; + } + Map params = getHashMap(2); + params.put("businessId", businessId); + params.put("userIds", userIds); + List existUserIds = businessUserDao.listUserId(params); + List newUserIds = new ArrayList<>(); + for (String userId : userIds) { + boolean isNewUser = true; + for (String existUserId : existUserIds) { + if (StringUtils.equals(userId, existUserId)) { + isNewUser = false; + break; + } + } + if (isNewUser) { + params.put("businessUserId", UUIDUtil.getUUID()); + params.put("userId", userId); + businessUserDao.save(params); + } } - businessUserDao.update(params); } @Override @@ -141,7 +114,27 @@ public class BusinessUserServiceImpl extends DefaultBaseService implements IBusi @Override public List list(Map params) { - return businessUserDao.list(params); + String keywords = getKeywords(params); + if (!StringUtils.isBlank(keywords)) { + List userDTOs = userBaseService.listByKeywords(keywords); + List userIds = ArrayListUtil.listBeanStringIdValue(userDTOs, "userId", UserDTO.class); + params.put("userIds", userIds); + } + List businessUserDTOs = businessUserDao.list(params); + setUser(businessUserDTOs); + return businessUserDTOs; + } + + @Override + public List listUserId(String businessId, Map params) { + params.put("businessId", businessId); + return businessUserDao.listUserId(params); + } + + @Override + public List listBusinessId(String businessId, Map params) { + params.put("businessId", businessId); + return businessUserDao.listBusinessId(params); } @Override @@ -162,10 +155,63 @@ public class BusinessUserServiceImpl extends DefaultBaseService implements IBusi return new SuccessResultList<>(businessUserDTOs, pageInfo.getPageNum(), pageInfo.getTotal()); } + @Override + public SuccessResultList> listPage(String businessId, ListPage page) { + page.getParams().put("businessId", businessId); + return listPage(page); + } + @Override public Integer count(Map params) { Integer count = businessUserDao.count(params); return count == null ? 0 : count; } + @Override + public List listUser(String businessId) { + Map params = getHashMap(2); + params.put("businessId", businessId); + List userIds = businessUserDao.listUserId(params); + if (userIds.isEmpty()) { + return new ArrayList<>(); + } + return userBaseService.listByUserIds(userIds); + } + + @Override + public List listBusiness(String userId) { + Map params = getHashMap(2); + params.put("userId", userId); + List businessIds = businessUserDao.listBusinessId(params); + if (businessIds.isEmpty()) { + return new ArrayList<>(); + } + return businessService.listByBusinessIds(businessIds); + } + + /** + * 设置用户 + * + * @param businessUserDTOs + */ + private void setUser(List businessUserDTOs) { + if (businessUserDTOs.isEmpty()) { + return; + } + List userIds = ArrayListUtil.listBeanStringIdValue(businessUserDTOs, "userId", BusinessUserDTO.class); + List userDTOs = userBaseService.listByUserIds(userIds); + if (userDTOs.isEmpty()) { + return; + } + for (BusinessUserDTO businessUserDTO : businessUserDTOs) { + for (UserDTO userDTO : userDTOs) { + if (StringUtils.equals(businessUserDTO.getUserId(), userDTO.getUserId())) { + businessUserDTO.setUserName(userDTO.getUserName()); + businessUserDTO.setUserUsername(userDTO.getUserUsername()); + break; + } + } + } + } + } \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/business-user/business-user-mapper.xml b/src/main/resources/mybatis/mapper/business-user/business-user-mapper.xml index 89f8650..1615201 100644 --- a/src/main/resources/mybatis/mapper/business-user/business-user-mapper.xml +++ b/src/main/resources/mybatis/mapper/business-user/business-user-mapper.xml @@ -127,25 +127,29 @@ SELECT t1.business_user_id, t1.business_id, - t1.user_id, - 1 + t1.user_id FROM city_business_user t1 - WHERE - 1 = 1 - - AND ( - - t1.id LIKE CONCAT('%', #{keywords}, '%') - ) - - - AND - t1.business_user_id IN - - #{businessUserIds[${index}]} - - + + + AND + t1.business_id = #{businessId} + + + AND + t1.business_user_id IN + + #{businessUserIds[${index}]} + + + + AND + t1.user_id IN + + #{userIds[${index}]} + + + @@ -198,6 +202,39 @@ + + + + + + @@ -160,6 +160,10 @@ AND t1.business_id = #{businessId} + + AND + t1.business_code = #{businessCode} + @@ -182,6 +186,10 @@ AND t1.business_id = #{businessId} + + AND + t1.business_code = #{businessCode} + @@ -191,8 +199,7 @@ t1.business_name, t1.business_summary, t1.business_code, - t1.gmt_create, - 1 + t1.gmt_create FROM city_business t1 WHERE @@ -200,7 +207,7 @@ AND ( - t1.id LIKE CONCAT('%', #{keywords}, '%') + t1.business_name LIKE CONCAT('%', #{keywords}, '%') ) @@ -239,7 +246,7 @@ AND ( - t1.id LIKE CONCAT('%', #{keywords}, '%') + t1.business_name LIKE CONCAT('%', #{keywords}, '%') ) @@ -278,7 +285,7 @@ AND ( - t1.id LIKE CONCAT('%', #{keywords}, '%') + t1.business_name LIKE CONCAT('%', #{keywords}, '%') ) diff --git a/src/main/resources/templates/business-user/list.html b/src/main/resources/templates/business-user/list.html index a57a8f0..4281ea1 100644 --- a/src/main/resources/templates/business-user/list.html +++ b/src/main/resources/templates/business-user/list.html @@ -11,7 +11,7 @@ -
+
@@ -20,13 +20,6 @@
- 新增时间 -
- -
-
- -
@@ -38,9 +31,6 @@ - @@ -51,8 +41,8 @@
+ - - - - \ No newline at end of file diff --git a/src/main/resources/templates/business-user/update.html b/src/main/resources/templates/business-user/update.html deleted file mode 100644 index 9387834..0000000 --- a/src/main/resources/templates/business-user/update.html +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - - -
-
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
-
-
-
-
- - - - \ No newline at end of file diff --git a/src/main/resources/templates/business/list.html b/src/main/resources/templates/business/list.html index 42f08ba..ea51b21 100644 --- a/src/main/resources/templates/business/list.html +++ b/src/main/resources/templates/business/list.html @@ -52,7 +52,6 @@
- diff --git a/src/main/resources/templates/business/update.html b/src/main/resources/templates/business/update.html index 4133ceb..9e71bdb 100644 --- a/src/main/resources/templates/business/update.html +++ b/src/main/resources/templates/business/update.html @@ -33,12 +33,6 @@ -
- -
- -
-