|
@@ -21,16 +21,17 @@ type ProjectSettingApi struct {
|
|
|
Ctx iris.Context
|
|
|
// 需要用的service
|
|
|
ServiceProjectAccount services.ProjectAccountService
|
|
|
+ ServiceProject services.ProjectService
|
|
|
}
|
|
|
|
|
|
// @Summary 获得项目账号列表
|
|
|
// @Tags 项目设置-管理员
|
|
|
-// @Description id获得单条信息<br/>name模糊检索
|
|
|
+// @Description id获得单条信息<br/>
|
|
|
// @Accept json
|
|
|
// @Produce json
|
|
|
// @Security ApiKeyAuth
|
|
|
// @Param id body string false "账号ID"
|
|
|
-// @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
|
|
|
+// @Success 200 {object} viewmodels.ProjectAccount "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
|
|
|
// @Router /api/projectSetting/account [get]
|
|
|
func (c *ProjectSettingApi) GetAccount() {
|
|
|
// 获得项目ID
|
|
@@ -75,7 +76,7 @@ func (c *ProjectSettingApi) GetAccount() {
|
|
|
// @Produce json
|
|
|
// @Security ApiKeyAuth
|
|
|
// @Param name body string true "检索内容"
|
|
|
-// @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
|
|
|
+// @Success 200 {object} viewmodels.ProjectAccount "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
|
|
|
// @Router /api/projectSetting/account/search [get]
|
|
|
func (c *ProjectSettingApi) GetAccountSearch() {
|
|
|
// 获得项目ID
|
|
@@ -117,8 +118,9 @@ func (c *ProjectSettingApi) GetAccountSearch() {
|
|
|
// @Param position body string true "职位"
|
|
|
// @Param mobile body string true "手机"
|
|
|
// @Param telephone body string true "座机"
|
|
|
-// @Param accountGroup body string true "账号组"
|
|
|
-// @Success 200 {string} string "{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
|
|
|
+// @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 /api/projectSetting/account/add [post]
|
|
|
func (c *ProjectSettingApi) PostAccountAdd() {
|
|
|
ErrMsg := ""
|
|
@@ -130,8 +132,13 @@ func (c *ProjectSettingApi) PostAccountAdd() {
|
|
|
c.Ctx.JSON(iris.Map{"code": -1, "msg": ErrMsg})
|
|
|
return
|
|
|
} else {
|
|
|
+ projectId, err := utils.GetProjectId(c.Ctx)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
|
|
|
+ return
|
|
|
+ }
|
|
|
// 新增账号信息
|
|
|
- err := c.ServiceProjectAccount.Add(AccountData)
|
|
|
+ err = c.ServiceProjectAccount.Add(AccountData, projectId)
|
|
|
if err != nil {
|
|
|
c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
|
|
|
return
|
|
@@ -139,3 +146,200 @@ func (c *ProjectSettingApi) PostAccountAdd() {
|
|
|
c.Ctx.JSON(iris.Map{"code": 0, "msg": "新增成功"})
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// @Summary 编辑账号
|
|
|
+// @Tags 项目设置-管理员
|
|
|
+// @Description 编辑账号
|
|
|
+// @Accept json
|
|
|
+// @Produce json
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @Param id body string true "账号ID" default(PcqqGsn1O0jBSmLqkuOTwQ)
|
|
|
+// @Param name body string true "姓名"
|
|
|
+// @Param company body string true "公司"
|
|
|
+// @Param position 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 /api/projectSetting/account/save [post]
|
|
|
+func (c *ProjectSettingApi) PostAccountSave() {
|
|
|
+ // 验证内容
|
|
|
+ AccountData, err := c.ServiceProjectAccount.ValidRule(c.Ctx)
|
|
|
+ if err != nil {
|
|
|
+ ErrMsg := utils.FormValidError(err)
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": ErrMsg})
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ // 获得更新账号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)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = c.ServiceProjectAccount.Save(AccountData, id, projectId)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ c.Ctx.JSON(iris.Map{"code": 0, "msg": "编辑成功"})
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// @Summary 账号启用/禁用
|
|
|
+// @Tags 项目设置-管理员
|
|
|
+// @Description 账号启用/禁用
|
|
|
+// @Accept json
|
|
|
+// @Produce json
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @Param id body string true "账号ID" default(PcqqGsn1O0jBSmLqkuOTwQ)
|
|
|
+// @Param enable body int true "启用/禁用"
|
|
|
+// @Param X-CSRF-Token header string true "csrf"
|
|
|
+// @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
|
|
|
+// @Router /api/projectSetting/account/enable [post]
|
|
|
+func (c *ProjectSettingApi) PostAccountEnable() {
|
|
|
+ accountVaild := viewmodels.ProjectAccount{}
|
|
|
+ err := c.Ctx.ReadJSON(&accountVaild)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": "参数错误"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // 账号ID校验
|
|
|
+ id, err := utils.GetDecryptId(accountVaild.Id)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": "账号异常"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 项目ID
|
|
|
+ projectId, err := utils.GetProjectId(c.Ctx)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": "账号异常"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = c.ServiceProjectAccount.Enable(id, projectId, accountVaild.Enable)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ c.Ctx.JSON(iris.Map{"code": 0, "msg": "操作成功"})
|
|
|
+}
|
|
|
+
|
|
|
+// @Summary 删除账号
|
|
|
+// @Tags 项目设置-管理员
|
|
|
+// @Description 删除账号
|
|
|
+// @Accept json
|
|
|
+// @Produce json
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @Param id body string true "账号ID" default(PcqqGsn1O0jBSmLqkuOTwQ)
|
|
|
+// @Param X-CSRF-Token header string true "csrf"
|
|
|
+// @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
|
|
|
+// @Router /api/projectSetting/account/delete [post]
|
|
|
+func (c *ProjectSettingApi) PostAccountDelete() {
|
|
|
+ accountVaild := viewmodels.ProjectAccount{}
|
|
|
+ err := c.Ctx.ReadJSON(&accountVaild)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": "参数错误"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 账号ID校验
|
|
|
+ id, err := utils.GetDecryptId(accountVaild.Id)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": "账号异常"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 项目ID
|
|
|
+ projectId, err := utils.GetProjectId(c.Ctx)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": "账号异常"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = c.ServiceProjectAccount.Delete(id, projectId)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ c.Ctx.JSON(iris.Map{"code": 0, "msg": "操作成功"})
|
|
|
+}
|
|
|
+
|
|
|
+// @Summary 设置账号密码
|
|
|
+// @Tags 项目设置-管理员
|
|
|
+// @Description 设置账号密码
|
|
|
+// @Accept json
|
|
|
+// @Produce json
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @Param id body string true "账号ID" default(PcqqGsn1O0jBSmLqkuOTwQ)
|
|
|
+// @Param account body string true "账号" default(textoopd)
|
|
|
+// @Param password body string true "密码" default(ww123456)
|
|
|
+// @Param X-CSRF-Token header string true "csrf"
|
|
|
+// @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
|
|
|
+// @Router /api/projectSetting/account/change [post]
|
|
|
+func (c *ProjectSettingApi) PostAccountChange() {
|
|
|
+ // 验证内容
|
|
|
+ AccountData, err := c.ServiceProjectAccount.ValidRule(c.Ctx)
|
|
|
+ if err != nil {
|
|
|
+ ErrMsg := utils.FormValidError(err)
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": ErrMsg})
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ // 获得更新账号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)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = c.ServiceProjectAccount.ChangeAccount(id, projectId, AccountData)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ c.Ctx.JSON(iris.Map{"code": 0, "msg": "编辑成功"})
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// @Summary 保存项目信息
|
|
|
+// @Tags 项目设置-管理员
|
|
|
+// @Description 保存项目信息
|
|
|
+// @Accept json
|
|
|
+// @Produce json
|
|
|
+// @Security ApiKeyAuth
|
|
|
+// @Param name body string true "账号ID" default(红旗大桥)
|
|
|
+// @Param X-CSRF-Token header string true "csrf"
|
|
|
+// @Success 200 {string} string "{code:0成功,-1参数类错误,data:viewmodels.ProjectAccount,msg:错误信息}"
|
|
|
+// @Router /api/projectSetting/project/save [post]
|
|
|
+func (c *ProjectSettingApi) PostProjectSave() {
|
|
|
+
|
|
|
+ ProjectData, err := c.ServiceProject.ValidRule(c.Ctx)
|
|
|
+ if err != nil {
|
|
|
+ ErrMsg := utils.FormValidError(err)
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": ErrMsg})
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ // 项目ID
|
|
|
+ projectId, err := utils.GetProjectId(c.Ctx)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": "账号异常"})
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ err = c.ServiceProject.Save(projectId, ProjectData)
|
|
|
+ if err != nil {
|
|
|
+ c.Ctx.JSON(iris.Map{"code": -1, "msg": err})
|
|
|
+ return
|
|
|
+ }
|
|
|
+ c.Ctx.JSON(iris.Map{"code": 0, "msg": "操作成功"})
|
|
|
+ }
|
|
|
+}
|