新增部门配置模块

This commit is contained in:
clunt 2022-03-18 15:04:01 +08:00
parent 409ec52569
commit c901d276c9
6 changed files with 160 additions and 0 deletions

View File

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

View File

@ -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的路径等等
}

View File

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

View File

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

View File

@ -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数据有误!");
}
}
}

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ghy.system.mapper.SysDeptConfigMapper">
<resultMap id="SysDeptConfigResult" type="com.ghy.system.domain.SysDeptConfig">
<result property="sysDeptConfigId" column="sys_dept_config_id" />
<result property="deptId" column="dept_id" />
<result property="bannerUrl" column="banner_url" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectSysDeptConfig">
SELECT sys_dept_config_id, dept_id, banner_url, create_by, create_time, remark
FROM sys_dept_config
</sql>
<select id="selectByDeptId" parameterType="long" resultMap="SysDeptConfigResult">
<include refid="selectSysDeptConfig" />
<where>
<if test="deptId != null and deptId != 0">
AND dept_id = #{deptId}
</if>
</where>
</select>
</mapper>