diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/system/SysDeptConfigController.java b/ghy-admin/src/main/java/com/ghy/web/controller/system/SysDeptConfigController.java new file mode 100644 index 00000000..70ff28f2 --- /dev/null +++ b/ghy-admin/src/main/java/com/ghy/web/controller/system/SysDeptConfigController.java @@ -0,0 +1,33 @@ +package com.ghy.web.controller.system; + +import com.ghy.common.core.controller.BaseController; +import com.ghy.common.core.domain.entity.SysDept; +import com.ghy.system.domain.SysDeptConfig; +import com.ghy.system.service.ISysDeptConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + + +/** + * 部门配置信息 + * + * @author clunt + */ +@Controller +@RequestMapping("/system/dept/config") +public class SysDeptConfigController extends BaseController { + + @Autowired + private ISysDeptConfigService sysDeptConfigService; + + @PostMapping("/query") + @ResponseBody + public SysDeptConfig query(SysDept dept) + { + return sysDeptConfigService.selectByDeptId(dept.getDeptId()); + } + +} diff --git a/ghy-system/src/main/java/com/ghy/system/domain/SysDeptConfig.java b/ghy-system/src/main/java/com/ghy/system/domain/SysDeptConfig.java new file mode 100644 index 00000000..a11081c5 --- /dev/null +++ b/ghy-system/src/main/java/com/ghy/system/domain/SysDeptConfig.java @@ -0,0 +1,21 @@ +package com.ghy.system.domain; + +import com.ghy.common.core.domain.BaseEntity; +import lombok.Data; + +/** + * @author clunt + * 部门配置表, 如支付账号。各个地方的图片等. + */ +@Data +public class SysDeptConfig extends BaseEntity { + + private Long sysDeptConfigId; + + private Long deptId; + + private String bannerUrl; + + // TODO 应该有很多配置才对. 例如支付第三方,logo的路径等等 + +} diff --git a/ghy-system/src/main/java/com/ghy/system/mapper/SysDeptConfigMapper.java b/ghy-system/src/main/java/com/ghy/system/mapper/SysDeptConfigMapper.java new file mode 100644 index 00000000..5bfba886 --- /dev/null +++ b/ghy-system/src/main/java/com/ghy/system/mapper/SysDeptConfigMapper.java @@ -0,0 +1,18 @@ +package com.ghy.system.mapper; + +import com.ghy.system.domain.SysDeptConfig; + +/** + * @author clunt + * 部门配置Mapper层 + */ +public interface SysDeptConfigMapper { + + + /** + * @param deptId 部门id + * @return 部门配置 + */ + public SysDeptConfig selectByDeptId(Long deptId); + +} diff --git a/ghy-system/src/main/java/com/ghy/system/service/ISysDeptConfigService.java b/ghy-system/src/main/java/com/ghy/system/service/ISysDeptConfigService.java new file mode 100644 index 00000000..792c18ae --- /dev/null +++ b/ghy-system/src/main/java/com/ghy/system/service/ISysDeptConfigService.java @@ -0,0 +1,17 @@ +package com.ghy.system.service; + +import com.ghy.system.domain.SysDeptConfig; + +/** + * @author clunt + * 部门配置Service层 + */ +public interface ISysDeptConfigService { + + /** + * @param deptId 当前登陆用户的部门id + * @return 部门配置 + */ + public SysDeptConfig selectByDeptId(Long deptId); + +} diff --git a/ghy-system/src/main/java/com/ghy/system/service/impl/SysDeptConfigServiceImpl.java b/ghy-system/src/main/java/com/ghy/system/service/impl/SysDeptConfigServiceImpl.java new file mode 100644 index 00000000..1fa47e53 --- /dev/null +++ b/ghy-system/src/main/java/com/ghy/system/service/impl/SysDeptConfigServiceImpl.java @@ -0,0 +1,39 @@ +package com.ghy.system.service.impl; + +import com.ghy.common.core.domain.entity.SysDept; +import com.ghy.common.exception.ServiceException; +import com.ghy.common.utils.StringUtils; +import com.ghy.system.domain.SysDeptConfig; +import com.ghy.system.mapper.SysDeptConfigMapper; +import com.ghy.system.mapper.SysDeptMapper; +import com.ghy.system.service.ISysDeptConfigService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * @author clunt + * 部门配置impl + */ +@Service +public class SysDeptConfigServiceImpl implements ISysDeptConfigService { + + @Resource + private SysDeptConfigMapper sysDeptConfigMapper; + + @Resource + private SysDeptMapper sysDeptMapper; + + @Override + public SysDeptConfig selectByDeptId(Long deptId) { + + SysDept dept = sysDeptMapper.selectDeptById(deptId); + if(StringUtils.isNotNull(dept) && StringUtils.isNotEmpty(dept.getAncestors())){ + Long targetDeptId = Long.parseLong(dept.getAncestors().split(",")[1]); + return sysDeptConfigMapper.selectByDeptId(targetDeptId); + }else { + throw new ServiceException("该用户的部门ID数据有误!"); + } + + } +} diff --git a/ghy-system/src/main/resources/mapper/system/SysDeptConfigMapper.xml b/ghy-system/src/main/resources/mapper/system/SysDeptConfigMapper.xml new file mode 100644 index 00000000..ede5e9f2 --- /dev/null +++ b/ghy-system/src/main/resources/mapper/system/SysDeptConfigMapper.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + SELECT sys_dept_config_id, dept_id, banner_url, create_by, create_time, remark + FROM sys_dept_config + + + + + \ No newline at end of file