diff --git a/muyu-modules/cloud-modules-many-datasource/pom.xml b/muyu-modules/cloud-modules-many-datasource/pom.xml index b0fbd66..32beee1 100644 --- a/muyu-modules/cloud-modules-many-datasource/pom.xml +++ b/muyu-modules/cloud-modules-many-datasource/pom.xml @@ -21,6 +21,12 @@ + + com.muyu + muyu-customer-business-server + 3.6.3 + + com.alibaba.cloud diff --git a/muyu-modules/cloud-modules-many-datasource/src/main/java/com/muyu/cloud/many/datasource/config/ManyDataSource.java b/muyu-modules/cloud-modules-many-datasource/src/main/java/com/muyu/cloud/many/datasource/config/ManyDataSource.java index d901d46..2fe2c6f 100644 --- a/muyu-modules/cloud-modules-many-datasource/src/main/java/com/muyu/cloud/many/datasource/config/ManyDataSource.java +++ b/muyu-modules/cloud-modules-many-datasource/src/main/java/com/muyu/cloud/many/datasource/config/ManyDataSource.java @@ -1,7 +1,7 @@ package com.muyu.cloud.many.datasource.config; import com.alibaba.druid.pool.DruidDataSource; -import com.alibaba.druid.pool.DruidDataSourceFactory; +import com.muyu.cloud.many.datasource.config.factory.DruidDataSourceFactory; import com.muyu.cloud.many.datasource.config.domain.model.DataSourceInfo; import com.muyu.cloud.many.datasource.config.domain.model.EnterPriseInfo; import com.muyu.cloud.many.datasource.config.role.DynamicDataSource; @@ -38,8 +38,8 @@ public class ManyDataSource { DruidDataSourceFactory druidDataSourceFactory= SpringUtils.getBean(DruidDataSourceFactory.class); DynamicDataSource dynamicDataSource= SpringUtils.getBean(DynamicDataSource.class); EnterPriseInfo enterPriseInfo = EnterPriseInfo.builder() - .entCode("liu_0603") - .ip("192.168.116.129") + .entCode("jiang_0604") + .ip("101.34.248.9") .port(3308) .build(); @@ -54,8 +54,8 @@ public class ManyDataSource { List list = new ArrayList<>(); list.add( EnterPriseInfo.builder() - .entCode("liu_0604") - .ip("192.168.116.129") + .entCode("jiang_0604") + .ip("101.34.248.9") .port(3307) .build() ); diff --git a/muyu-modules/cloud-modules-many-datasource/src/main/java/com/muyu/cloud/many/datasource/config/domain/model/DataSourceInfo.java b/muyu-modules/cloud-modules-many-datasource/src/main/java/com/muyu/cloud/many/datasource/config/domain/model/DataSourceInfo.java index 4813c09..c6ea5f8 100644 --- a/muyu-modules/cloud-modules-many-datasource/src/main/java/com/muyu/cloud/many/datasource/config/domain/model/DataSourceInfo.java +++ b/muyu-modules/cloud-modules-many-datasource/src/main/java/com/muyu/cloud/many/datasource/config/domain/model/DataSourceInfo.java @@ -7,6 +7,8 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import static com.muyu.cloud.many.datasource.config.DatasourceContent.*; + /** * @author DongZl * @description: 数据源实体类 @@ -34,15 +36,14 @@ public class DataSourceInfo { private String userName; /** - * 用户密码 + * 密码 */ private String password; - public static DataSourceInfo hostAndPortBuild(String key,String host, Integer port){ return DataSourceInfo.builder() .key(key) - .url(StringUtils.format(DATASOURCE_URL, host, port,port)) + .url(StringUtils.format(DATASOURCE_URL, host,port)) .password(PASSWORD) .userName(USER_NAME) .build(); diff --git a/muyu-modules/cloud-modules-many-datasource/src/main/java/com/muyu/cloud/many/datasource/config/role/DataSourceAsp.java b/muyu-modules/cloud-modules-many-datasource/src/main/java/com/muyu/cloud/many/datasource/config/role/DataSourceAsp.java new file mode 100644 index 0000000..d34018c --- /dev/null +++ b/muyu-modules/cloud-modules-many-datasource/src/main/java/com/muyu/cloud/many/datasource/config/role/DataSourceAsp.java @@ -0,0 +1,34 @@ +package com.muyu.cloud.many.datasource.config.role; + +import com.muyu.cloud.many.datasource.config.holder.DynamicDataSourceHolder; +import com.muyu.common.security.utils.SecurityUtils; +import org.aspectj.lang.annotation.After; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; +import org.springframework.stereotype.Component; + +/** + * 数据源切面 + */ +@Aspect +@Component +public class DataSourceAsp { + + @Pointcut("execution(public * com.muyu.customer.business.controller.*Controller.*(..))") + public void pointcut(){ + + } + + @Before("pointcut()") + public void beforeMethod(){ + Long storeId = SecurityUtils.getLoginUser().getUserid(); + DynamicDataSourceHolder.setDynamicDataSourceKey("test_"+storeId); + } + + @After("pointcut()") + public void afterMethod(){ + DynamicDataSourceHolder.removeDynamicDataSourceKey(); + } + +} diff --git a/muyu-modules/muyu-customer-business/muyu-customer-business-common/src/main/java/com/muyu/customer/business/domain/Group.java b/muyu-modules/muyu-customer-business/muyu-customer-business-common/src/main/java/com/muyu/customer/business/domain/Group.java new file mode 100644 index 0000000..95e0d3b --- /dev/null +++ b/muyu-modules/muyu-customer-business/muyu-customer-business-common/src/main/java/com/muyu/customer/business/domain/Group.java @@ -0,0 +1,36 @@ +package com.muyu.customer.business.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.muyu.common.core.annotation.Excel; +import com.muyu.common.core.web.domain.BaseEntity; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.StandardException; +import lombok.experimental.SuperBuilder; + +@Data +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = true) +@TableName("group") +public class Group extends BaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * 围栏组id + */ + private Long id; + + /** + * 围栏组名称 + */ + @Excel(name = "围栏组名称") + private String groupName; + + +} diff --git a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/controller/GroupController.java b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/controller/GroupController.java new file mode 100644 index 0000000..1d9ce25 --- /dev/null +++ b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/controller/GroupController.java @@ -0,0 +1,86 @@ +package com.muyu.customer.business.controller; + +import com.muyu.common.core.domain.Result; +import com.muyu.common.core.utils.poi.ExcelUtil; +import com.muyu.common.core.web.controller.BaseController; +import com.muyu.common.core.web.page.TableDataInfo; +import com.muyu.common.log.annotation.Log; +import com.muyu.common.log.enums.BusinessType; +import com.muyu.customer.business.domain.Group; +import com.muyu.customer.business.service.GroupService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +@RestController +@RequestMapping("/group") +public class GroupController extends BaseController +{ + @Autowired + private GroupService groupService; + + /** + * 查询围栏组列表 + */ + @GetMapping("/list") + public Result> list(Group group) + { + startPage(); + List list = groupService.selectGroupList(group); + return getDataTable(list); + } + + /** + * 导出围栏组列表 + */ + @Log(title = "围栏组", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, Group group) + { + List list = groupService.selectGroupList(group); + ExcelUtil util = new ExcelUtil(Group.class); + util.exportExcel(response, list, "围栏组数据"); + } + + /** + * 获取围栏组详细信息 + */ + @GetMapping(value = "/{id}") + public Result getInfo(@PathVariable("id") Long id) + { + return success(groupService.selectGroupById(id)); + } + + /** + * 新增围栏组 + */ + @Log(title = "围栏组", businessType = BusinessType.INSERT) + @PostMapping + public Result add(@RequestBody Group group) + { + return toAjax(groupService.insertGroup(group)); + } + + /** + * 修改围栏组 + */ + @Log(title = "围栏组", businessType = BusinessType.UPDATE) + @PutMapping + public Result edit(@RequestBody Group group) + { + return toAjax(groupService.updateGroup(group)); + } + + /** + * 删除围栏组 + */ + @Log(title = "围栏组", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public Result remove(@PathVariable Long[] ids) + { + return toAjax(groupService.deleteGroupByIds(ids)); + } + +} diff --git a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/mapper/GroupMapper.java b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/mapper/GroupMapper.java new file mode 100644 index 0000000..9d80e97 --- /dev/null +++ b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/mapper/GroupMapper.java @@ -0,0 +1,58 @@ +package com.muyu.customer.business.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.muyu.customer.business.domain.Group; + +import java.util.List; + +public interface GroupMapper extends BaseMapper { + + /** + * 查询围栏组 + * + * @param id 围栏组主键 + * @return 围栏组 + */ + public Group selectGroupById(Long id); + + /** + * 查询围栏组列表 + * + * @param group 围栏组 + * @return 围栏组集合 + */ + public List selectGroupList(Group group); + + /** + * 新增围栏组 + * + * @param group 围栏组 + * @return 结果 + */ + public int insertGroup(Group group); + + /** + * 修改围栏组 + * + * @param group 围栏组 + * @return 结果 + */ + public int updateGroup(Group group); + + /** + * 删除围栏组 + * + * @param id 围栏组主键 + * @return 结果 + */ + public int deleteGroupById(Long id); + + /** + * 批量删除围栏组 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteGroupByIds(Long[] ids); + +} diff --git a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/service/GroupService.java b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/service/GroupService.java new file mode 100644 index 0000000..cfe8609 --- /dev/null +++ b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/service/GroupService.java @@ -0,0 +1,57 @@ +package com.muyu.customer.business.service; + +import com.muyu.customer.business.domain.Group; + +import java.util.List; + +public interface GroupService { + + /** + * 查询围栏组 + * + * @param id 围栏组主键 + * @return 围栏组 + */ + public Group selectGroupById(Long id); + + /** + * 查询围栏组列表 + * + * @param group 围栏组 + * @return 围栏组集合 + */ + public List selectGroupList(Group group); + + /** + * 新增围栏组 + * + * @param group 围栏组 + * @return 结果 + */ + public int insertGroup(Group group); + + /** + * 修改围栏组 + * + * @param group 围栏组 + * @return 结果 + */ + public int updateGroup(Group group); + + /** + * 批量删除围栏组 + * + * @param ids 需要删除的围栏组主键集合 + * @return 结果 + */ + public int deleteGroupByIds(Long[] ids); + + /** + * 删除围栏组信息 + * + * @param id 围栏组主键 + * @return 结果 + */ + public int deleteGroupById(Long id); + +} diff --git a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/service/impl/GroupServiceImpl.java b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/service/impl/GroupServiceImpl.java new file mode 100644 index 0000000..08e0861 --- /dev/null +++ b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/java/com/muyu/customer/business/service/impl/GroupServiceImpl.java @@ -0,0 +1,47 @@ +package com.muyu.customer.business.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.muyu.customer.business.domain.Group; +import com.muyu.customer.business.mapper.GroupMapper; +import com.muyu.customer.business.service.GroupService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class GroupServiceImpl extends ServiceImpl implements GroupService { + + @Autowired + private GroupMapper groupMapper; + @Override + public Group selectGroupById(Long id) { + return groupMapper.selectGroupById(id); + } + + @Override + public List selectGroupList(Group group) { + return groupMapper.selectGroupList(group); + } + + @Override + public int insertGroup(Group group) { + return groupMapper.insertGroup(group); + } + + @Override + public int updateGroup(Group group) { + return groupMapper.updateGroup(group); + } + + @Override + public int deleteGroupByIds(Long[] ids) { + return groupMapper.deleteGroupByIds(ids); + } + + @Override + public int deleteGroupById(Long id) { + return groupMapper.deleteGroupById(id); + } + +} diff --git a/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/resources/mapper/customerBusiness/GroupMapper.xml b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/resources/mapper/customerBusiness/GroupMapper.xml new file mode 100644 index 0000000..63bc66d --- /dev/null +++ b/muyu-modules/muyu-customer-business/muyu-customer-business-server/src/main/resources/mapper/customerBusiness/GroupMapper.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + select id, group_name, remark, create_by, create_time, update_by, update_time from `group` + + + + + + + + insert into `group` + + group_name, + remark, + create_by, + create_time, + update_by, + update_time, + + + #{groupName}, + #{remark}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update `group` + + group_name = #{groupName}, + remark = #{remark}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where id = #{id} + + + + delete from `group` where id = #{id} + + + + delete from `group` where id in + + #{id} + + +