Commit 19b10670 authored by “yiyousong”'s avatar “yiyousong”
parents 62ee304d 4e6670e5
......@@ -29,7 +29,7 @@ public interface IApiBaseManagerFeign extends IFeign {
* @param query
* @return
*/
@PostMapping(value = "/dept/list")
@PostMapping(value = "/dept/interlist")
String getDeptByQuery(@RequestBody DeptPdu query);
}
......
......@@ -26,7 +26,7 @@ public interface IDeptFeign extends IFeign {
* @param deptPdu
* @return
*/
@PostMapping(value = "/dept/list")
@PostMapping(value = "/dept/interlist")
Rest<RespData<List<DeptPdu>>> list(@RequestBody DeptPdu deptPdu);
......@@ -36,7 +36,7 @@ public interface IDeptFeign extends IFeign {
* @param id
* @return
*/
@GetMapping(value = "/dept/info")
@GetMapping(value = "/dept/interinfo")
Rest<DeptPdu> info(@RequestParam(value = "id") Long id);
/**
......
......@@ -31,7 +31,7 @@ public interface IDeviceFeign extends IFeign {
* @param devicePdu
* @return
*/
@PostMapping(value = "/device/list")
@PostMapping(value = "/device/interlist")
Rest<RespData<List<DevicePdu>>> list(@RequestBody DevicePdu devicePdu);
......@@ -41,7 +41,7 @@ public interface IDeviceFeign extends IFeign {
* @param id
* @return
*/
@GetMapping(value = "/device/info")
@GetMapping(value = "/device/interinfo")
Rest<DevicePdu> info(@RequestParam(value = "id") Long id);
......
......@@ -25,7 +25,7 @@ public interface IFirmFeign extends IFeign {
* @param firmPdu
* @return
*/
@PostMapping(value = "/firm/list")
@PostMapping(value = "/firm/interlist")
Rest<RespData<List<FirmPdu>>> list(@RequestBody FirmPdu firmPdu);
......@@ -35,7 +35,7 @@ public interface IFirmFeign extends IFeign {
* @param id
* @return
*/
@GetMapping(value = "/firm/info")
@GetMapping(value = "/firm/interinfo")
Rest<FirmPdu> info(@RequestParam(value = "id") Long id);
/**
......
......@@ -29,7 +29,7 @@ public interface ISiteFeign extends IFeign {
* @param sitePdu
* @return
*/
@PostMapping(value = "/site/list")
@PostMapping(value = "/site/interlist")
Rest<RespData<List<SitePdu>>> list(@RequestBody SitePdu sitePdu);
......@@ -39,7 +39,7 @@ public interface ISiteFeign extends IFeign {
* @param id
* @return
*/
@GetMapping(value = "/site/info")
@GetMapping(value = "/site/interinfo")
Rest<SitePdu> info(@RequestParam(value = "id") Long id);
/**
......
......@@ -26,7 +26,7 @@ public interface ISiteMatterFeign extends IFeign {
* @param siteMatterPdu
* @return
*/
@PostMapping(value = "/site/matter/list")
@PostMapping(value = "/site/matter/interlist")
Rest<RespData<List<SiteMatterPdu>>> list(@RequestBody SiteMatterPdu siteMatterPdu);
......@@ -36,7 +36,7 @@ public interface ISiteMatterFeign extends IFeign {
* @param id
* @return
*/
@GetMapping(value = "/site/matter/info")
@GetMapping(value = "/site/matter/interinfo")
Rest<SiteMatterPdu> info(@RequestParam(value = "id") Long id);
/**
......
......@@ -25,7 +25,7 @@ public interface ISkinBaseFeign extends IFeign {
* @param skinBasePdu
* @return
*/
@PostMapping(value = "/skin/base/list")
@PostMapping(value = "/skin/base/interlist")
Rest<RespData<List<SkinBasePdu>>> list(@RequestBody SkinBasePdu skinBasePdu);
......
......@@ -38,7 +38,7 @@ public interface IUserFeign extends IFeign {
* @param id
* @return
*/
@GetMapping(value = "/user/info")
@GetMapping(value = "/user/interinfo")
Rest<UserPdu> info(@RequestParam(value = "id") Long id);
/**
......
......@@ -7,7 +7,13 @@ import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.IUser;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.StringUtils;
import com.mortals.xhx.base.system.resource.service.ResourceService;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.key.RedisKey;
import com.mortals.xhx.common.utils.MenuEncodeUtil;
import com.mortals.xhx.feign.user.IUserFeign;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
......@@ -17,11 +23,13 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Primary;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* token验证处理
......@@ -33,6 +41,10 @@ import java.util.Map;
@Order(1)
@Slf4j
public class AuthTokenServiceImpl implements IAuthTokenService {
@Autowired
private UserService userService;
// 令牌自定义标识
@Value("${token.header:Authorization}")
private String header;
......@@ -70,6 +82,10 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
@Autowired
private ICacheService cacheService;
@Autowired
private ResourceService resourceService;
/**
* 获取信息
*
......@@ -82,22 +98,39 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
String token = getToken(request);
if (StringUtils.isNotEmpty(token)) {
try {
boolean signed = Jwts.parser().isSigned(token);
if (!signed) {
log.error("token非法!=>{}", token);
return null;
}
Claims claims = parseToken(token);
String uuid = (String) claims.get(SysConstains.LOGIN_USER_KEY);
String userKey = getTokenKey(uuid);
cacheService.select(portalDb);
String userStr = cacheService.get(userKey);
//刷新token时间
UserEntity userEntity = JSONObject.parseObject(userStr, UserEntity.class);
if (!ObjectUtils.isEmpty(userEntity)) {
verifyToken(userEntity);
}
cacheService.select(db);
// Rest<String> rest = userFeign.getToken(userKey);
// String userStr = rest.getData();
if (StringUtils.isNotEmpty(userStr)) {
UserEntity userEntity = JSONObject.parseObject(userStr, UserEntity.class);
userEntity.setToken(token);
if (!ObjectUtils.isEmpty(userEntity)) {
UserEntity temp = userService.getExtCache(userEntity.getLoginName());
if (!ObjectUtils.isEmpty(temp)) {
userEntity.setId(temp.getId());
}
//更新resource 路径
String menuUrlCode = cacheService.hget(RedisKey.KEY_USER_MENU_CACHE, userEntity.getId().toString(), String.class);
if (ObjectUtils.isEmpty(menuUrlCode)) {
Set<String> urls = resourceService.findUrlSetByUserId(userEntity.getId());
menuUrlCode = MenuEncodeUtil.generateMenuUrlCode(urls);
cacheService.hset(RedisKey.KEY_USER_MENU_CACHE, userEntity.getId().toString(), menuUrlCode);
}
userEntity.setMenuUrl(menuUrlCode);
return userEntity;
}
} catch (Exception e) {
log.error("解析jwt token异常!", e);
log.error("解析jwt token异常!,token:{}",token, e);
return null;
}
}
......@@ -151,8 +184,8 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
public void verifyToken(IUser user) {
long expireTime = user.getExpireTime();
long currentTime = System.currentTimeMillis();
if (expireTime - currentTime <= SECOND_MINUTE_TEN) {
log.info("不足十分钟,刷新过期时间");
if (expireTime - currentTime <= SECOND_MINUTE_TEN*1000) {
log.info("不足十分钟,刷新过期时间");
refreshToken(user);
}
}
......@@ -164,7 +197,7 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
*/
public void refreshToken(IUser user) {
//user.setLoginTime(System.currentTimeMillis());
user.setExpireTime(user.getLoginTime() == null ? System.currentTimeMillis() : user.getLoginTime() + expireTime * SECOND_MINUTE);
user.setExpireTime(user.getLoginTime() == null ? System.currentTimeMillis() : user.getLoginTime() + expireTime * SECOND_MINUTE*1000);
// 根据uuid将user缓存
String userKey = getTokenKey(user.getToken());
//设置有效时间 单位秒
......@@ -231,4 +264,11 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
private String getTokenKey(String uuid) {
return SysConstains.LOGIN_TOKEN_KEY + uuid;
}
public static void main(String[] args) {
// boolean signed = Jwts.parser().isSigned("123");
boolean signed = Jwts.parser().isSigned("eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJuaW5naGFvLm5ldCIsImV4cCI6IjE0Mzg5NTU0NDUiLCJuYW1lIjoid2FuZ2hhbyIsImFkbWluIjp0cnVlfQ.SwyHTEx_RQppr97g4J5lKXtabJecpejuef8AqKYMAJc");
System.out.println(signed);
}
}
/**
* 文件:ResourceController.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.resource.web;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.code.UserType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.resource.model.ResourceEntity;
import com.mortals.xhx.base.system.resource.service.ResourceService;
import com.mortals.xhx.common.code.AuthType;
import com.mortals.xhx.common.code.SourceType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* <p>Title: 资源信息</p>
* <p>Description: ResourceController </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
* 资源信息
*
* @author: zxfei
* @date: 2022/5/7 15:27
*/
@Slf4j
@RestController
@RequestMapping("resource")
public class ResourceController extends BaseCRUDJsonMappingController<ResourceService,ResourceForm,ResourceEntity,Long> {
public class ResourceController extends BaseCRUDJsonBodyMappingController<ResourceService,ResourceEntity,Long> {
public ResourceController(){
super.setFormClass(ResourceForm.class);
super.setModuleDesc("资源信息");
}
@Override
protected void init(HttpServletRequest request, HttpServletResponse response, ResourceForm form,
Map<String, Object> model, Context context) {
protected void init(Map<String, Object> model, Context context) {
Map<String, Object> statsus = new HashMap<String, Object>();
statsus.put("authType", AuthType.getEnumMap());
statsus.put("sourceType", SourceType.getEnumMap());
......@@ -57,7 +44,6 @@ public class ResourceController extends BaseCRUDJsonMappingController<ResourceSe
statsus.put("userType", UserType.findByValue(getCurUser().getUserType()));
}
model.put(KEY_RESULT_DICT, statsus);
super.init(request, response, form, model, context);
}
/**
......
/**
* 文件:ResourceForm.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.resource.web;
import com.mortals.framework.web.BaseCRUDFormLong;
import com.mortals.xhx.base.system.resource.model.ResourceEntity;
import com.mortals.xhx.base.system.resource.model.ResourceQuery;
/**
* <p>Title: 资源信息</p>
* <p>Description: ResourceForm </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class ResourceForm extends BaseCRUDFormLong<ResourceEntity> {
private ResourceEntity entity = new ResourceEntity();
private ResourceQuery query = new ResourceQuery();
public ResourceForm(){
}
@Override
public ResourceEntity getEntity() {
return entity;
}
public void setEntity(ResourceEntity entity) {
this.entity = entity;
}
@Override
public ResourceQuery getQuery() {
return query;
}
public void setQuery(ResourceQuery query) {
this.query = query;
}
}
\ No newline at end of file
/**
* 文件:RoleAuthServiceImpl.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
* 文件:RoleAuthServiceImpl.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.service.impl;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.util.DataUtil;
import com.mortals.xhx.base.system.resource.service.ResourceService;
import com.mortals.xhx.base.system.role.dao.RoleAuthDao;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.model.RoleAuthQuery;
import com.mortals.xhx.base.system.role.service.RoleAuthService;
import com.mortals.xhx.common.key.RedisKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.mortals.xhx.common.utils.MenuEncodeUtil.generateMenuUrlCode;
/**
* <p>Title: 角色资源权限</p>
* <p>Description: RoleAuthServiceImpl service接口 </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @author
* @version 1.0.0
*/
@Service("roleAuthService")
public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao,RoleAuthEntity,Long> implements RoleAuthService {
public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, RoleAuthEntity, Long> implements RoleAuthService {
@Autowired
private ICacheService cacheService;
@Autowired
private ResourceService resourceService;
@Override
public void doDistributionSource(RoleAuthQuery query) {
......@@ -49,6 +56,18 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao,Rol
list.add(entity);
}
this.dao.insertBatch(list);
this.updateUserMenuUrlCache();
}
private void updateUserMenuUrlCache() {
//更新用户菜单
Set<String> hkeys = cacheService.hkeys(RedisKey.KEY_USER_MENU_CACHE);
for (String userId : hkeys) {
Set<String> urls = resourceService.findUrlSetByUserId(DataUtil.converStr2Long(userId, 0L));
String menuUrlCode = generateMenuUrlCode(urls);
cacheService.hset(RedisKey.KEY_USER_MENU_CACHE, userId, menuUrlCode);
}
}
}
\ No newline at end of file
/**
* 文件:RoleServiceImpl.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
* 文件:RoleServiceImpl.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.base.system.role.dao.RoleDao;
import com.mortals.xhx.base.system.role.model.RoleEntity;
import com.mortals.xhx.base.system.role.model.*;
import com.mortals.xhx.base.system.role.service.RoleAuthService;
import com.mortals.xhx.base.system.role.service.RoleService;
import com.mortals.xhx.base.system.role.service.RoleUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Arrays;
/**
* <p>Title: 角色信息</p>
* <p>Description: RoleServiceImpl service接口 </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @author
* @version 1.0.0
*/
@Service("roleService")
public class RoleServiceImpl extends AbstractCRUDServiceImpl<RoleDao,RoleEntity,Long> implements RoleService {
@Autowired
private RoleAuthService roleAuthService;
@Autowired
private RoleUserService roleUserService;
@Override
protected void removeAfter(Long[] ids, Context context, int result) throws AppException {
//删除关联角色
Arrays.asList(ids).stream().peek(roleId->{
RoleAuthQuery roleAuthQuery = new RoleAuthQuery();
roleAuthQuery.setRoleId(roleId);
Long[] roleAuthIds = roleAuthService.find(roleAuthQuery).stream().map(RoleAuthEntity::getId).toArray(Long[]::new);
roleAuthService.remove(roleAuthIds,context);
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setRoleId(roleId);
Long[] roleUserIds = roleUserService.find(roleUserQuery).stream().map(RoleUserEntity::getId).toArray(Long[]::new);
roleUserService.remove(roleUserIds,context);
}).count();
super.removeAfter(ids, context, result);
}
}
\ No newline at end of file
/**
* 文件:RoleUserServiceImpl.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
* 文件:RoleUserServiceImpl.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.service.impl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.util.DataUtil;
import com.mortals.xhx.base.system.resource.service.ResourceService;
import com.mortals.xhx.base.system.role.dao.RoleUserDao;
import com.mortals.xhx.base.system.role.model.RoleUserEntity;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
import com.mortals.xhx.base.system.role.service.RoleUserService;
import com.mortals.xhx.common.key.RedisKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import static com.mortals.xhx.common.utils.MenuEncodeUtil.generateMenuUrlCode;
/**
* <p>Title: 角色用户</p>
* <p>Description: RoleUserServiceImpl service接口 </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @author
* @version 1.0.0
*/
@Service("roleUserService")
public class RoleUserServiceImpl extends AbstractCRUDServiceImpl<RoleUserDao,RoleUserEntity,Long> implements RoleUserService {
public class RoleUserServiceImpl extends AbstractCRUDServiceImpl<RoleUserDao, RoleUserEntity, Long> implements RoleUserService {
@Autowired
private ICacheService cacheService;
@Autowired
private ResourceService resourceService;
@Override
public void doDistributionUser(RoleUserQuery query) {
......@@ -49,6 +60,7 @@ public class RoleUserServiceImpl extends AbstractCRUDServiceImpl<RoleUserDao,Rol
list.add(rolseUser);
}
this.dao.insertBatch(list);
updateUserMenuUrlCache();
}
@Override
......@@ -67,6 +79,22 @@ public class RoleUserServiceImpl extends AbstractCRUDServiceImpl<RoleUserDao,Rol
list.add(rolseUser);
}
this.dao.insertBatch(list);
updateUserMenuUrlCache();
}
@Override
protected void removeAfter(Long[] ids, Context context, int result) throws AppException {
updateUserMenuUrlCache();
}
private void updateUserMenuUrlCache() {
//更新用户菜单
Set<String> hkeys = cacheService.hkeys(RedisKey.KEY_USER_MENU_CACHE);
for (String userId : hkeys) {
Set<String> urls = resourceService.findUrlSetByUserId(DataUtil.converStr2Long(userId, 0L));
String menuUrlCode = generateMenuUrlCode(urls);
cacheService.hset(RedisKey.KEY_USER_MENU_CACHE, userId, menuUrlCode);
}
}
}
\ No newline at end of file
/**
* 文件:RoleAuthController.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.model.RoleAuthQuery;
import com.mortals.xhx.base.system.role.service.RoleAuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.service.RoleAuthService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* <p>Title: 角色资源权限</p>
* <p>Description: RoleAuthController </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
* 角色资源权限
*
* @author: zxfei
* @date: 2022/5/7 15:19
*/
@Slf4j
@RestController
@RequestMapping("role/auth")
public class RoleAuthController extends BaseCRUDJsonMappingController<RoleAuthService,RoleAuthForm,RoleAuthEntity,Long> {
public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAuthService, RoleAuthEntity, Long> {
public RoleAuthController() {
super.setModuleDesc("角色资源权限");
}
public RoleAuthController(){
super.setFormClass(RoleAuthForm.class);
super.setModuleDesc("角色资源权限");
}
/**
* 分配资源
*/
@PostMapping(value = "distributionSource")
public String distributionUser(@RequestBody RoleAuthQuery query) {
try {
service.doDistributionSource(query);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString();
} catch (Exception e) {
log.error("分配角色资源错误", e);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
/**
* 分配资源
*/
@PostMapping(value = "distributionSource")
public String distributionUser(HttpServletRequest request, HttpServletResponse response, RoleAuthForm form) {
try {
service.doDistributionSource(form.getQuery());
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString();
} catch (Exception e) {
log.error("分配角色资源错误", e);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
}
\ No newline at end of file
/**
* 文件:RoleAuthForm.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
import com.mortals.framework.web.BaseCRUDFormLong;
import com.mortals.xhx.base.system.role.model.RoleAuthEntity;
import com.mortals.xhx.base.system.role.model.RoleAuthQuery;
/**
* <p>Title: 角色资源权限</p>
* <p>Description: RoleAuthForm </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class RoleAuthForm extends BaseCRUDFormLong<RoleAuthEntity> {
private RoleAuthEntity entity = new RoleAuthEntity();
private RoleAuthQuery query = new RoleAuthQuery();
public RoleAuthForm(){
}
@Override
public RoleAuthEntity getEntity() {
return entity;
}
public void setEntity(RoleAuthEntity entity) {
this.entity = entity;
}
@Override
public RoleAuthQuery getQuery() {
return query;
}
public void setQuery(RoleAuthQuery query) {
this.query = query;
}
}
\ No newline at end of file
/**
* 文件:RoleController.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
......@@ -12,34 +5,28 @@ import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.IBaseEnum;
import com.mortals.framework.common.code.UserType;
import com.mortals.framework.model.Context;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.role.model.RoleEntity;
import com.mortals.xhx.base.system.role.model.RoleUserEntity;
import com.mortals.xhx.base.system.role.service.RoleService;
import com.mortals.xhx.base.system.role.service.RoleUserService;
import com.mortals.xhx.common.code.RoleType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>Title: 角色信息</p>
* <p>Description: RoleController </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
* 角色信息
*
* @author: zxfei
* @date: 2022/5/7 15:15
*/
@RestController
@RequestMapping("role")
......@@ -49,23 +36,29 @@ public class RoleController extends BaseCRUDJsonBodyMappingController<RoleServic
private RoleUserService roleUserService;
public RoleController(){
super.setFormClass(RoleForm.class);
super.setModuleDesc("角色信息");
}
@Override
protected void init(Map<String, Object> model, Context context) {
this.addDict(model,"userType", IBaseEnum.getEnumMap(UserType.class));
this.addDict(model,"roleType", RoleType.getEnumMap());
super.init(model, context);
Map<String, Object> status = new HashMap<>();
status.put("userType", IBaseEnum.getEnumMap(UserType.class));
status.put("roleType", RoleType.getEnumMap());
model.put(KEY_RESULT_DICT, status);
}
/**
* 根据用户id获取角色名称
* @param userId
* @return
*/
@PostMapping("roleNameByUserId")
public String getRoleNameByUserId(@RequestBody RoleUserEntity query) {
public String getRoleNameByUserId(@RequestParam(value = "userId") Long userId) {
try{
JSONObject ret = new JSONObject();
RoleUserEntity roleUserEntity = new RoleUserEntity();
roleUserEntity.setUserId(query.getUserId());
roleUserEntity.setUserId(userId);
List<RoleUserEntity> find = roleUserService.find(roleUserEntity, new Context());
List<RoleEntity> model = new ArrayList<>();
if(find.size() > 0){
......
/**
* 文件:RoleForm.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
import com.mortals.framework.web.BaseCRUDFormLong;
import com.mortals.xhx.base.system.role.model.RoleEntity;
import com.mortals.xhx.base.system.role.model.RoleQuery;
/**
* <p>Title: 角色信息</p>
* <p>Description: RoleForm </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class RoleForm extends BaseCRUDFormLong<RoleEntity> {
private RoleEntity entity = new RoleEntity();
private RoleQuery query = new RoleQuery();
/** 用户ID */
private Long userId;
public RoleForm(){
}
@Override
public RoleEntity getEntity() {
return entity;
}
public void setEntity(RoleEntity entity) {
this.entity = entity;
}
@Override
public RoleQuery getQuery() {
return query;
}
public void setQuery(RoleQuery query) {
this.query = query;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
}
\ No newline at end of file
/**
* 文件:RoleUserController.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
import com.alibaba.fastjson.JSONObject;
......@@ -14,23 +7,22 @@ import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.framework.model.Context;
import org.apache.commons.beanutils.MethodUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.role.model.RoleEntity;
import com.mortals.xhx.base.system.role.model.RoleUserEntity;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
import com.mortals.xhx.base.system.role.service.RoleService;
import com.mortals.xhx.base.system.role.service.RoleUserService;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService;
import org.apache.commons.beanutils.MethodUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -38,29 +30,49 @@ import java.util.Set;
import java.util.stream.Collectors;
/**
* <p>Title: 角色用户</p>
* <p>Description: RoleUserController </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
* 角色用户
*
* @author: zxfei
* @date: 2022/5/7 15:15
*/
@RestController
@RequestMapping("role/user")
public class RoleUserController extends BaseCRUDJsonMappingController<RoleUserService,RoleUserForm,RoleUserEntity,Long> {
public class RoleUserController extends BaseCRUDJsonBodyMappingController<RoleUserService, RoleUserEntity, Long> {
@Autowired
private RoleService roleService;
@Autowired
private UserService userService;
public RoleUserController() {
super.setModuleDesc("角色用户");
}
@Autowired
private RoleService roleService;
@Autowired
private UserService userService;
@Override
protected void init(Map<String, Object> model, Context context) {
Map<String, Object> status = new HashMap<>(3);
status.put("roleId", roleService.find(new RoleEntity(), null).stream()
.collect(Collectors.toMap(e -> e.getId().toString(), RoleEntity::getName)));
List<RoleUserEntity> roleUserList = (List<RoleUserEntity>) model.get(SysConstains.RESULT_KEY);
if (roleUserList != null && roleUserList.size() > 0) {
List<Long> userIdsList = roleUserList.stream().map(RoleUserEntity::getUserId).collect(Collectors.toList());
List<UserEntity> userEntityList = userService.find(getQuery(UserQuery.class,
Sets.newHashSet("id", "realName", "loginName"), userIdsList.toArray(new Long[userIdsList.size()])), null);
if (userEntityList != null) {
status.put("userReNameMap",
userEntityList.stream().collect(Collectors.toMap(e -> e.getId().toString(), UserEntity::getRealName)));
status.put("userId",
userEntityList.stream().collect(Collectors.toMap(e -> e.getId().toString(), UserEntity::getLoginName)));
}
}
model.put(KEY_RESULT_DICT, status);
}
public RoleUserController(){
super.setFormClass(RoleUserForm.class);
super.setModuleDesc("角色用户");
}
/**
/**
* 获取查询对象,限制查询返回的结果只包含ID和名称
*
* @param IdList
* @return
*/
......@@ -79,65 +91,42 @@ public class RoleUserController extends BaseCRUDJsonMappingController<RoleUserSe
}
}
@SuppressWarnings("unchecked")
@Override
protected void init(HttpServletRequest request, HttpServletResponse response, RoleUserForm form, Map<String, Object> model, Context context) {
Map<String, Object> status = new HashMap<>(3);
status.put("roleId", roleService.find(new RoleEntity(), null).stream()
.collect(Collectors.toMap(e -> e.getId().toString(), RoleEntity::getName)));
List<RoleUserEntity> roleUserList = (List<RoleUserEntity>) model.get(SysConstains.RESULT_KEY);
if(roleUserList!=null && roleUserList.size()>0) {
List<Long> userIdsList = roleUserList.stream().map(RoleUserEntity::getUserId).collect(Collectors.toList());
List<UserEntity> userEntityList = userService.find(getQuery(UserQuery.class,
Sets.newHashSet("id", "realName","loginName"), userIdsList.toArray(new Long[userIdsList.size()])), null);
if(userEntityList!=null) {
status.put("userReNameMap",
userEntityList.stream().collect(Collectors.toMap(e -> e.getId().toString(), UserEntity::getRealName)));
status.put("userId",
userEntityList.stream().collect(Collectors.toMap(e -> e.getId().toString(), UserEntity::getLoginName)));
}
}
model.put(KEY_RESULT_DICT, status);
super.init(request, response, form, model, context);
}
/**
* 分配用户
*/
@PostMapping(value = "distributionUser")
public String distributionUser(HttpServletRequest request, HttpServletResponse response, RoleUserForm form) {
try {
service.doDistributionUser(form.getQuery());
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString();
} catch (Exception e) {
log.error("分配用户错误", e);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
/**
* 分配用户
*/
@PostMapping(value = "distributionUser")
public String distributionUser(@RequestBody RoleUserQuery query) {
try {
service.doDistributionUser(query);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString();
} catch (Exception e) {
log.error("分配用户错误", e);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
/**
* 分配角色
*/
@PostMapping(value = "distributionRole")
public String distributionRole(HttpServletRequest request, HttpServletResponse response, RoleUserForm form) {
try {
service.doDistributionRole(form.getQuery());
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString();
} catch (Exception e) {
log.error("分配角色错误", e);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
/**
* 分配角色
*/
@PostMapping(value = "distributionRole")
public String distributionRole(@RequestBody RoleUserQuery query) {
try {
service.doDistributionRole(query);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
return ret.toJSONString();
} catch (Exception e) {
log.error("分配角色错误", e);
JSONObject ret = new JSONObject();
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, super.convertException(e));
return ret.toJSONString();
}
}
}
\ No newline at end of file
/**
* 文件:RoleUserForm.java
* 版本:1.0.0
* 日期:
* Copyright &reg;
* All right reserved.
*/
package com.mortals.xhx.base.system.role.web;
import com.mortals.framework.web.BaseCRUDFormLong;
import com.mortals.xhx.base.system.role.model.RoleUserEntity;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
/**
* <p>Title: 角色用户</p>
* <p>Description: RoleUserForm </p>
* <p>Copyright: Copyright &reg; </p>
* <p>Company: </p>
* @author
* @version 1.0.0
*/
public class RoleUserForm extends BaseCRUDFormLong<RoleUserEntity> {
private RoleUserEntity entity = new RoleUserEntity();
private RoleUserQuery query = new RoleUserQuery();
public RoleUserForm(){
}
@Override
public RoleUserEntity getEntity() {
return entity;
}
public void setEntity(RoleUserEntity entity) {
this.entity = entity;
}
@Override
public RoleUserQuery getQuery() {
return query;
}
public void setQuery(RoleUserQuery query) {
this.query = query;
}
}
\ No newline at end of file
......@@ -36,4 +36,14 @@ public class UserEntityExt extends BaseEntityLong {
private String oldPassword;
private String newPassword;
private String siteIds;
/**
* 菜单栏
*/
private String menuUrl;
/**
* 所属区域code,多个逗号分隔
*/
private String areaCodes;
}
\ No newline at end of file
......@@ -10,6 +10,7 @@ package com.mortals.xhx.base.system.user.service;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Result;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.ICRUDService;
import com.mortals.framework.service.IUser;
import com.mortals.xhx.base.system.menu.model.MenuEntity;
......@@ -28,7 +29,7 @@ import java.util.Set;
* @version 1.0.0
*/
public interface UserService extends ICRUDService<UserEntity,Long> {
public interface UserService extends ICRUDCacheService<UserEntity,Long> {
/**
* 用户登录
*
......
......@@ -15,6 +15,7 @@ import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.service.IUser;
import com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.util.SecurityUtil;
import com.mortals.framework.util.StringUtils;
......@@ -43,7 +44,7 @@ import java.util.*;
* @version 1.0.0
*/
@Service("userService")
public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity, Long> implements UserService {
public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserEntity, Long> implements UserService {
@Autowired
......@@ -53,6 +54,13 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
@Autowired
private RoleUserDao roleUserDao;
@Override
protected String getExtKey(UserEntity data) {
return data.getLoginName();
}
private void doHandlerUser(UserEntity entity) throws AppException {
if (StringUtils.isNotEmpty(entity.getLoginPwd())) {
try {
......
......@@ -15,7 +15,7 @@ public class RedisKey {
public static final String KEY_DAY_VIEW_TOTAL = "dayViewTotal:";
public static final String KEY_USER_MENU_CACHE = "user:menu";
......
package com.mortals.xhx.common.utils;
import com.mortals.framework.ap.GlobalSysInfo;
import com.mortals.framework.ap.SysConstains;
import com.mortals.framework.util.AESUtil;
import lombok.extern.slf4j.Slf4j;
import java.util.Set;
@Slf4j
public class MenuEncodeUtil {
public static String generateMenuUrlCode(Set<String> urls) {
try {
String securityKey = GlobalSysInfo.getPropertyValue(SysConstains.PROP_COOKIE_SECURITY_KEY);
StringBuilder sb = new StringBuilder();
if (urls != null && urls.size() > 0) {
for (String url : urls) {
int index = url.hashCode() & (Integer.MAX_VALUE - 1);
sb.append(index).append(",");
}
}
String menuUrl = sb.toString();
return AESUtil.encrypt(menuUrl, securityKey);
} catch (Throwable e) {
log.error("编码异常",e);
return null;
}
}
}
......@@ -65,7 +65,9 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
log.info("结束同步设备列表!");
log.info("开始同步皮肤列表!");
syncSkin();
skinService.syncSkin();
//syncSkin();
log.info("结束同步皮肤列表!");
}
......@@ -159,7 +161,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
}
}
private void syncSkin() {
/* private void syncSkin() {
SkinBasePdu skinBasePdu = new SkinBasePdu();
skinBasePdu.setProductName("样表机");
......@@ -230,7 +232,7 @@ public class SyncSiteDeviceTaskImpl implements ITaskExcuteService {
}
}
}
}*/
@Override
public void stopTask(ITask task) throws AppException {
......
......@@ -276,4 +276,7 @@ public class HomeController extends BaseJsonBodyController {
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
}
......@@ -11,4 +11,6 @@ import com.mortals.xhx.module.skin.model.SkinEntity;
*/
public interface SkinService extends ICRUDService<SkinEntity,Long>{
void syncSkin();
}
\ No newline at end of file
package com.mortals.xhx.module.skin.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.code.SourceType;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.device.DeviceMsgReqPdu;
import com.mortals.xhx.common.pdu.skin.SkinBasePdu;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.feign.device.IDeviceMessageFeign;
import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.feign.skin.ISkinBaseFeign;
import com.mortals.xhx.module.skin.model.SkinQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
......@@ -15,6 +24,13 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.skin.dao.SkinDao;
import com.mortals.xhx.module.skin.model.SkinEntity;
import com.mortals.xhx.module.skin.service.SkinService;
import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* SkinService
* 皮肤 service实现
......@@ -26,6 +42,8 @@ import com.mortals.xhx.module.skin.service.SkinService;
@Slf4j
public class SkinServiceImpl extends AbstractCRUDServiceImpl<SkinDao, SkinEntity, Long> implements SkinService {
@Autowired
private ISkinBaseFeign skinBaseFeign;
@Override
protected void updateBefore(SkinEntity entity, Context context) throws AppException {
......@@ -42,4 +60,84 @@ public class SkinServiceImpl extends AbstractCRUDServiceImpl<SkinDao, SkinEntity
}
}
@Override
public void syncSkin() {
SkinBasePdu skinBasePdu = new SkinBasePdu();
skinBasePdu.setProductName("样表机");
skinBasePdu.setSize(-1);
Rest<RespData<List<SkinBasePdu>>> skinBaseRest = skinBaseFeign.list(skinBasePdu);
if (skinBaseRest.getCode() == YesNoEnum.YES.getValue()) {
List<SkinBasePdu> skinBasePduList = skinBaseRest.getData().getData();
log.info("样表机皮肤总数量:{}", skinBasePduList.size());
if (!ObjectUtils.isEmpty(skinBasePduList)) {
List<SkinEntity> newSkinList = skinBasePduList.stream().map(newSkin -> {
SkinEntity skinEntity = new SkinEntity();
skinEntity.initAttrValue();
//存相对地址
newSkin.setCssFilePath("/file"+ StrUtil.subAfter(newSkin.getCssFilePath(), "/file", false));
newSkin.setPreviewImagePath("/file"+StrUtil.subAfter(newSkin.getPreviewImagePath(), "/file", false));
BeanUtils.copyProperties(newSkin, skinEntity, BeanUtil.getNullPropertyNames(newSkin));
return skinEntity;
}).collect(Collectors.toList());
List<SkinEntity> oldSkinList = this.find(new SkinQuery());
Map<Long, SkinEntity> oldSkinMap = oldSkinList.stream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n));
Map<Long, SkinEntity> newSkinMap = newSkinList.stream().collect(Collectors.toMap(x -> x.getId(), y -> y, (o, n) -> n));
List<SkinEntity> updateSkinLsit = newSkinList.stream().map(item -> {
if (oldSkinMap.containsKey(item.getId())) {
item.setUsed(oldSkinMap.get(item.getId()).getUsed());
item.setUpdateTime(new Date());
return item;
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
List<SkinEntity> saveSkinList = newSkinList.stream().map(item -> {
if (!oldSkinMap.containsKey(item.getId())) {
item.setCreateUserId(1L);
item.setCreateUserName("系统管理员");
item.setCreateTime(new Date());
return item;
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
//做差集
List<Long> delSkinList = oldSkinList.stream().map(item -> {
if (!newSkinMap.containsKey(item.getId())) {
return item.getId();
}
return null;
}).filter(f -> f != null).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(updateSkinLsit)) {
log.info("皮肤更新,size:{}", updateSkinLsit.size());
this.update(updateSkinLsit);
}
if (!ObjectUtils.isEmpty(saveSkinList)) {
log.info("皮肤新增,size:{}", saveSkinList.size());
this.save(saveSkinList);
}
if (!ObjectUtils.isEmpty(delSkinList)) {
log.info("皮肤删除,size:{}", delSkinList.size());
this.remove(delSkinList, null);
}
}
}
}
public static void main(String[] args) {
// boolean b = StrUtil.subPre("http://192.168.0.98:11078/file/fileupload/1699947376437.png", "/file");
// System.out.println(b);
String subAfter = StrUtil.subAfter("http://192.168.0.98:11078/file/fileupload/1699947376437.png", "/file", false);
System.out.println(subAfter);
}
}
\ No newline at end of file
package com.mortals.xhx.module.skin.web;
import com.alibaba.fastjson.JSON;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
......@@ -12,33 +14,40 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.mortals.framework.model.Context;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.module.skin.model.SkinEntity;
import com.mortals.xhx.module.skin.service.SkinService;
import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*;
/**
*
* 皮肤
*
* @author zxfei
* @date 2023-04-03
*/
* 皮肤
*
* @author zxfei
* @date 2023-04-03
*/
@RestController
@RequestMapping("skin")
@Slf4j
public class SkinController extends BaseCRUDJsonBodyMappingController<SkinService,SkinEntity,Long> {
public class SkinController extends BaseCRUDJsonBodyMappingController<SkinService, SkinEntity, Long> {
@Autowired
private ParamService paramService;
......@@ -46,14 +55,14 @@ public class SkinController extends BaseCRUDJsonBodyMappingController<SkinServic
@Autowired
private IDeviceMessageFeign deviceMessageFeign;
public SkinController(){
super.setModuleDesc( "皮肤");
public SkinController() {
super.setModuleDesc("皮肤");
}
@Override
protected void init(Map<String, Object> model, Context context) {
this.addDict(model, "imageResolution", paramService.getParamBySecondOrganize("Skin","imageResolution"));
this.addDict(model, "used", paramService.getParamBySecondOrganize("Skin","used"));
this.addDict(model, "imageResolution", paramService.getParamBySecondOrganize("Skin", "imageResolution"));
this.addDict(model, "used", paramService.getParamBySecondOrganize("Skin", "used"));
super.init(model, context);
}
......@@ -63,7 +72,7 @@ public class SkinController extends BaseCRUDJsonBodyMappingController<SkinServic
//推送皮肤更新消息
DeviceMsgReqPdu deviceMsgReqPdu = new DeviceMsgReqPdu();
deviceMsgReqPdu.setSiteid(entity.getSiteId());
deviceMsgReqPdu.setProductCode("tdj");
deviceMsgReqPdu.setProductCode("ybj");
deviceMsgReqPdu.setMessageType("edition");
deviceMsgReqPdu.setData("W10=");
deviceMsgReqPdu.setTimestamp(System.currentTimeMillis());
......@@ -71,4 +80,13 @@ public class SkinController extends BaseCRUDJsonBodyMappingController<SkinServic
log.info("send device message==>{}", JSON.toJSONString(rest));
return super.saveAfter(entity, model, context);
}
@PostMapping({"refreshSkin"})
@UnAuth
public Rest<Object> refreshSkin() {
log.info("刷新皮肤");
this.service.syncSkin();
return Rest.ok("皮肤刷新操作成功");
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment