新增:当前登录用户信息

This commit is contained in:
gxwebsoft
2024-04-15 12:26:41 +08:00
parent af2dcf9e3e
commit 54b9436f2c
14 changed files with 81 additions and 25 deletions
@@ -16,6 +16,7 @@ import com.gxwebsoft.common.core.security.JwtUtil;
import com.gxwebsoft.common.core.utils.RedisUtil; import com.gxwebsoft.common.core.utils.RedisUtil;
import com.gxwebsoft.common.core.web.*; import com.gxwebsoft.common.core.web.*;
import com.gxwebsoft.common.system.entity.User; import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.service.UserService;
import com.gxwebsoft.oa.entity.Company; import com.gxwebsoft.oa.entity.Company;
import com.gxwebsoft.oa.param.LinkParam; import com.gxwebsoft.oa.param.LinkParam;
import com.gxwebsoft.oa.service.LinkService; import com.gxwebsoft.oa.service.LinkService;
@@ -56,6 +57,8 @@ public class WebsiteController extends BaseController {
private LinkService linkService; private LinkService linkService;
@Resource @Resource
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Resource
private UserService userService;
@ApiOperation("获取网站信息") @ApiOperation("获取网站信息")
@GetMapping("/getSiteInfo") @GetMapping("/getSiteInfo")
@@ -63,6 +66,8 @@ public class WebsiteController extends BaseController {
final Integer tenantId = getTenantId(); final Integer tenantId = getTenantId();
String key = "SiteInfo:" + tenantId; String key = "SiteInfo:" + tenantId;
final String siteInfo = redisUtil.get(key); final String siteInfo = redisUtil.get(key);
String access_token = JwtUtil.getAccessToken(request);
System.out.println("access_token = " + access_token);
// 从缓存读取信息 // 从缓存读取信息
if(StrUtil.isNotBlank(siteInfo)){ if(StrUtil.isNotBlank(siteInfo)){
@@ -73,8 +78,6 @@ public class WebsiteController extends BaseController {
final WebsiteParam websiteParam = new WebsiteParam(); final WebsiteParam websiteParam = new WebsiteParam();
if (websiteService.count() == 0) { if (websiteService.count() == 0) {
// 请求主服务器获取租户信息 // 请求主服务器获取租户信息
String access_token = JwtUtil.getAccessToken(request);
// 链式构建请求
String result = HttpRequest.get("https://server.gxwebsoft.com/api/auth/tenant") String result = HttpRequest.get("https://server.gxwebsoft.com/api/auth/tenant")
.header("Authorization", access_token) .header("Authorization", access_token)
.header("Tenantid", tenantId.toString()) .header("Tenantid", tenantId.toString())
@@ -220,11 +223,26 @@ public class WebsiteController extends BaseController {
param.setDeleted(0); param.setDeleted(0);
param.setStatus(0); param.setStatus(0);
website.setCategoryList(articleCategoryService.listRel(param)); website.setCategoryList(articleCategoryService.listRel(param));
// 读取友情链接 // 读取友情链接
final LinkParam linkParam = new LinkParam(); final LinkParam linkParam = new LinkParam();
linkParam.setLinkType("友情链接"); linkParam.setLinkType("友情链接");
website.setLinks(linkService.listRel(linkParam)); website.setLinks(linkService.listRel(linkParam));
// 读取会员信息
if(access_token != null){
// 请求主服务器获取租户信息
String result = HttpRequest.get("https://server.gxwebsoft.com/api/auth/user")
.header("Authorization", access_token)
.header("Tenantid", tenantId.toString())
.timeout(20000)//超时,毫秒
.execute().body();
JSONObject jsonObject = JSONObject.parseObject(result);
final String data = jsonObject.getString("data");
final User user = JSONObject.parseObject(data, User.class);
website.setUserInfo(user);
}
// 授权信息 // 授权信息
HashMap<String, Object> config = new HashMap<>(); HashMap<String, Object> config = new HashMap<>();
config.put("LICENSE_CODE", ""); config.put("LICENSE_CODE", "");
@@ -57,11 +57,6 @@ public class WebsiteFieldController extends BaseController {
@ApiOperation("添加应用参数") @ApiOperation("添加应用参数")
@PostMapping() @PostMapping()
public ApiResult<?> save(@RequestBody WebsiteField websiteField) { public ApiResult<?> save(@RequestBody WebsiteField websiteField) {
// 记录当前登录用户id
User loginUser = getLoginUser();
if (loginUser != null) {
websiteField.setUserId(loginUser.getUserId());
}
if (websiteFieldService.save(websiteField)) { if (websiteFieldService.save(websiteField)) {
return success("添加成功"); return success("添加成功");
} }
@@ -1,6 +1,8 @@
package com.gxwebsoft.cms.entity; package com.gxwebsoft.cms.entity;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.common.system.entity.UserInfo;
import com.gxwebsoft.oa.entity.Link; import com.gxwebsoft.oa.entity.Link;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@@ -153,6 +155,10 @@ public class Website implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private List<Link> links; private List<Link> links;
@ApiModelProperty(value = "用户信息")
@TableField(exist = false)
private User userInfo;
@ApiModelProperty(value = "配置信息") @ApiModelProperty(value = "配置信息")
@TableField(exist = false) @TableField(exist = false)
private Object config; private Object config;
@@ -31,18 +31,15 @@ public class WebsiteField implements Serializable {
@ApiModelProperty(value = "网站ID") @ApiModelProperty(value = "网站ID")
private Integer websiteId; private Integer websiteId;
@ApiModelProperty(value = "名称") @ApiModelProperty(value = "参数名称")
private String name; private String name;
@ApiModelProperty(value = "参数值")
private String value;
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String comments; private String comments;
@ApiModelProperty(value = "用户ID")
private Integer userId;
@ApiModelProperty(value = "状态, 0正常, 1删除")
private Integer status;
@ApiModelProperty(value = "排序(数字越小越靠前)") @ApiModelProperty(value = "排序(数字越小越靠前)")
private Integer sortNumber; private Integer sortNumber;
@@ -47,7 +47,7 @@
<if test="param.goodsCategoryId != null"> <if test="param.goodsCategoryId != null">
AND a.goods_category_id = #{param.goodsCategoryId} AND a.goods_category_id = #{param.goodsCategoryId}
</if> </if>
<if test="param.goods_id != null"> <if test="param.goodsId != null">
AND a.goods_id = #{param.goodsId} AND a.goods_id = #{param.goodsId}
</if> </if>
<if test="param.active != null"> <if test="param.active != null">
@@ -19,12 +19,6 @@
<if test="param.comments != null"> <if test="param.comments != null">
AND a.comments LIKE CONCAT('%', #{param.comments}, '%') AND a.comments LIKE CONCAT('%', #{param.comments}, '%')
</if> </if>
<if test="param.userId != null">
AND a.user_id = #{param.userId}
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.sortNumber != null"> <if test="param.sortNumber != null">
AND a.sort_number = #{param.sortNumber} AND a.sort_number = #{param.sortNumber}
</if> </if>
@@ -36,10 +36,6 @@ public class WebsiteFieldParam extends BaseParam {
@ApiModelProperty(value = "备注") @ApiModelProperty(value = "备注")
private String comments; private String comments;
@ApiModelProperty(value = "用户ID")
@QueryField(type = QueryType.EQ)
private Integer userId;
@ApiModelProperty(value = "状态, 0正常, 1删除") @ApiModelProperty(value = "状态, 0正常, 1删除")
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer status; private Integer status;
@@ -17,6 +17,7 @@ import com.gxwebsoft.oa.service.AppService;
import com.gxwebsoft.oa.service.AppUserService; import com.gxwebsoft.oa.service.AppUserService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
@@ -69,12 +70,22 @@ public class AppController extends BaseController {
new LambdaQueryWrapper<App>() new LambdaQueryWrapper<App>()
.eq(App::getAppStatus, "已下架") .eq(App::getAppStatus, "已下架")
); );
Integer totalNum6 = appService.count(
new LambdaQueryWrapper<App>()
.eq(App::getShowCase,true)
);
Integer totalNum7 = appService.count(
new LambdaQueryWrapper<App>()
.eq(App::getShowIndex, true)
);
data.put("totalNum", totalNum); data.put("totalNum", totalNum);
data.put("totalNum2", totalNum2); data.put("totalNum2", totalNum2);
data.put("totalNum3", totalNum3); data.put("totalNum3", totalNum3);
data.put("totalNum4", totalNum4); data.put("totalNum4", totalNum4);
data.put("totalNum5", totalNum5); data.put("totalNum5", totalNum5);
data.put("totalNum6", totalNum6);
data.put("totalNum7", totalNum7);
return success(data); return success(data);
} }
@@ -114,6 +125,7 @@ public class AppController extends BaseController {
return appPageResult; return appPageResult;
} }
@PreAuthorize("hasAuthority('oa:app:list')")
@ApiOperation("查询全部应用管理记录表") @ApiOperation("查询全部应用管理记录表")
@GetMapping() @GetMapping()
public ApiResult<List<App>> list(AppParam param) { public ApiResult<List<App>> list(AppParam param) {
@@ -201,6 +201,12 @@ public class App implements Serializable {
@ApiModelProperty(value = "是否作为案例展示") @ApiModelProperty(value = "是否作为案例展示")
private Boolean showCase; private Boolean showCase;
@ApiModelProperty(value = "是否推荐")
private Boolean recommend;
@ApiModelProperty(value = "是否显示在首页")
private Boolean showIndex;
@ApiModelProperty(value = "排序(数字越小越靠前)") @ApiModelProperty(value = "排序(数字越小越靠前)")
private Integer sortNumber; private Integer sortNumber;
@@ -20,6 +20,12 @@
<if test="param.showCase != null"> <if test="param.showCase != null">
AND a.show_case = #{param.showCase} AND a.show_case = #{param.showCase}
</if> </if>
<if test="param.recommend != null">
AND a.recommend = #{param.recommend}
</if>
<if test="param.showIndex != null">
AND a.show_index = #{param.showIndex}
</if>
<if test="param.parentId != null"> <if test="param.parentId != null">
AND a.parent_id = #{param.parentId} AND a.parent_id = #{param.parentId}
</if> </if>
@@ -225,4 +225,12 @@ public class AppParam extends BaseParam {
@TableField(exist = false) @TableField(exist = false)
private Boolean showCase; private Boolean showCase;
@ApiModelProperty(value = "是否推荐")
@TableField(exist = false)
private Boolean recommend;
@ApiModelProperty(value = "是否显示到首页")
@TableField(exist = false)
private Boolean showIndex;
} }
@@ -52,6 +52,12 @@ public class Goods implements Serializable {
@ApiModelProperty(value = "分类ID") @ApiModelProperty(value = "分类ID")
private Integer categoryId; private Integer categoryId;
@ApiModelProperty(value = "一级分类")
private String categoryParent;
@ApiModelProperty(value = "二级分类")
private String categoryChildren;
@ApiModelProperty(value = "规格") @ApiModelProperty(value = "规格")
private String specs; private String specs;
@@ -25,6 +25,12 @@
<if test="param.categoryId != null"> <if test="param.categoryId != null">
AND a.category_id = #{param.categoryId} AND a.category_id = #{param.categoryId}
</if> </if>
<if test="param.categoryParent != null">
AND a.category_parent LIKE CONCAT('%', #{param.categoryParent}, '%')
</if>
<if test="param.categoryChildren != null">
AND a.category_children LIKE CONCAT('%', #{param.categoryChildren}, '%')
</if>
<if test="param.specs != null"> <if test="param.specs != null">
AND a.specs LIKE CONCAT('%', #{param.specs}, '%') AND a.specs LIKE CONCAT('%', #{param.specs}, '%')
</if> </if>
@@ -44,6 +44,12 @@ public class GoodsParam extends BaseParam {
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer categoryId; private Integer categoryId;
@ApiModelProperty(value = "一级分类")
private String categoryParent;
@ApiModelProperty(value = "二级分类")
private String categoryChildren;
@ApiModelProperty(value = "规格") @ApiModelProperty(value = "规格")
private String specs; private String specs;