| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package controller
- import (
- "github.com/kataras/iris/v12/mvc"
- "xps/pkg/system/datamodel"
- "xps/pkg/system/service"
- )
- type CompanyProfileController struct {
- Base
- Service service.CompanyProfileService
- }
- func (c *CompanyProfileController) BeforeActivation(b mvc.BeforeActivation) {
- b.Handle("GET", "/", "GetById" )
- b.Handle("PUT", "/update", "Update" )
- }
- func (c *CompanyProfileController) GetById() *JsonResult {
- ocId := c.GetCurOcId()
- data, err := c.Service.GetById(ocId)
- if err != nil {
- return ResultErr("数据不存在", nil)
- } else {
- return ResultOk("获取成功", data)
- }
- }
- func (c *CompanyProfileController) Update() *JsonResult {
- ocId := c.GetCurOcId()
- cmp := &datamodel.Company{OcId: ocId}
- if err := c.Ctx.ReadJSON(cmp); err != nil {
- return ResultErr(err.Error(), nil)
- }
- if err := c.Service.Update(cmp); err != nil {
- return ResultErr("更新失败", nil)
- }
- return ResultOk("更新成功", nil)
- }
|