Commit f8fa3fb8 authored by 赵啸非's avatar 赵啸非

添加更新默认用户角色

parent 16bbdfad
......@@ -2,28 +2,26 @@ package com.mortals.xhx.base.system.param.web;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.RepeatSubmit;
import com.alibaba.nacos.common.utils.IpUtils;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.code.PageDisplayType;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.util.FileUtil;
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.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mortals.framework.web.BaseCRUDJsonMappingController;
import com.mortals.xhx.base.system.param.model.ParamEntity;
import com.mortals.xhx.base.system.param.model.ParamQuery;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.code.DataSatusEnum;
import com.mortals.xhx.common.code.ModStatusEnum;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.mortals.xhx.common.key.Constant.PARAM_SERVER_HTTP_URL;
/**
* 参数信息
*
......@@ -48,6 +46,94 @@ public class ParamController extends BaseCRUDJsonBodyMappingController<ParamServ
model.put(KEY_RESULT_DICT, status);
}
/**
* @param query
* @param list
* @param context
* @throws AppException
*/
@Override
protected void doListAfter(ParamEntity query, List<ParamEntity> list, Context context) throws AppException {
super.doListAfter(query, list, context);
}
@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "key")
@UnAuth
public String getValueByKey(@RequestParam(name = "key") String key) {
JSONObject jsonObject = new JSONObject();
String busiDesc = "通过key查询参数值" + this.getModuleDesc();
try {
String value = this.service.getValueByKey(key);
jsonObject.put(KEY_RESULT_DATA, value);
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, busiDesc + "成功!");
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "dict")
@UnAuth
public String getDict(@RequestParam(name = "first") String first, @RequestParam(name = "second") String second) {
JSONObject jsonObject = new JSONObject();
String busiDesc = "通过key查询字典参数值" + this.getModuleDesc();
try {
Map<String, String> dict = this.service.getParamBySecondOrganize(first, second);
// String value = this.service.getValueByKey(key);
jsonObject.put(KEY_RESULT_DATA, dict);
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, busiDesc + "成功!");
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
/**
* 更新终端访问服务器应用ip地址
*/
@GetMapping(value = "updateServerIp")
@UnAuth
public String updateServerip(String serverIp) {
JSONObject jsonObject = new JSONObject();
try {
//校验ip地址
boolean ipv4 = IpUtils.isIpv4(serverIp);
if (!ipv4) {
throw new AppException("请输入正确的ip地址");
}
ParamQuery paramQuery = new ParamQuery();
paramQuery.setParamKey(PARAM_SERVER_HTTP_URL);
ParamEntity paramEntity = this.service.selectOne(paramQuery);
if (!ObjectUtils.isEmpty(paramEntity)) {
//paramEntity.setParamValue(serverIp);
String value = "http://" + serverIp + ":11078";
paramEntity.setParamValue(value);
this.service.update(paramEntity);
}
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, "更新终端访问服务端ip成功!");
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
private Map<String, Object> getPageDisplayType() {
PageDisplayType[] pageDisplayTypes = PageDisplayType.values();
......@@ -58,4 +144,11 @@ public class ParamController extends BaseCRUDJsonBodyMappingController<ParamServ
return result;
}
public static void main(String[] args) {
//FileUtil.delete("E:\\pic\\1.png");
System.out.println(IpUtils.isIpv4("10.102.252.13"));
}
}
\ No newline at end of file
......@@ -344,8 +344,13 @@ public class UserServiceImpl extends AbstractCRUDCacheServiceImpl<UserDao, UserE
userEntity.setRealName(userResp.getName());
userEntity.setPhone(userResp.getPhone());
userEntity.setMobile(userResp.getPhone());
userEntity.setLoginPwd(SecurityUtil.md5DoubleEncoding("123"));
userEntity.setLoginPwd(SecurityUtil.md5DoubleEncoding("xhxADMIN8@a"));
userEntity.setUserType(2);
//更新默认用户角色
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserId(userEntity.getId());
roleUserQuery.setRoleIdList(Arrays.asList(1L));
roleUserService.doDistributionRole(roleUserQuery);
this.save(userEntity);
} catch (Exception e) {
log.error("保存用户失败!", e.getMessage());
......
......@@ -13,6 +13,9 @@ import com.mortals.framework.util.DateUtils;
import com.mortals.framework.util.SecurityUtil;
import com.mortals.framework.util.StringUtils;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.resource.service.ResourceService;
import com.mortals.xhx.base.system.role.model.RoleUserQuery;
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;
......@@ -31,6 +34,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
......@@ -56,6 +60,11 @@ public class H5LoginController extends BaseCRUDJsonBodyMappingController<UserSer
@Autowired
private CompanyService companyService;
@Autowired
private ResourceService resourceService;
@Autowired
private RoleUserService roleUserService;
/**
* 微信appId
*/
......@@ -200,6 +209,13 @@ public class H5LoginController extends BaseCRUDJsonBodyMappingController<UserSer
userEntity.setCompanyId(companyEntity.getId());
userEntity.setRoleIds("2");
userEntity = userService.save(userEntity);
//更新默认用户角色
RoleUserQuery roleUserQuery = new RoleUserQuery();
roleUserQuery.setUserId(userEntity.getId());
roleUserQuery.setRoleIdList(Arrays.asList(2L));
roleUserService.doDistributionRole(roleUserQuery);
}else {
userEntity.setPhone(req.getPhone());
userEntity.setMobile(req.getPhone());
......
......@@ -29,5 +29,11 @@ public class DeclareVo extends BaseEntityLong {
private List<EvaluationInfoEntity> evaluationInfoList=new ArrayList<>();
/** 开始 创建时间 */
private String createTimeStart;
/** 结束 创建时间 */
private String createTimeEnd;
}
\ No newline at end of file
......@@ -19,5 +19,9 @@ public class EvaluationInfoVo extends BaseEntityLong {
/** 主键ID,主键,自增长列表 */
private List <Long> idList;
/** 开始 创建时间 */
private String createTimeStart;
/** 结束 创建时间 */
private String createTimeEnd;
}
\ 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