Commit 39b9879a authored by chenying's avatar chenying

3.12:修改模板和用户的接口

parent 6df80164
This diff is collapsed.
package com.example.tdl.domain.vo;
public class AddUserVo {
private String userNumber;
private String userName;
private String password;
......@@ -13,6 +15,34 @@ public class AddUserVo {
private String roleName;
private Long createTime;
private Long updateTime;
public String getUserNumber() {
return userNumber;
}
public void setUserNumber(String userNumber) {
this.userNumber = userNumber;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
public Long getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Long updateTime) {
this.updateTime = updateTime;
}
public String getUserName() {
return userName;
}
......
......@@ -8,4 +8,6 @@ import java.util.List;
@Mapper
public interface RoleMapper {
List<String> getAllRoleName();
Integer getByRoleName(String roleName);
}
......@@ -15,4 +15,8 @@ public class RoleService {
public List<String> getAllRoleName(){
return roleMapper.getAllRoleName();
}
public Integer getByRoleName(String roleName){
return roleMapper.getByRoleName(roleName);
}
}
......@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.AddModelVo;
import com.example.tdl.domain.vo.UpdateModelVo;
import com.example.tdl.entity.TopicModel;
import com.example.tdl.service.ModelService;
import com.example.tdl.service.ProbesModelService;
import com.example.tdl.service.TopicModelService;
......@@ -23,7 +22,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
......
......@@ -7,6 +7,7 @@ import com.example.tdl.domain.vo.AddModelInfoVo;
import com.example.tdl.domain.vo.DelModelInfoVo;
import com.example.tdl.domain.vo.ModelInfoTermVo;
import com.example.tdl.service.ModelInfoService;
import com.example.tdl.service.ModelService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -33,6 +34,9 @@ public class ModelInfoController {
@Autowired
private ModelInfoService modelInfoService;
@Autowired
private ModelService modelService;
@ApiOperation(value = "查询所有配置模板",notes = "modelName是查询的模板名,查询所有配置模板的返回值对应的意义:" +
" modelName: 模板名," +
......@@ -100,6 +104,11 @@ public class ModelInfoController {
fb.setMessage("需要添加的通道编号不能为空");
return gson.toJson(fb);
}
if (modelService.getByModelName(addModelInfoVo.getModelName())==null){
fb.setCode(0);
fb.setMessage("没有该配置模板");
return gson.toJson(fb);
}
if (modelInfoService.getByPortAndTopicName(new ModelInfoTermVo(addModelInfoVo.getModelName(),addModelInfoVo.getTopicModelName(),
addModelInfoVo.getTopicName(),addModelInfoVo.getProbesModelName(),addModelInfoVo.getPort()))!=null){
fb.setCode(0);
......@@ -154,6 +163,11 @@ public class ModelInfoController {
fb.setMessage("需要删除的通道编号不能为空");
return gson.toJson(fb);
}
if (modelService.getByModelName(delModelInfoVo.getModelName())==null){
fb.setCode(0);
fb.setMessage("没有该配置模板");
return gson.toJson(fb);
}
int a=modelInfoService.delModelInfo(delModelInfoVo);
if (a>0){
fb.setCode(1);
......
......@@ -51,6 +51,11 @@ public class ProbesModelInfoController {
public Object getAll(@RequestBody String probesModelName){
JSONObject jsonObject= JSON.parseObject(probesModelName);
probesModelName=(String) jsonObject.get("probesModelName");
if (StringUtils.isEmpty(probesModelName)){
fb.setCode(0);
fb.setMessage("需要查询的通道模板不能为空");
return gson.toJson(fb);
}
return probesModelInfoService.getAll(probesModelName);
}
......@@ -162,6 +167,12 @@ public class ProbesModelInfoController {
fb.setMessage("需要删除的通道模板编号不能为空");
return gson.toJson(fb);
}
if (probesModelService.getByProbesModelName(delProbesModelInfoVo.getProbesModelName())==null){
fb.setCode(0);
fb.setMessage("需要删除的模板名不存在");
return gson.toJson(fb);
}
Map<String,Object> params=new HashMap<String, Object>();
params.put("probesModelName",delProbesModelInfoVo.getProbesModelName());
params.put("port",delProbesModelInfoVo.getPort());
......@@ -187,7 +198,7 @@ public class ProbesModelInfoController {
//修改单个通道模板
@ApiOperation(value = "修改单个通道模板",notes = "修改单个通道模板,port不能:" +
@ApiOperation(value = "修改单个通道模板",notes = "修改单个通道模板,port不能:" +
" probesModelName: 需要修改的模板名," +
" port: 需要修改的通道模板编号," +
" unit: 通道模板单位," +
......@@ -241,6 +252,11 @@ public class ProbesModelInfoController {
fb.setMessage("通道模板报警下限不能为空");
return gson.toJson(fb);
}
if (probesModelService.getByProbesModelName(resultProbesModelInfoVo.getProbesModelName())==null){
fb.setCode(0);
fb.setMessage("需要修改的模板名不存在");
return gson.toJson(fb);
}
Integer probesModelId=probesModelService.getIdByProbesModel(resultProbesModelInfoVo.getProbesModelName());
ResultProbesModelInfoVo resultAlias=probesModelInfoService.getByAlias(probesModelId,resultProbesModelInfoVo.getAlias());
if (resultAlias!=null&&resultAlias.getPort()!=resultProbesModelInfoVo.getPort()){
......
......@@ -7,9 +7,7 @@ import com.example.tdl.domain.dto.CommFeedback;
import com.example.tdl.domain.vo.AddRouteVo;
import com.example.tdl.domain.vo.RouteTermVo;
import com.example.tdl.domain.vo.UpdateRouteVo;
import com.example.tdl.domain.vo.UserVo;
import com.example.tdl.entity.Route;
import com.example.tdl.service.RoleService;
import com.example.tdl.service.RouteService;
import com.example.tdl.service.TokenRedisService;
import com.google.gson.Gson;
......@@ -17,7 +15,6 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -26,9 +23,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
@RestController
......
......@@ -110,6 +110,11 @@ public class TopicModelInfoController {
fb.setMessage("添加模板的主题名不能相同");
return gson.toJson(fb);
}
if (topicModelService.getByTopicModelName(topicModelInfoVo.getTopicModelName())==null){
fb.setCode(0);
fb.setMessage("没有该主题模板");
return gson.toJson(fb);
}
int a=topicModelInfoService.addTopicModelInfo(topicModelInfoVo);
if (a>0){
fb.setCode(1);
......@@ -168,6 +173,11 @@ public class TopicModelInfoController {
fb.setMessage("修改的主题名不能相同");
return gson.toJson(fb);
}
if (topicModelService.getByTopicModelName(updateTopicModelInfoVo.getTopicModelName())==null){
fb.setCode(0);
fb.setMessage("没有该主题模板");
return gson.toJson(fb);
}
int a=topicModelInfoService.updateTopicModelInfo(updateTopicModelInfoVo);
if (a>0){
fb.setCode(1);
......@@ -200,6 +210,11 @@ public class TopicModelInfoController {
fb.setMessage("删除的主题名不能为空");
return gson.toJson(fb);
}
if (topicModelService.getByTopicModelName(delTopicModelInfoVo.getTopicModelName())==null){
fb.setCode(0);
fb.setMessage("没有该主题模板");
return gson.toJson(fb);
}
try {
Map<String,Object> map=new HashMap<>();
map.put("topicModelName",delTopicModelInfoVo.getTopicModelName());
......
......@@ -6,4 +6,7 @@
SELECT roleName from role;
</select>
<select id="getByRoleName" resultType="java.lang.Integer" parameterType="String">
SELECT COUNT(*) from role WHERE roleName=#{roleName,jdbcType=VARCHAR}
</select>
</mapper>
\ No newline at end of file
......@@ -68,18 +68,18 @@
</select>
<!--添加用户-->
<insert id="addUser" parameterType="com.example.tdl.domain.vo.UserVo">
<insert id="addUser" parameterType="com.example.tdl.domain.vo.AddUserVo">
INSERT INTO `user` VALUES(
null,
CONCAT("U",(unix_timestamp(now())*1000)),
#{userNumber,jdbcType=VARCHAR},
#{userName,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR},
#{nickName,jdbcType=VARCHAR},
#{phone,jdbcType=VARCHAR},
#{email,jdbcType=VARCHAR},
(SELECT id from role WHERE roleName=#{roleName,jdbcType=VARCHAR}),
(unix_timestamp(now())*1000) ,
(unix_timestamp(now())*1000) ,
#{createTime,jdbcType=VARCHAR},
#{updateTime,jdbcType=VARCHAR},
1
)
</insert>
......
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