更新租户授权配置允许同时配置多个

This commit is contained in:
panshuling321 2022-02-23 10:24:47 +08:00
parent 93afe83d55
commit ce6db8a2a8
4 changed files with 49 additions and 8 deletions

View File

@ -6,11 +6,15 @@ import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.page.TableDataInfo; import com.xhpc.common.core.web.page.TableDataInfo;
import com.xhpc.common.log.annotation.Log; import com.xhpc.common.log.annotation.Log;
import com.xhpc.common.log.enums.BusinessType; import com.xhpc.common.log.enums.BusinessType;
import com.xhpc.common.util.LogUserUtils;
import com.xhpc.system.api.model.LoginUser;
import com.xhpc.tenant.domain.XhpcTenantDomain; import com.xhpc.tenant.domain.XhpcTenantDomain;
import com.xhpc.tenant.service.XhpcTenantService; import com.xhpc.tenant.service.XhpcTenantService;
import org.apache.tools.ant.taskdefs.condition.Http;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -21,6 +25,9 @@ public class XhpcTenantController extends BaseController {
@Resource @Resource
XhpcTenantService tenantService; XhpcTenantService tenantService;
@Resource
LogUserUtils logUserUtils;
@GetMapping("/getPage") @GetMapping("/getPage")
public TableDataInfo getPage(String tenantId, public TableDataInfo getPage(String tenantId,
@ -46,28 +53,42 @@ public class XhpcTenantController extends BaseController {
@Log(title = "租户管理-新增租户", businessType = BusinessType.INSERT) @Log(title = "租户管理-新增租户", businessType = BusinessType.INSERT)
@PostMapping("/detail") @PostMapping("/detail")
public R insertNewTenant(@RequestBody XhpcTenantDomain domain){ public R insertNewTenant(HttpServletRequest request, @RequestBody XhpcTenantDomain domain){
LoginUser loginUser = logUserUtils.getLogUser(request);
domain.setCreateUser(loginUser.getUserid());
domain.setUpdateUser(loginUser.getUserid());
return R.ok(tenantService.insertTenant(domain)); return R.ok(tenantService.insertTenant(domain));
} }
@Log(title = "租户管理-更新租户信息", businessType = BusinessType.UPDATE) @Log(title = "租户管理-更新租户信息", businessType = BusinessType.UPDATE)
@PatchMapping("/detail") @PatchMapping("/detail")
public R updateTenant(@RequestBody XhpcTenantDomain domain){ public R updateTenant(HttpServletRequest request, @RequestBody XhpcTenantDomain domain){
LoginUser loginUser = logUserUtils.getLogUser(request);
domain.setCreateUser(loginUser.getUserid());
domain.setUpdateUser(loginUser.getUserid());
return R.ok(tenantService.updateTenantInfo(domain)); return R.ok(tenantService.updateTenantInfo(domain));
} }
@Log(title = "租户管理-更新租户授权配置信息", businessType = BusinessType.UPDATE) @Log(title = "租户管理-更新租户授权配置信息", businessType = BusinessType.UPDATE)
@PatchMapping("/config") @PatchMapping("/config")
public R updateTenantConfig(@RequestBody XhpcTenantDomain domain){ public R updateTenantConfig(HttpServletRequest request, @RequestBody XhpcTenantDomain domain){
LoginUser loginUser = logUserUtils.getLogUser(request);
domain.setCreateUser(loginUser.getUserid());
domain.setUpdateUser(loginUser.getUserid());
return R.ok(tenantService.updateTenantConfig(domain)); return R.ok(tenantService.updateTenantConfig(domain));
} }
@Log(title = "租户管理-更新租户状态", businessType = BusinessType.UPDATE) @Log(title = "租户管理-更新租户状态", businessType = BusinessType.UPDATE)
@PatchMapping("/status") @PatchMapping("/status")
public R updateTenantStatus(@RequestBody XhpcTenantDomain domain){ public R updateTenantStatus(HttpServletRequest request, @RequestBody XhpcTenantDomain domain){
LoginUser loginUser = logUserUtils.getLogUser(request);
domain.setCreateUser(loginUser.getUserid());
domain.setUpdateUser(loginUser.getUserid());
return R.ok(tenantService.updateTenantConfig(domain)); return R.ok(tenantService.updateTenantConfig(domain));
} }

View File

@ -2,6 +2,8 @@ package com.xhpc.tenant.domain;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
import lombok.Data; import lombok.Data;
/** /**
@ -95,5 +97,9 @@ public class XhpcTenantDomain implements Serializable {
*/ */
private Integer isDeleted; private Integer isDeleted;
// 修改信息的时候传递多参数
private List<String> tenantIds;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -63,7 +63,15 @@ public class XhpcTenantServiceImpl implements XhpcTenantService {
@Override @Override
public boolean updateTenantConfig(XhpcTenantDomain domain){ public boolean updateTenantConfig(XhpcTenantDomain domain){
return tenantMapper.updateTenantConfigByPrimaryKey(domain) > 0; if(domain.getTenantIds() != null && domain.getTenantIds().size() > 0){
for (String tenantId : domain.getTenantIds()){
domain.setTenantId(tenantId);
tenantMapper.updateTenantConfigByPrimaryKey(domain);
}
} else {
tenantMapper.updateTenantConfigByPrimaryKey(domain);
}
return true;
} }

View File

@ -61,13 +61,13 @@
</update> </update>
<insert id="insert" keyColumn="tenant_id" keyProperty="tenantId" parameterType="com.xhpc.tenant.domain.XhpcTenantDomain" useGeneratedKeys="true"> <insert id="insert" keyColumn="tenant_id" keyProperty="tenantId" parameterType="com.xhpc.tenant.domain.XhpcTenantDomain" useGeneratedKeys="true">
insert into xhpc_tenant (tenant_name, `domain`, background_url, insert into xhpc_tenant (tenant_id, tenant_name, `domain`, background_url,
linkman, contact_number, address, linkman, contact_number, address,
station_quote, station_pile_quote, expire_time, station_quote, station_pile_quote, expire_time,
create_user, create_dept, create_time, create_user, create_dept, create_time,
update_user, update_time, `status`, update_user, update_time, `status`,
is_deleted) is_deleted)
values (#{tenantName,jdbcType=VARCHAR}, #{domain,jdbcType=VARCHAR}, #{backgroundUrl,jdbcType=VARCHAR}, values (#{tenantId, jdbcType=VARCHAR}, #{tenantName,jdbcType=VARCHAR}, #{domain,jdbcType=VARCHAR}, #{backgroundUrl,jdbcType=VARCHAR},
#{linkman,jdbcType=VARCHAR}, #{contactNumber,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, #{linkman,jdbcType=VARCHAR}, #{contactNumber,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR},
#{stationQuote,jdbcType=INTEGER}, #{stationPileQuote,jdbcType=INTEGER}, #{expireTime,jdbcType=TIMESTAMP}, #{stationQuote,jdbcType=INTEGER}, #{stationPileQuote,jdbcType=INTEGER}, #{expireTime,jdbcType=TIMESTAMP},
#{createUser,jdbcType=BIGINT}, #{createDept,jdbcType=BIGINT}, sysdate(), #{createUser,jdbcType=BIGINT}, #{createDept,jdbcType=BIGINT}, sysdate(),
@ -77,6 +77,9 @@
<insert id="insertSelective" keyColumn="tenant_id" keyProperty="tenantId" parameterType="com.xhpc.tenant.domain.XhpcTenantDomain" useGeneratedKeys="true"> <insert id="insertSelective" keyColumn="tenant_id" keyProperty="tenantId" parameterType="com.xhpc.tenant.domain.XhpcTenantDomain" useGeneratedKeys="true">
insert into xhpc_tenant insert into xhpc_tenant
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="tenantId != null and tenantId !=''">
tenant_id,
</if>
<if test="tenantName != null"> <if test="tenantName != null">
tenant_name, tenant_name,
</if> </if>
@ -121,6 +124,9 @@
is_deleted is_deleted
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="tenantId != null and tenantId !=''">
#{tenantId,jdbcType=VARCHAR},
</if>
<if test="tenantName != null"> <if test="tenantName != null">
#{tenantName,jdbcType=VARCHAR}, #{tenantName,jdbcType=VARCHAR},
</if> </if>
@ -256,7 +262,7 @@
station_pile_quote = #{stationPileQuote,jdbcType=INTEGER}, station_pile_quote = #{stationPileQuote,jdbcType=INTEGER},
expire_time = #{expireTime,jdbcType=TIMESTAMP}, expire_time = #{expireTime,jdbcType=TIMESTAMP},
update_user = #{updateUser,jdbcType=BIGINT}, update_user = #{updateUser,jdbcType=BIGINT},
update_time = sysdate(), update_time = sysdate()
where tenant_id = #{tenantId,jdbcType=VARCHAR} where tenant_id = #{tenantId,jdbcType=VARCHAR}
</update> </update>