Commit 5f04986b authored by wzp's avatar wzp

修改返回信息

parent fccf3d89
......@@ -2,6 +2,7 @@ package cn.wisenergy.chnmuseum.party.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.wisenergy.chnmuseum.party.model.TOrgan;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
......@@ -20,4 +21,6 @@ public interface TOrganMapper extends BaseMapper<TOrgan> {
TOrgan getById(String id);
TOrgan selectCodeMax(String parentId);
List<TOrgan> getAllList(@Param("org") TOrgan org);
}
......@@ -54,7 +54,7 @@ public class RunLog implements Serializable {
@TableField("end_time")
private LocalDateTime endTime;
@ApiModelProperty(value = "结束时间")
@ApiModelProperty(value = "机构名称")
@TableField(exist = false)
private String orgName;
......
......@@ -22,4 +22,6 @@ public interface TOrganService extends IService<TOrgan> {
TOrgan selectById(String id);
TOrgan selectCodeMax(String parentId);
List<TOrgan> getAllList(TOrgan tOrgan);
}
......@@ -116,6 +116,11 @@ public class TOrganServiceImpl extends ServiceImpl<TOrganMapper, TOrgan> impleme
return organMapper.selectCodeMax(parentId);
}
@Override
public List<TOrgan> getAllList(TOrgan tOrgan) {
return organMapper.getAllList(tOrgan);
}
private String getOrganCode(String parentId) {
TOrgan max = selectCodeMax(parentId);
......
......@@ -264,7 +264,7 @@ public class ChinaMobileRestApiController extends BaseController {
@ApiOperation(value = "获取单个成员信息")
@GetMapping(value = "/user/getUserInfo")
public ResponseEntity<JSONObject> getById(String userId, @RequestHeader("token") String token) {
public ResponseEntity<JSONObject> getById(String userId) {
JSONObject resultMap = new JSONObject(true);
try {
TUser user = userService.getById(userId);
......@@ -277,10 +277,9 @@ public class ChinaMobileRestApiController extends BaseController {
}
JSONObject jsonObject = new JSONObject(true);
jsonObject.put("token", token);
jsonObject.put("userId", user.getId());
jsonObject.put("userName", user.getUserName());
long expire = stringRedisTemplate.getExpire(SHIRO_JWT_TOKEN + token) == null ? 0L : stringRedisTemplate.getExpire(SHIRO_JWT_TOKEN + token);
// long expire = stringRedisTemplate.getExpire(SHIRO_JWT_TOKEN + token) == null ? 0L : stringRedisTemplate.getExpire(SHIRO_JWT_TOKEN + token);
//jsonObject.put("expire", TimeUtils.format(LocalDateTime.now().plusMinutes(expire), TimeUtils.FORMAT_ONE));
jsonObject.put("effectiveDate", user.getEffectiveDate());
jsonObject.put("expireDate", user.getExiredDate());
......@@ -299,7 +298,8 @@ public class ChinaMobileRestApiController extends BaseController {
}
@RequestMapping(value = "/user/logout", method = RequestMethod.GET)
public ResponseEntity<JSONObject> logout(@RequestHeader(value = "token") String token) {
public ResponseEntity<JSONObject> logout() {
String token = request.getHeader("Authorization");
JSONObject resultMap = new JSONObject(true);
try {
if (StringUtils.isNotBlank(token)) {
......
......@@ -130,7 +130,13 @@ public class SysLogController extends BaseController {
@ApiOperation(value = "插入机顶盒日志表", notes = "插入机顶盒日志表")
@PostMapping(value = "/insertRunLog")
public Boolean insertRunLog(RunLog runLog) {
boolean b = runLogService.insertRunLog(runLog);
boolean b = false;
try {
b = runLogService.insertRunLog(runLog);
return b;
} catch (Exception e) {
e.printStackTrace();
}
return b;
}
......@@ -141,7 +147,13 @@ public class SysLogController extends BaseController {
@PostMapping(value = "/insertOperationLog")
public Boolean insertOperationLog(TOperationLog tOperationLog) {
tOperationLog.setCreateTime(LocalDateTime.now());
boolean b = operationLogService.save(tOperationLog);
boolean b = false;
try {
b = operationLogService.save(tOperationLog);
return b;
} catch (Exception e) {
e.printStackTrace();
}
return b;
}
......
......@@ -73,8 +73,14 @@ public class TBoxOperationController extends BaseController {
if (StringUtils.isNotBlank(areaId)) {
user.setAreaId(areaId);
}
Page<TBoxOperation> page = tBoxOperationService.selectBoxPage(getPage(), user);
return getResult(page);
Page<TBoxOperation> page = null;
try {
page = tBoxOperationService.selectBoxPage(getPage(), user);
return getResult(page);
} catch (Exception e) {
e.printStackTrace();
}
return getFailResult();
}
@PostMapping("/add")
......@@ -84,14 +90,18 @@ public class TBoxOperationController extends BaseController {
// 保存业务节点信息
tBoxOperation.setCreateTime(LocalDateTime.now());
tBoxOperation.setUpdateTime(LocalDateTime.now());
boolean result = tBoxOperationService.save(tBoxOperation);
// 返回操作结果
if (result) {
boolean result = false;
try {
result = tBoxOperationService.save(tBoxOperation);
if (!result) {
return getFailResult();
}
return getSuccessResult();
} else {
} catch (Exception e) {
e.printStackTrace();
}
// 保存失败
return getFailResult();
}
}
@PutMapping("/update")
......@@ -123,9 +133,15 @@ public class TBoxOperationController extends BaseController {
@ApiImplicitParam(name = "id", value = "标识ID", paramType = "path", dataType = "String")
})
public Map<String, Object> deleteTBoxOperation(@PathVariable("id") String id) {
boolean result = tBoxOperationService.removeById(id);
if (result) {
boolean result = false;
try {
result = tBoxOperationService.removeById(id);
if (!result) {
return getFailResult();
}
return getSuccessResult();
} catch (Exception e) {
e.printStackTrace();
}
return getFailResult();
}
......@@ -134,8 +150,14 @@ public class TBoxOperationController extends BaseController {
@RequiresPermissions("/boxOperation/getList")
@ApiOperation(value = "获取机顶盒运维信息全部列表(无分页)", notes = "获取机顶盒运维信息全部列表(无分页)")
public Map<String, Object> getTBoxOperationList() {
List<TBoxOperation> tBoxOperationList = tBoxOperationService.getList();
return getResult(tBoxOperationList);
List<TBoxOperation> tBoxOperationList = null;
try {
tBoxOperationList = tBoxOperationService.getList();
return getResult(tBoxOperationList);
} catch (Exception e) {
e.printStackTrace();
}
return getFailResult();
}
@ApiImplicitParams(value = {
......@@ -160,16 +182,28 @@ public class TBoxOperationController extends BaseController {
wrapper.eq("area_id", areaId);
}
wrapper.orderByDesc("create_time");
Page<TBoxOperation> page = this.tBoxOperationService.page(getPage(), wrapper);
return getResult(page);
Page<TBoxOperation> page = null;
try {
page = this.tBoxOperationService.page(getPage(), wrapper);
return getResult(page);
} catch (Exception e) {
e.printStackTrace();
}
return getFailResult();
}
@ApiOperation(value = "获取机顶盒运维信息详情", notes = "获取机顶盒运维信息详情")
@GetMapping("/getById")
@RequiresPermissions("/boxOperation/getById")
public Map<String, Object> getById(@PathVariable("id") String id) {
TBoxOperation tBoxOperation = tBoxOperationService.getById(id);
return getResult(tBoxOperation);
TBoxOperation tBoxOperation = null;
try {
tBoxOperation = tBoxOperationService.getById(id);
return getResult(tBoxOperation);
} catch (Exception e) {
e.printStackTrace();
}
return getFailResult();
}
}
......
......@@ -63,46 +63,60 @@ public class TInteractionController extends BaseController {
@RequiresPermissions("/interaction/add")
@ApiOperation(value = "添加看板互动", notes = "添加看板互动")
public Map<String, Object> saveTInteraction(TInteraction tInteraction) {
Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
if (StringUtils.isBlank(tInteraction.getName())||StringUtils.isBlank(tInteraction.getPassword())) {
resultMap.put("code", 400);
resultMap.put("msg", "请输入用户名和密码");
return resultMap;
}
TUser user = userService.selectByUsername(tInteraction.getName());
if (user == null) {
resultMap.put("code", 500);
resultMap.put("msg", "用户名错误");
return resultMap;
}
byte[] salt = user.getPasswordSalt();
if (!new String(SHA256PasswordEncryptionService.createPasswordHash(tInteraction.getPassword(), salt))
.equals(new String(user.getPasswordHash()))) {
resultMap.put("code", 500);
resultMap.put("msg", "密码错误");
return resultMap;
}
tInteraction.setCreateTime(LocalDateTime.now());
// 保存业务节点信息
boolean result = tInteractionService.save(tInteraction);
// 返回操作结果
if (result) {
return getSuccessResult();
} else {
// 保存失败
return getFailResult();
boolean result = false;
try {
Map<String, Object> resultMap = new LinkedHashMap<String, Object>();
if (StringUtils.isBlank(tInteraction.getName())||StringUtils.isBlank(tInteraction.getPassword())) {
resultMap.put("code", 400);
resultMap.put("msg", "请输入用户名和密码");
return resultMap;
}
TUser user = userService.selectByUsername(tInteraction.getName());
if (user == null) {
resultMap.put("code", 500);
resultMap.put("msg", "用户名错误");
return resultMap;
}
byte[] salt = user.getPasswordSalt();
if (!new String(SHA256PasswordEncryptionService.createPasswordHash(tInteraction.getPassword(), salt))
.equals(new String(user.getPasswordHash()))) {
resultMap.put("code", 500);
resultMap.put("msg", "密码错误");
return resultMap;
}
tInteraction.setCreateTime(LocalDateTime.now());
result = tInteractionService.save(tInteraction);
// 返回操作结果
if (result) {
return getSuccessResult();
} else {
// 保存失败
return getFailResult();
}
} catch (Exception e) {
e.printStackTrace();
}
return getFailResult();
}
@PutMapping("/update")
@RequiresPermissions("/interaction/update")
@ApiOperation(value = "修改看板互动信息", notes = "修改看板互动信息")
public Map<String, Object> updateTInteraction(@Validated(value = {Update.class}) TInteraction tInteraction) {
boolean flag = tInteractionService.updateById(tInteraction);
if (flag) {
return getSuccessResult();
boolean flag = false;
try {
flag = tInteractionService.updateById(tInteraction);
if (!flag) {
return getFailResult();
}
return getSuccessResult();
} catch (Exception e) {
e.printStackTrace();
}
return getFailResult();
}
......@@ -131,8 +145,14 @@ public class TInteractionController extends BaseController {
})
@ApiOperation(value = "获取看板互动列表", notes = "获取看板互动列表")
public Map<String, Object> getTInteractionPageList(String orgId) {
Page<TInteraction> list = tInteractionService.page(getPage(),new UpdateWrapper<TInteraction>().eq("organ_id", orgId));
return getResult(list);
Page<TInteraction> list = null;
try {
list = tInteractionService.page(getPage(),new UpdateWrapper<TInteraction>().eq("organ_id", orgId));
return getResult(list);
} catch (Exception e) {
e.printStackTrace();
}
return getFailResult();
}
......@@ -140,8 +160,14 @@ public class TInteractionController extends BaseController {
@GetMapping("/getById")
@RequiresPermissions("/interaction/getById")
public Map<String, Object> getById(String id) {
TInteraction tInteraction = tInteractionService.getById(id);
return getResult(tInteraction);
TInteraction tInteraction = null;
try {
tInteraction = tInteractionService.getById(id);
return getResult(tInteraction);
} catch (Exception e) {
e.printStackTrace();
}
return getFailResult();
}
......
......@@ -91,22 +91,30 @@ public class TOrganController extends BaseController {
@ApiOperation(value = "update", notes = "修改机构信息")
// @MethodLog(operModule = OperModule.ORG,operType = OperType.UPDATE)
public Map<String, Object> updateTOrgan(TOrgan tOrgan) {
TOrgan byId = tOrganService.selectById(tOrgan.getId());
if (byId.getLevel()!=tOrgan.getLevel()&&byId.getChildren().size()>0){
HashMap<String, Object> map = new HashMap<>();
map.put("resultCode", 500);
map.put("message", "机构存在下级机构,不能修改机构级别!");
map.put("data", "");
return map;
}
if (!byId.getParentId().equals(tOrgan.getParentId())){
tOrgan.setCode(getOrganCode(tOrgan.getParentId()));
}
tOrgan.setUpdateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
boolean flag = tOrganService.updateById(tOrgan);
if (flag) {
try {
TOrgan byId = tOrganService.selectById(tOrgan.getId());
if (byId.getLevel()!=tOrgan.getLevel()&&byId.getChildren().size()>0){
HashMap<String, Object> map = new HashMap<>();
map.put("resultCode", 500);
map.put("message", "机构存在下级机构,不能修改机构级别!");
map.put("data", "");
return map;
}
if (!byId.getParentId().equals(tOrgan.getParentId())){
tOrgan.setCode(getOrganCode(tOrgan.getParentId()));
}
tOrgan.setUpdateTime(DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
boolean flag = false;
flag = tOrganService.updateById(tOrgan);
if (!flag) {
return getFailResult();
}
return getSuccessResult();
} catch (Exception e) {
e.printStackTrace();
}
return getFailResult();
}
......@@ -119,30 +127,42 @@ public class TOrganController extends BaseController {
@ApiImplicitParam(name = "id", value = "标识ID", paramType = "path", dataType = "String")
})
public Map<String, Object> deleteTOrgan(@PathVariable("id") String id) {
UpdateWrapper<TOrgan> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id);
updateWrapper.eq("is_deleted", 1);
updateWrapper.eq("update_time", DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
boolean result = tOrganService.update(updateWrapper);
if (result) {
boolean result = false;
try {
UpdateWrapper<TOrgan> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", id);
updateWrapper.eq("is_deleted", 1);
updateWrapper.eq("update_time", DateUtil80.getDateTimeOfTimestamp(System.currentTimeMillis()));
result = tOrganService.update(updateWrapper);
if (!result) {
return getFailResult();
}
return getSuccessResult();
} catch (Exception e) {
e.printStackTrace();
}
return getFailResult();
}
@GetMapping("/getList")
@RequiresPermissions("/organ/getList")
@ApiOperation(value = "获取机构全部列表(无分页)", notes = "获取机构全部列表(无分页)")
@MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
// @MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
public Map<String, Object> getTOrganList() {
TUser user = null;
try {
user = getcurUser();
TOrgan tOrgan = new TOrgan();
tOrgan.setId(user.getOrgId());
List<TOrgan> list = tOrganService.getAllList(tOrgan);
return getResult(list);
} catch (Exception e) {
e.printStackTrace();
}
List<TOrgan> tOrganList = tOrganService.list(Wrappers.<TOrgan>lambdaQuery().eq(TOrgan::getIsDeleted, 0).likeRight(TOrgan::getId,user.getOrgId()).orderByDesc(TOrgan::getCreateTime));
return getResult(tOrganList);
return getFailResult();
}
......@@ -159,20 +179,27 @@ public class TOrganController extends BaseController {
@ApiOperation(value = "获取机构分页列表", notes = "获取机构分页列表")
@MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
public Map<String, Object> getTOrganPageList(GenericPageParam genericPageParam) {
LambdaQueryWrapper<TOrgan> queryWrapper = new LambdaQueryWrapper<>();
// 对名称或编码模糊查询
if (StringUtils.isNotBlank(genericPageParam.getNameOrCode())) {
queryWrapper.like(TOrgan::getName, genericPageParam.getNameOrCode());
}
// 根据创建时间区间检索
if (genericPageParam.getStartDate() != null && genericPageParam.getEndDate() != null) {
queryWrapper.ge(TOrgan::getCreateTime, genericPageParam.getStartDate().atTime(0, 0, 0))
.le(TOrgan::getCreateTime, genericPageParam.getEndDate().atTime(23, 59, 59));
Page<TOrgan> page = null;
try {
LambdaQueryWrapper<TOrgan> queryWrapper = new LambdaQueryWrapper<>();
// 对名称或编码模糊查询
if (StringUtils.isNotBlank(genericPageParam.getNameOrCode())) {
queryWrapper.like(TOrgan::getName, genericPageParam.getNameOrCode());
}
// 根据创建时间区间检索
if (genericPageParam.getStartDate() != null && genericPageParam.getEndDate() != null) {
queryWrapper.ge(TOrgan::getCreateTime, genericPageParam.getStartDate().atTime(0, 0, 0))
.le(TOrgan::getCreateTime, genericPageParam.getEndDate().atTime(23, 59, 59));
}
// 设置排序规则
queryWrapper.orderByDesc(TOrgan::getCreateTime);
page = this.tOrganService.page(getPage(), queryWrapper);
return getResult(page);
} catch (Exception e) {
e.printStackTrace();
}
// 设置排序规则
queryWrapper.orderByDesc(TOrgan::getCreateTime);
Page<TOrgan> page = this.tOrganService.page(getPage(), queryWrapper);
return getResult(page);
return getFailResult();
}
@ApiOperation(value = "获取机构详情", notes = "获取机构详情")
......@@ -180,8 +207,14 @@ public class TOrganController extends BaseController {
@RequiresPermissions("/organ/getById")
@MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
public Map<String, Object> getById(String id) {
TOrgan tOrgan = tOrganService.selectById(id);
return getResult(tOrgan);
TOrgan tOrgan = null;
try {
tOrgan = tOrganService.selectById(id);
return getResult(tOrgan);
} catch (Exception e) {
e.printStackTrace();
}
return getFailResult();
}
......@@ -191,21 +224,33 @@ public class TOrganController extends BaseController {
// @MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
public Map<String, Object> getTree(String name) {
List<TOrgan> list = new ArrayList<>();
if (StringUtils.isBlank(name)) {
list = tOrganService.getTree();
}else {
list = tOrganService.list(new UpdateWrapper<TOrgan>().like("name",name));
try {
if (StringUtils.isBlank(name)) {
list = tOrganService.getTree();
}else {
list = tOrganService.list(new UpdateWrapper<TOrgan>().like("name",name));
}
return getResult(list);
} catch (Exception e) {
e.printStackTrace();
}
return getResult(list);
}
return getFailResult();
}
@GetMapping("/getAreaTree")
@RequiresPermissions("/organ/getAreaTree")
@ApiOperation(value = "获取区域树", notes = "获取机构树")
// @MethodLog(operModule = OperModule.ORG,operType = OperType.SELECT)
public Map<String, Object> getAreaTree() {
List<TArea> list = tAreaService.getAreaTree();
return getResult(list);
List<TArea> list = null;
try {
list = tAreaService.getAreaTree();
return getResult(list);
} catch (Exception e) {
e.printStackTrace();
}
return getFailResult();
}
......
......@@ -37,6 +37,18 @@ left join t_area a on o.area_id = a.id
where o.id = #{id}
</select>
<select id="getAllList" resultMap="BaseResultMap">
select o.* ,r.`name` parent_name,a.full_name area_name
from t_organ o
left join t_organ r on o.parent_id = r.id
left join t_area a on o.area_id = a.id
where 1=1
<if test=" org.id != null and org.id != '' ">
and o.id LIKE concat('%', #{org.id})
</if>
order by o.create_time desc
</select>
<select id="selectCodeMax" resultMap="BaseResultMap">
select * from t_organ where parent_id = #{parentId} order by code desc limit 1
</select>
......
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