新增业务与用户业务关联关系

This commit is contained in:
wanggeng 2021-11-04 00:16:08 +08:00
parent 97941cb489
commit 73d8b51816
19 changed files with 510 additions and 692 deletions

View File

@ -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")

View File

@ -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<BusinessUserDTO> list() {
@GetMapping("list-user-id/{businessId}")
public List<String> list(@PathVariable("businessId") String businessId) {
Map<String, Object> 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<UserDTO> 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<BusinessDTO> 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<List<BusinessUserDTO>> listPage(ListPage page) {
@GetMapping("listpage/{businessId}")
public SuccessResultList<List<BusinessUserDTO>> listPage(@PathVariable("businessId") String businessId, ListPage page) {
Map<String, Object> params = requestParams();
page.setParams(params);
return businessUserService.listPage(page);
return businessUserService.listPage(businessId, page);
}
@ApiOperation(value = "业务用户统计", notes = "业务用户统计接口")

View File

@ -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"),

View File

@ -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"),

View File

@ -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<BusinessUserDTO> list() {
Map<String, Object> params = requestParams();
return businessUserService.list(params);
@GetMapping("list-user/{businessId}")
public List<UserDTO> 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<List<BusinessUserDTO>> listPage(ListPage page) {
Map<String, Object> params = requestParams();
page.setParams(params);
return businessUserService.listPage(page);
}
@ApiOperation(value = "业务用户统计", notes = "业务用户统计接口")
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("count")
SuccessResultData<Integer> count() {
Map<String, Object> params = requestParams();
return new SuccessResultData<>(businessUserService.count(params));
@GetMapping("list-business/{userId}")
public List<BusinessDTO> listBusiness(@PathVariable("userId") String userId) {
return businessUserService.listBusiness(userId);
}
}

View File

@ -109,6 +109,24 @@ public interface IBusinessUserDao extends IInitBaseTable {
*/
List<BusinessUserPO> listPO(Map<String, Object> params) throws SearchException;
/**
* 用户ID列表
*
* @param params
* @return
* @throws SearchException
*/
List<String> listUserId(Map<String, Object> params) throws SearchException;
/**
* 业务ID列表
*
* @param params
* @return
* @throws SearchException
*/
List<String> listBusinessId(Map<String, Object> params) throws SearchException;
/**
* 业务用户统计
*

View File

@ -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;
}
}

View File

@ -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;

View File

@ -66,7 +66,7 @@ public interface IBusinessService {
* 删除业务
*
* @param token
* @param ids id列表
* @param ids id列表
* @return
*/
void remove(String token, List<String> 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<BusinessDTO> list(Map<String, Object> params);
/**
* 业务列表
*
* @param businessIds 业务ID列表
* @return
*/
List<BusinessDTO> listByBusinessIds(List<String> businessIds);
/**
* 业务列表
*

View File

@ -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<String, Object> 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<String, Object> params = getHashMap(2);
params.put("businessCode", businessCode);
return getPO(params);
}
@Override
public List<BusinessDTO> list(Map<String, Object> params) {
return businessDao.list(params);
}
@Override
public List<BusinessDTO> listByBusinessIds(List<String> businessIds) {
Map<String, Object> params = getHashMap(2);
params.put("businessIds", businessIds);
return list(params);
}
@Override
public List<BusinessBO> listBO(Map<String, Object> params) {
return businessDao.listBO(params);

View File

@ -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<String> ids);
/**
* 删除业务用户
*
* @param token
* @param ids id列表
* @return
*/
void remove(String token, List<String> 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<BusinessUserDTO> list(Map<String, Object> params);
/**
* 业务用户ID列表
*
* @param businessId
* @param params
* @return
*/
List<String> listUserId(String businessId, Map<String, Object> params);
/**
* 业务ID列表
*
* @param businessId
* @param params
* @return
*/
List<String> listBusinessId(String businessId, Map<String, Object> params);
/**
* 业务用户列表
*
@ -177,6 +135,15 @@ public interface IBusinessUserService {
*/
SuccessResultList<List<BusinessUserDTO>> listPage(ListPage page);
/**
* 业务用户分页列表
*
* @param businessId
* @param page
* @return
*/
SuccessResultList<List<BusinessUserDTO>> listPage(String businessId, ListPage page);
/**
* 业务用户统计
*
@ -185,4 +152,19 @@ public interface IBusinessUserService {
*/
Integer count(Map<String, Object> params);
/**
* 用户列表
*
* @param businessId 业务ID
* @return
*/
List<UserDTO> listUser(String businessId);
/**
* 业务列表
*
* @param userId 用户ID
* @return
*/
List<BusinessDTO> listBusiness(String userId);
}

View File

@ -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<String, Object> 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<String> ids) {
remove(null, ids);
}
@Override
public void remove(String token, List<String> ids) {
Map<String, Object> 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<String> 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<String, Object> 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<String> userIds = idsVO.getIds();
if (userIds.isEmpty()) {
return;
}
Map<String, Object> params = getHashMap(2);
params.put("businessId", businessId);
params.put("userIds", userIds);
List<String> existUserIds = businessUserDao.listUserId(params);
List<String> 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<BusinessUserDTO> list(Map<String, Object> params) {
return businessUserDao.list(params);
String keywords = getKeywords(params);
if (!StringUtils.isBlank(keywords)) {
List<UserDTO> userDTOs = userBaseService.listByKeywords(keywords);
List<String> userIds = ArrayListUtil.listBeanStringIdValue(userDTOs, "userId", UserDTO.class);
params.put("userIds", userIds);
}
List<BusinessUserDTO> businessUserDTOs = businessUserDao.list(params);
setUser(businessUserDTOs);
return businessUserDTOs;
}
@Override
public List<String> listUserId(String businessId, Map<String, Object> params) {
params.put("businessId", businessId);
return businessUserDao.listUserId(params);
}
@Override
public List<String> listBusinessId(String businessId, Map<String, Object> 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<List<BusinessUserDTO>> listPage(String businessId, ListPage page) {
page.getParams().put("businessId", businessId);
return listPage(page);
}
@Override
public Integer count(Map<String, Object> params) {
Integer count = businessUserDao.count(params);
return count == null ? 0 : count;
}
@Override
public List<UserDTO> listUser(String businessId) {
Map<String, Object> params = getHashMap(2);
params.put("businessId", businessId);
List<String> userIds = businessUserDao.listUserId(params);
if (userIds.isEmpty()) {
return new ArrayList<>();
}
return userBaseService.listByUserIds(userIds);
}
@Override
public List<BusinessDTO> listBusiness(String userId) {
Map<String, Object> params = getHashMap(2);
params.put("userId", userId);
List<String> businessIds = businessUserDao.listBusinessId(params);
if (businessIds.isEmpty()) {
return new ArrayList<>();
}
return businessService.listByBusinessIds(businessIds);
}
/**
* 设置用户
*
* @param businessUserDTOs
*/
private void setUser(List<BusinessUserDTO> businessUserDTOs) {
if (businessUserDTOs.isEmpty()) {
return;
}
List<String> userIds = ArrayListUtil.listBeanStringIdValue(businessUserDTOs, "userId", BusinessUserDTO.class);
List<UserDTO> 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;
}
}
}
}
}

View File

@ -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
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="businessUserIds != null and businessUserIds.size > 0">
AND
t1.business_user_id IN
<foreach collection="businessUserIds" index="index" open="(" separator="," close=")">
#{businessUserIds[${index}]}
</foreach>
</if>
<where>
<if test="businessId != null and businessId != ''">
AND
t1.business_id = #{businessId}
</if>
<if test="businessUserIds != null and businessUserIds.size > 0">
AND
t1.business_user_id IN
<foreach collection="businessUserIds" index="index" open="(" separator="," close=")">
#{businessUserIds[${index}]}
</foreach>
</if>
<if test="userIds != null and userIds.size > 0">
AND
t1.user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
</where>
</select>
<!-- 业务用户列表 -->
@ -198,6 +202,39 @@
</if>
</select>
<!-- 用户ID列表 -->
<select id="listUserId" parameterType="map" resultType="java.lang.String">
SELECT
user_id
FROM
city_business_user
<where>
<if test="businessId != null and businessId != ''">
business_id = #{businessId}
</if>
<if test="userIds != null and userIds.size > 0">
AND
user_id IN
<foreach collection="userIds" index="index" open="(" separator="," close=")">
#{userIds[${index}]}
</foreach>
</if>
</where>
</select>
<!-- 业务ID列表 -->
<select id="listBusinessId" parameterType="map" resultType="java.lang.String">
SELECT
business_id
FROM
city_business_user
<where>
<if test="userId != null and userId != ''">
user_id = #{userId}
</if>
</where>
</select>
<!-- 业务用户统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT

View File

@ -112,13 +112,9 @@
</if>
<if test="businessSummary != null and businessSummary != ''">
business_summary = #{businessSummary},
</if>
<if test="businessCode != null and businessCode != ''">
business_code = #{businessCode},
</if>
gmt_modified = #{gmtModified},
modifier = #{modifier},
business_id = business_id
modifier = #{modifier}
WHERE
business_id = #{businessId}
</update>
@ -138,6 +134,10 @@
AND
t1.business_id = #{businessId}
</if>
<if test="businessCode != null and businessCode != ''">
AND
t1.business_code = #{businessCode}
</if>
</select>
<!-- 业务详情 -->
@ -160,6 +160,10 @@
AND
t1.business_id = #{businessId}
</if>
<if test="businessCode != null and businessCode != ''">
AND
t1.business_code = #{businessCode}
</if>
</select>
<!-- 业务详情 -->
@ -182,6 +186,10 @@
AND
t1.business_id = #{businessId}
</if>
<if test="businessCode != null and businessCode != ''">
AND
t1.business_code = #{businessCode}
</if>
</select>
<!-- 业务列表 -->
@ -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 @@
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
t1.business_name LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
@ -239,7 +246,7 @@
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
t1.business_name LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
@ -278,7 +285,7 @@
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
t1.business_name LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">

View File

@ -11,7 +11,7 @@
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-anim layui-anim-fadein">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
@ -20,13 +20,6 @@
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item search-item-width-100" placeholder="输入关键字">
</div>
新增时间
<div class="layui-inline">
<input type="text" id="startTime" class="layui-input search-item search-item-width-100" placeholder="开始时间" readonly>
</div>
<div class="layui-inline">
<input type="text" id="endTime" class="layui-input search-item search-item-width-100" placeholder="结束时间" readonly>
</div>
<button type="button" id="search" class="layui-btn layui-btn-sm">
<i class="fa fa-lg fa-search"></i> 搜索
</button>
@ -38,9 +31,6 @@
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
<i class="fa fa-lg fa-plus"></i> 新增
</button>
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
<i class="fa fa-lg fa-edit"></i> 编辑
</button>
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
<i class="fa fa-lg fa-trash"></i> 删除
</button>
@ -51,8 +41,8 @@
</div>
</div>
</div>
<input id="selectedUserIds" type="hidden"/>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/'
@ -66,16 +56,17 @@
var laydate = layui.laydate;
var common = layui.common;
var resizeTimeout = null;
var tableUrl = 'api/business-user/listpage';
var businessId = top.restAjax.params(window.location.href).businessId;
var tableUrl = 'api/business-user/listpage/{businessId}';
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path(tableUrl, []),
url: top.restAjax.path(tableUrl, [businessId]),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 90,
height: $win.height() - 60,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
@ -87,7 +78,7 @@
[
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field: 'businessUserId', width: 180, title: '主键', align:'center',
{field: 'userUsername', width: 180, title: '用户名', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
@ -96,16 +87,7 @@
return rowData;
}
},
{field: 'businessId', width: 180, title: '业务ID', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'userId', width: 180, title: '用户ID', align:'center',
{field: 'userName', width: 180, title: '昵称', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
@ -161,8 +143,12 @@
yes: function (index) {
top.dialog.close(index);
var layIndex;
top.restAjax.delete(top.restAjax.path('api/business-user/remove/{ids}', [ids]), {}, null, function (code, data) {
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
top.restAjax.delete(top.restAjax.path('api/business-user/delete/{ids}', [ids]), {}, null, function (code, data) {
top.dialog.msg(top.dataMessage.deleteSuccess);
var deleteUserIds = ids.split('_');
var selectedUserIds = $('#selectedUserIds').val().split('_');
var tempIds = common.resultIdsOfDeleteIds(deleteUserIds, selectedUserIds);
$('#selectedUserIds').val(tempIds);
reloadTable();
}, function (code, data) {
top.dialog.msg(data.msg);
@ -174,8 +160,31 @@
}
});
}
initTable();
initDate();
// 初始化职位用户ID列表
function initSelectUserIds() {
var layIndex;
top.restAjax.get(top.restAjax.path('api/business-user/list-user-id/{businessId}', [businessId]), {}, null, function(code, data) {
var selectedUserIds = '';
for(var i = 0, item; item = data[i++]; ) {
if('' != selectedUserIds) {
selectedUserIds += '_';
}
selectedUserIds += item;
}
$('#selectedUserIds').val(selectedUserIds);
initTable();
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
layIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(layIndex);
});
}
initSelectUserIds();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
@ -193,37 +202,47 @@
var checkStatus = table.checkStatus('dataTable');
var checkDatas = checkStatus.data;
if(layEvent === 'saveEvent') {
layer.open({
type: 2,
title: false,
top.dialog.dialogData.selectedUserIds = $('#selectedUserIds').val();
top.dialog.open({
url: top.restAjax.path('route/department/user/select-user', []),
title: '选择用户',
width: '500px',
height: '500px',
closeBtn: 0,
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/business-user/save', []),
end: function() {
reloadTable();
}
});
} else if(layEvent === 'updateEvent') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectEdit);
} else if(checkDatas.length > 1) {
top.dialog.msg(top.dataMessage.table.selectOneEdit);
} else {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/business-user/update?businessUserId={businessUserId}', [checkDatas[0].businessUserId]),
end: function() {
reloadTable();
onClose: function() {
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
if(selectedUsers != null && selectedUsers.length > 0) {
var ids = [];
for (var i = 0, item; item = selectedUsers[i++];) {
ids.push(item.userId);
}
top.dialog.msg(top.dataMessage.update, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
yes: function (index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.put(top.restAjax.path('api/business-user/update/{businessId}', [businessId]), {
ids: ids
}, null, function (code, data) {
top.dialog.msg(top.dataMessage.updated);
initSelectUserIds();
}, function (code, data) {
top.dialog.msg(data.msg);
}, function () {
loadLayerIndex = top.dialog.msg(top.dataMessage.updating, {
icon: 16,
time: 0,
shade: 0.3
});
}, function () {
top.dialog.close(loadLayerIndex);
});
},
});
}
});
}
}
})
} else if(layEvent === 'removeEvent') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectDelete);

View File

@ -1,111 +0,0 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>新增内容</cite></a>
</span>
</div>
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="layui-form-item">
<label class="layui-form-label">业务ID</label>
<div class="layui-input-block">
<input type="text" id="businessId" name="businessId" class="layui-input" value="" placeholder="请输入业务ID" maxlength="36">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">用户ID</label>
<div class="layui-input-block">
<input type="text" id="userId" name="userId" class="layui-input" value="" placeholder="请输入用户ID" maxlength="36">
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 初始化内容
function initData() {
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/business-user/save', []), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
window.location.reload();
},
btn2: function() {
closeBox();
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
$('.close').on('click', function() {
closeBox();
});
// 校验
form.verify({
});
});
</script>
</body>
</html>

View File

@ -1,128 +0,0 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>编辑内容</cite></a>
</span>
</div>
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="layui-form-item">
<label class="layui-form-label">业务ID</label>
<div class="layui-input-block">
<input type="text" id="businessId" name="businessId" class="layui-input" value="" placeholder="请输入业务ID" maxlength="36">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">用户ID</label>
<div class="layui-input-block">
<input type="text" id="userId" name="userId" class="layui-input" value="" placeholder="请输入用户ID" maxlength="36">
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交编辑</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
var businessUserId = top.restAjax.params(window.location.href).businessUserId;
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 初始化内容
function initData() {
var loadLayerIndex;
top.restAjax.get(top.restAjax.path('api/business-user/get/{businessUserId}', [businessUserId]), {}, null, function(code, data) {
var dataFormData = {};
for(var i in data) {
dataFormData[i] = data[i] +'';
}
form.val('dataForm', dataFormData);
form.render(null, 'dataForm');
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.put(top.restAjax.path('api/business-user/update/{businessUserId}', [businessUserId]), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
window.location.reload();
},
btn2: function() {
closeBox();
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
$('.close').on('click', function() {
closeBox();
});
// 校验
form.verify({
});
});
</script>
</body>
</html>

View File

@ -52,7 +52,6 @@
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/'
@ -87,15 +86,6 @@
[
{type:'checkbox', fixed: 'left'},
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
{field: 'businessId', width: 180, title: '主键', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'businessName', width: 180, title: '业务名称', align:'center',
templet: function(row) {
var rowData = row[this.field];
@ -132,6 +122,11 @@
return rowData;
}
},
{field: 'userList', width: 120, title: '操作', align:'center', fixed: 'right',
templet: function(row) {
return '<button type="button" class="layui-btn layui-btn-sm" lay-event="userListEvent">人员列表</button>';;
}
},
]
],
page: true,
@ -257,6 +252,22 @@
}
}
});
// 事件处理
table.on('tool(dataTable)', function(obj) {
var layEvent = obj.event;
var data = obj.data;
if(layEvent === 'userListEvent') {
top.dialog.open({
url: top.restAjax.path('route/business-user/list?businessId={businessId}', [data.businessId]),
title: '人员列表',
width: '800px',
height: '450px',
onClose: function() {
}
});
}
});
});
</script>
</body>

View File

@ -33,12 +33,6 @@
<input type="text" id="businessSummary" name="businessSummary" class="layui-input" value="" placeholder="请输入业务描述" maxlength="255">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">业务编码</label>
<div class="layui-input-block">
<input type="text" id="businessCode" name="businessCode" class="layui-input" value="" placeholder="请输入业务编码" maxlength="255">
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">