Ejemplo n.º 1
0
 def get(self):
     app.logger.info(
         f"TeamProjectViews get({teamProjectParams.parse_args()})")
     msg = MsgBuilder()
     args = removeNoneKey(teamProjectParams.parse_args())
     teamInfo = SrvCnf.query.filter_by(active=1, **args).all()
     teamInfoSchema = TeamProjectSchema(many=True)
     teamInfoSerialized = teamInfoSchema.dump(teamInfo)
     msg.setSucceed(respData=[
         project.get("project") for project in teamInfoSerialized
     ])
     return jsonify(msg.getMsg())
Ejemplo n.º 2
0
 def get(self):
     """
     获取服务配置列表
     :return:list
     """
     app.logger.info(f"SrvCnfsViews get({srvCnfReqData.parse_args()})")
     msg = MsgBuilder()
     args = removeNoneKey(srvCnfReqData.parse_args())
     config = SrvCnf.query.filter_by(active=1, **args).all()
     srvCnfSchema = SrvCnfSchema(many=True)
     configSerialized = srvCnfSchema.dump(config)
     msg.setSucceed(respData=configSerialized)
     return jsonify(msg.getMsg())
Ejemplo n.º 3
0
 def post(self):
     app.logger.info(f"CommonCnfViews post({commonCnfParams.parse_args()})")
     msg = MsgBuilder()
     args = removeNoneKey(commonCnfParams.parse_args())
     if CommonCnf.query.filter_by(key=args.get("key")).first():
         msg.setFailed(ResCode.UNIQUE_ERROR,
                       msg=f'key={args.get("key")}已存在!')
     else:
         commonCnfSchema = CommonCnfSchema()
         # 因为 value字段可能是可能是单纯字符串,也可能是符合json格式的 此处不用schema.load而做特殊处理
         args["value"] = strToJson(args.get("value"))
         CommonCnf.create(**jsonToStr(args))
         res = CommonCnf.query.filter_by(key=args.get("key")).first()
         msg.setSucceed(respData=commonCnfSchema.dump(res))
     return jsonify(msg.getMsg())
Ejemplo n.º 4
0
 def put(self):
     app.logger.info(f"CommonCnfViews put({commonCnfParams.parse_args()})")
     msg = MsgBuilder()
     args = removeNoneKey(commonCnfParams.parse_args())
     key = args.get("key")
     cnf = CommonCnf.query.filter_by(key=key).first()
     if cnf:
         # 因为 value字段可能是可能是单纯字符串,也可能是符合json格式的 此处不用schema.load而做特殊处理
         args["value"] = strToJson(args.get("value"))
         cnf.update(**jsonToStr(args))
         res = CommonCnf.query.filter_by(key=args.get("key")).first()
         commonCnfSchema = CommonCnfSchema()
         msg.setSucceed(respData=commonCnfSchema.dump(res))
     else:
         msg.setFailed(ResCode.NOT_FOUND, msg=f'key={args.get("key")}不存在!')
     return jsonify(msg.getMsg())