|
@@ -116,7 +116,7 @@ func (c *ProjectAccountBs) GetSearch() {
|
|
|
}
|
|
|
|
|
|
// @Summary 创建账号
|
|
|
-// @Tags 项目设置-管理员
|
|
|
+// @Tags 后台 - 项目账号
|
|
|
// @Description 新增账号
|
|
|
// @Accept json
|
|
|
// @Produce json
|
|
@@ -130,25 +130,18 @@ func (c *ProjectAccountBs) GetSearch() {
|
|
|
// @Param position body string true "职位"
|
|
|
// @Param mobile body string true "手机"
|
|
|
// @Param telephone body string true "座机"
|
|
|
-// @Param accountGroup body int true "账号组"
|
|
|
// @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
|
|
|
// @Router /backstage/account/create [post]
|
|
|
func (c *ProjectAccountBs) PostCreate() {
|
|
|
- ErrMsg := ""
|
|
|
// 验证内容
|
|
|
- AccountData, err := c.ServiceProjectAccount.ValidRule(c.Ctx)
|
|
|
-
|
|
|
+ accountData, err := c.ServiceBackstage.ValidRuleAccountAdd(c.Ctx)
|
|
|
if err != nil {
|
|
|
- ErrMsg = utils.FormValidError(err)
|
|
|
- c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", ErrMsg)})
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 项目ID
|
|
|
- if AccountData.ProjectId == "" {
|
|
|
- c.Ctx.JSON(iris.Map{"code": -1, "msg": "项目ID必填"})
|
|
|
- }
|
|
|
- projectId, err := utils.GetDecryptId(AccountData.ProjectId)
|
|
|
+ projectId, err := utils.GetDecryptId(accountData.ProjectId)
|
|
|
if err != nil {
|
|
|
c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
|
|
|
return
|
|
@@ -161,7 +154,7 @@ func (c *ProjectAccountBs) PostCreate() {
|
|
|
}
|
|
|
|
|
|
// 新增账号信息
|
|
|
- err = c.ServiceProjectAccount.Add(AccountData, projectId)
|
|
|
+ err = c.ServiceProjectAccount.AddBs(accountData, projectId)
|
|
|
if err != nil {
|
|
|
c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
|
|
|
return
|
|
@@ -171,46 +164,44 @@ func (c *ProjectAccountBs) PostCreate() {
|
|
|
}
|
|
|
|
|
|
// @Summary 编辑账号
|
|
|
-// @Tags 项目设置-管理员
|
|
|
+// @Tags 后台 - 项目账号
|
|
|
// @Description 编辑账号
|
|
|
// @Accept json
|
|
|
// @Produce json
|
|
|
// @Security ApiKeyAuth
|
|
|
// @Param id body string true "账号ID" default(PcqqGsn1O0jBSmLqkuOTwQ)
|
|
|
// @Param projectId body string true "项目ID"
|
|
|
-// @Param role body int true "角色ID"
|
|
|
// @Param name body string true "姓名"
|
|
|
// @Param company body string true "公司"
|
|
|
// @Param position body string true "职位"
|
|
|
+// @Param mobile body string true "手机"
|
|
|
// @Param telephone body string true "座机"
|
|
|
-// @Param accountGroup body int true "账号组"
|
|
|
// @Param X-CSRF-Token header string true "csrf"
|
|
|
// @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
|
|
|
// @Router /backstage/account/save [post]
|
|
|
func (c *ProjectAccountBs) PostSave() {
|
|
|
|
|
|
- // TODO
|
|
|
-
|
|
|
// 验证内容
|
|
|
- AccountData, err := c.ServiceProjectAccount.ValidRule(c.Ctx)
|
|
|
+ accountData, err := c.ServiceBackstage.ValidRuleAccountSave(c.Ctx)
|
|
|
if err != nil {
|
|
|
- ErrMsg := utils.FormValidError(err)
|
|
|
- c.Ctx.JSON(iris.Map{"code": -1, "msg": ErrMsg})
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
// 获得更新账号ID
|
|
|
- id, err := utils.GetDecryptId(AccountData.Id)
|
|
|
+ id, err := utils.GetDecryptId(accountData.Id)
|
|
|
if err != nil {
|
|
|
c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
|
|
|
return
|
|
|
}
|
|
|
- projectId, err := utils.GetProjectId(c.Ctx)
|
|
|
+ // 项目ID
|
|
|
+ projectId, err := utils.GetDecryptId(accountData.ProjectId)
|
|
|
if err != nil {
|
|
|
c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- err = c.ServiceProjectAccount.Save(AccountData, id, projectId)
|
|
|
+ err = c.ServiceProjectAccount.Save(accountData, id, projectId)
|
|
|
if err != nil {
|
|
|
c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
|
|
|
return
|
|
@@ -226,20 +217,21 @@ func (c *ProjectAccountBs) PostSave() {
|
|
|
// @Produce json
|
|
|
// @Security ApiKeyAuth
|
|
|
// @Param id body string true "账号ID" default(PcqqGsn1O0jBSmLqkuOTwQ)
|
|
|
+// @Param projectId body string true "项目ID"
|
|
|
// @Param enable body int true "启用/禁用"
|
|
|
// @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
|
|
|
// @Router /backstage/account/enable [post]
|
|
|
func (c *ProjectAccountBs) PostEnable() {
|
|
|
- // 修改验证方式——TODO
|
|
|
- accountVaild := viewmodels.ProjectAccount{}
|
|
|
- err := c.Ctx.ReadJSON(&accountVaild)
|
|
|
+
|
|
|
+ // 验证内容
|
|
|
+ accountData, err := c.ServiceBackstage.ValidRuleAccountEnable(c.Ctx)
|
|
|
if err != nil {
|
|
|
- c.Ctx.JSON(iris.Map{"code": -1, "msg": "参数错误"})
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
// 账号ID校验
|
|
|
- id, err := utils.GetDecryptId(accountVaild.Id)
|
|
|
+ id, err := utils.GetDecryptId(accountData.Id)
|
|
|
if err != nil {
|
|
|
c.Ctx.JSON(iris.Map{"code": -1, "msg": "账号异常"})
|
|
|
return
|
|
@@ -251,7 +243,7 @@ func (c *ProjectAccountBs) PostEnable() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- err = c.ServiceProjectAccount.Enable(id, projectId, accountVaild.Enable)
|
|
|
+ err = c.ServiceProjectAccount.Enable(id, projectId, accountData.Enable)
|
|
|
if err != nil {
|
|
|
c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
|
|
|
return
|